direct-io.hg

changeset 11128:5db6984e4503

Set the close-on-exec flag on the RPC socket in tool stack.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
author kfraser@localhost.localdomain
date Tue Aug 15 16:26:39 2006 +0100 (2006-08-15)
parents fdc4531aefe0
children 939f75570a15
files tools/python/xen/util/xmlrpclib2.py tools/python/xen/web/httpserver.py
line diff
     1.1 --- a/tools/python/xen/util/xmlrpclib2.py	Tue Aug 15 16:25:39 2006 +0100
     1.2 +++ b/tools/python/xen/util/xmlrpclib2.py	Tue Aug 15 16:26:39 2006 +0100
     1.3 @@ -22,6 +22,7 @@ An enhanced XML-RPC client/server interf
     1.4  
     1.5  import string
     1.6  import types
     1.7 +import fcntl
     1.8  
     1.9  from httplib import HTTPConnection, HTTP
    1.10  from xmlrpclib import Transport
    1.11 @@ -136,6 +137,17 @@ class TCPXMLRPCServer(SocketServer.Threa
    1.12                   logRequests=1):
    1.13          SimpleXMLRPCServer.__init__(self, addr, requestHandler, logRequests)
    1.14  
    1.15 +        flags = fcntl.fcntl(self.fileno(), fcntl.F_GETFD)
    1.16 +        flags |= fcntl.FD_CLOEXEC
    1.17 +        fcntl.fcntl(self.fileno(), fcntl.F_SETFD, flags)
    1.18 +
    1.19 +    def get_request(self):
    1.20 +        (client, addr) = SimpleXMLRPCServer.get_request(self)
    1.21 +        flags = fcntl.fcntl(client.fileno(), fcntl.F_GETFD)
    1.22 +        flags |= fcntl.FD_CLOEXEC
    1.23 +        fcntl.fcntl(client.fileno(), fcntl.F_SETFD, flags)
    1.24 +        return (client, addr)
    1.25 +                                                                                
    1.26      def _marshaled_dispatch(self, data, dispatch_method = None):
    1.27          params, method = xmlrpclib.loads(data)
    1.28          if False:
     2.1 --- a/tools/python/xen/web/httpserver.py	Tue Aug 15 16:25:39 2006 +0100
     2.2 +++ b/tools/python/xen/web/httpserver.py	Tue Aug 15 16:26:39 2006 +0100
     2.3 @@ -24,6 +24,7 @@ import types
     2.4  from urllib import quote, unquote
     2.5  import os
     2.6  import os.path
     2.7 +import fcntl
     2.8  
     2.9  from xen.xend import sxp
    2.10  from xen.xend.Args import ArgError
    2.11 @@ -294,6 +295,9 @@ class HttpServer:
    2.12  
    2.13      def bind(self):
    2.14          self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    2.15 +        flags = fcntl.fcntl(self.socket.fileno(), fcntl.F_GETFD)
    2.16 +        flags |= fcntl.FD_CLOEXEC
    2.17 +        fcntl.fcntl(self.socket.fileno(), fcntl.F_SETFD, flags)
    2.18          self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    2.19          self.socket.bind((self.interface, self.port))
    2.20  
    2.21 @@ -338,3 +342,6 @@ class UnixHttpServer(HttpServer):
    2.22          
    2.23      def bind(self):
    2.24          self.socket = unix.bind(self.path)
    2.25 +        flags = fcntl.fcntl(self.socket.fileno(), fcntl.F_GETFD)
    2.26 +        flags |= fcntl.FD_CLOEXEC
    2.27 +        fcntl.fcntl(self.socket.fileno(), fcntl.F_SETFD, flags)