[ python-Bugs-1222790 ] SimpleXMLRPCServer does not set FD_CLOEXEC
SourceForge.net
noreply at sourceforge.net
Sun Dec 4 16:08:57 CET 2005
Bugs item #1222790, was opened at 2005-06-17 13:18
Message generated for change (Comment added) made by akuchling
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1222790&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Demos and Tools
>Group: Python 2.5
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Winfried Harbecke (wharbecke)
>Assigned to: A.M. Kuchling (akuchling)
Summary: SimpleXMLRPCServer does not set FD_CLOEXEC
Initial Comment:
The SimpleXMLRPCServer constructor does not set
FD_CLOEXEC on the socket that listens for new
connections. When the XML RPC server spawns other
daemons, and the XML RPC server is stopped before
the spawned daemon dies, the spawned daemon will
hog the inherited socket and the XML RPC server will be
unable to open its listening socket again
(ADDR_IN_USE). Since there is no reason why a
spawned process should inherit the listen socket, the
close-on-exec flag should be used to prevent inheriting
the socket to spawned processes.
import socket
+ import fcntl
import xmlrpclib
...
def __init__(self, addr, ...
SocketServer.TCPServer.__init__(self, addr,
requestHandler)
! # close on exec - spawned shell should not
access the service
! # listen socket
! flags = fcntl.fcntl(self.fileno(), fcntl.F_GETFD)
! flags |= fcntl.FD_CLOEXEC
! fcntl.fcntl(self.fileno(), fcntl.F_SETFD, flags)
!
There is a similar fix in the Zope distribution, see
http://archives.free.net.ph/message/20030719.201708.f3a
aed4d.html
----------------------------------------------------------------------
>Comment By: A.M. Kuchling (akuchling)
Date: 2005-12-04 10:08
Message:
Logged In: YES
user_id=11375
Fixed in rev41585. SimpleXMLRPCServer now sets
allow_reuse_address to True, and also sets FD_CLOEXEC.
----------------------------------------------------------------------
Comment By: Sean Reifschneider (jafo)
Date: 2005-06-28 22:58
Message:
Logged In: YES
user_id=81797
I don't fully understand the implications of this, but I'd
vote for a fix of this as well. It's pretty painful to use
the SimpleXMLRPCServer for development because of the wait
time required between tests until the OS clears the "in use"
flag. I was thining that it was not setting the flag for
immediate re-use of the socket, though.
Sean
----------------------------------------------------------------------
Comment By: Sean Reifschneider (jafo)
Date: 2005-06-28 22:56
Message:
Logged In: YES
user_id=81797
I don't fully understand the implications of this, but I'd
vote for a fix of this as well. It's pretty painful to use
the SimpleXMLRPCServer for development because of the wait
time required between tests until the OS clears the "in use"
flag. I was thining that it was not setting the flag for
immediate re-use of the socket, though.
Sean
----------------------------------------------------------------------
Comment By: Sean Reifschneider (jafo)
Date: 2005-06-28 22:55
Message:
Logged In: YES
user_id=81797
I don't fully understand the implications of this, but I'd
vote for a fix of this as well. It's pretty painful to use
the SimpleXMLRPCServer for development because of the wait
time required between tests until the OS clears the "in use"
flag. I was thining that it was not setting the flag for
immediate re-use of the socket, though.
Sean
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1222790&group_id=5470
More information about the Python-bugs-list
mailing list