mirror of
				https://github.com/python/cpython.git
				synced 2025-10-30 21:21:22 +00:00 
			
		
		
		
	accepted sockets shouldn't inherit the SOCK_NONBLOCK flag (closes #25471)
This commit is contained in:
		
							parent
							
								
									458123bd18
								
							
						
					
					
						commit
						d9dbf49383
					
				
					 3 changed files with 9 additions and 1 deletions
				
			
		|  | @ -185,7 +185,11 @@ def accept(self): | |||
|         For IP sockets, the address info is a pair (hostaddr, port). | ||||
|         """ | ||||
|         fd, addr = self._accept() | ||||
|         sock = socket(self.family, self.type, self.proto, fileno=fd) | ||||
|         # If our type has the SOCK_NONBLOCK flag, we shouldn't pass it onto the | ||||
|         # new socket. We do not currently allow passing SOCK_NONBLOCK to | ||||
|         # accept4, so the returned socket is always blocking. | ||||
|         type = self.type & ~globals().get("SOCK_NONBLOCK", 0) | ||||
|         sock = socket(self.family, type, self.proto, fileno=fd) | ||||
|         # Issue #7995: if no default timeout is set and the listening | ||||
|         # socket had a (non-zero) timeout, force the new socket in blocking | ||||
|         # mode to override platform-specific socket flags inheritance. | ||||
|  |  | |||
|  | @ -3863,6 +3863,7 @@ def testAccept(self): | |||
|         read, write, err = select.select([self.serv], [], []) | ||||
|         if self.serv in read: | ||||
|             conn, addr = self.serv.accept() | ||||
|             self.assertIsNone(conn.gettimeout()) | ||||
|             conn.close() | ||||
|         else: | ||||
|             self.fail("Error trying to do accept after select.") | ||||
|  |  | |||
|  | @ -96,6 +96,9 @@ Core and Builtins | |||
| Library | ||||
| ------- | ||||
| 
 | ||||
| - Issue #25471: Sockets returned from accept() shouldn't appear to be | ||||
|   nonblocking. | ||||
| 
 | ||||
| - Issue #25441: asyncio: Raise error from drain() when socket is closed. | ||||
| 
 | ||||
| - Issue #25411: Improved Unicode support in SMTPHandler through better use of | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Benjamin Peterson
						Benjamin Peterson