Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
acbf5235
Commit
acbf5235
authored
Oct 13, 2014
by
Charles-François Natali
Browse files
Options
Browse Files
Download
Plain Diff
Issue #22435: Fix a file descriptor leak when SocketServer bind fails.
parents
dfbeb160
0f4f048f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
2 deletions
+18
-2
Lib/socketserver.py
Lib/socketserver.py
+6
-2
Lib/test/test_socketserver.py
Lib/test/test_socketserver.py
+10
-0
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/socketserver.py
View file @
acbf5235
...
...
@@ -439,8 +439,12 @@ class TCPServer(BaseServer):
self
.
socket
=
socket
.
socket
(
self
.
address_family
,
self
.
socket_type
)
if
bind_and_activate
:
self
.
server_bind
()
self
.
server_activate
()
try
:
self
.
server_bind
()
self
.
server_activate
()
except
:
self
.
server_close
()
raise
def
server_bind
(
self
):
"""Called by constructor to bind the socket.
...
...
Lib/test/test_socketserver.py
View file @
acbf5235
...
...
@@ -270,6 +270,16 @@ class SocketServerTest(unittest.TestCase):
t
.
join
()
s
.
server_close
()
def
test_tcpserver_bind_leak
(
self
):
# Issue #22435: the server socket wouldn't be closed if bind()/listen()
# failed.
# Create many servers for which bind() will fail, to see if this result
# in FD exhaustion.
for
i
in
range
(
1024
):
with
self
.
assertRaises
(
OverflowError
):
socketserver
.
TCPServer
((
HOST
,
-
1
),
socketserver
.
StreamRequestHandler
)
def
test_main
():
if
imp
.
lock_held
():
...
...
Misc/NEWS
View file @
acbf5235
...
...
@@ -174,6 +174,8 @@ Core and Builtins
Library
-------
-
Issue
#
22435
:
Fix
a
file
descriptor
leak
when
SocketServer
bind
fails
.
-
Issue
#
13096
:
Fixed
segfault
in
CTypes
POINTER
handling
of
large
values
.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment