Commit 85b56f12 authored by 's avatar

Merged Dieter Maurers closeOnExec stuff from 2.2. branch

parent 469f515a
......@@ -103,7 +103,7 @@ from medusa import asynchat, asyncore, logger
from medusa.counter import counter
from medusa.http_server import compute_timezone_for_log
from ZServer import CONNECTION_LIMIT
from ZServer import CONNECTION_LIMIT, requestCloseOnExec
from PubCore import handle
from PubCore.ZEvent import Wakeup
......@@ -347,6 +347,7 @@ class FCGIChannel(asynchat.async_chat):
self.server = server
self.addr = addr
asynchat.async_chat.__init__(self, sock)
requestCloseOnExec(sock)
self.setInitialState()
self.remainingRecs = 1 # We have to read at least one
self.env = {}
......
......@@ -142,7 +142,7 @@ from medusa import asyncore, asynchat, filesys
from FTPResponse import make_response
from FTPRequest import FTPRequest
from ZServer import CONNECTION_LIMIT
from ZServer import CONNECTION_LIMIT, requestCloseOnExec
from cStringIO import StringIO
import string
......@@ -161,6 +161,7 @@ class zope_ftp_channel(ftp_channel):
def __init__ (self, server, conn, addr, module):
ftp_channel.__init__(self,server,conn,addr)
requestCloseOnExec(conn)
self.module=module
self.userid=''
self.password=''
......
......@@ -123,7 +123,7 @@ from medusa.default_handler import split_path, unquote, get_header
from medusa.asyncore import compact_traceback, dispatcher
from ZServer import CONNECTION_LIMIT, ZOPE_VERSION, ZSERVER_VERSION
from ZServer import requestCloseOnExec
from zLOG import LOG, register_subsystem, BLATHER, INFO, WARNING, ERROR
import DebugLogger
from medusa import logger
......@@ -327,6 +327,7 @@ class zhttp_channel(http_channel):
def __init__(self, server, conn, addr):
http_channel.__init__(self, server, conn, addr)
requestCloseOnExec(conn)
self.queue=[]
self.working=0
......
......@@ -105,7 +105,7 @@ from medusa.counter import counter
from medusa.http_server import compute_timezone_for_log
from medusa.asyncore import compact_traceback
from ZServer import CONNECTION_LIMIT
from ZServer import CONNECTION_LIMIT, requestCloseOnExec
from PubCore import handle
from PubCore.ZEvent import Wakeup
......@@ -132,6 +132,7 @@ class PCGIChannel(asynchat.async_chat):
self.server = server
self.addr = addr
asynchat.async_chat.__init__ (self, sock)
requestCloseOnExec(sock)
self.env={}
self.data=StringIO()
self.set_terminator(10)
......
......@@ -119,6 +119,20 @@ try:
except:
pass
# A routine to try to arrange for request sockets to be closed
# on exec. This makes it easier for folks who spawn long running
# processes from Zope code. Thanks to Dieter Maurer for this.
try:
import fcntl, FCNTL
FCNTL.F_SETFD; FCNTL.FD_CLOEXEC
def requestCloseOnExec(sock):
fcntl.fcntl(sock.fileno(), FCNTL.F_SETFD, FCNTL.FD_CLOEXEC)
except (ImportError, AttributeError):
def requestCloseOnExec(sock):
pass
from medusa import resolver, logger, asyncore
from HTTPServer import zhttp_server, zhttp_handler
from PCGIServer import PCGIServer
......
......@@ -103,7 +103,7 @@ from medusa import asynchat, asyncore, logger
from medusa.counter import counter
from medusa.http_server import compute_timezone_for_log
from ZServer import CONNECTION_LIMIT
from ZServer import CONNECTION_LIMIT, requestCloseOnExec
from PubCore import handle
from PubCore.ZEvent import Wakeup
......@@ -347,6 +347,7 @@ class FCGIChannel(asynchat.async_chat):
self.server = server
self.addr = addr
asynchat.async_chat.__init__(self, sock)
requestCloseOnExec(sock)
self.setInitialState()
self.remainingRecs = 1 # We have to read at least one
self.env = {}
......
......@@ -142,7 +142,7 @@ from medusa import asyncore, asynchat, filesys
from FTPResponse import make_response
from FTPRequest import FTPRequest
from ZServer import CONNECTION_LIMIT
from ZServer import CONNECTION_LIMIT, requestCloseOnExec
from cStringIO import StringIO
import string
......@@ -161,6 +161,7 @@ class zope_ftp_channel(ftp_channel):
def __init__ (self, server, conn, addr, module):
ftp_channel.__init__(self,server,conn,addr)
requestCloseOnExec(conn)
self.module=module
self.userid=''
self.password=''
......
......@@ -123,7 +123,7 @@ from medusa.default_handler import split_path, unquote, get_header
from medusa.asyncore import compact_traceback, dispatcher
from ZServer import CONNECTION_LIMIT, ZOPE_VERSION, ZSERVER_VERSION
from ZServer import requestCloseOnExec
from zLOG import LOG, register_subsystem, BLATHER, INFO, WARNING, ERROR
import DebugLogger
from medusa import logger
......@@ -327,6 +327,7 @@ class zhttp_channel(http_channel):
def __init__(self, server, conn, addr):
http_channel.__init__(self, server, conn, addr)
requestCloseOnExec(conn)
self.queue=[]
self.working=0
......
......@@ -105,7 +105,7 @@ from medusa.counter import counter
from medusa.http_server import compute_timezone_for_log
from medusa.asyncore import compact_traceback
from ZServer import CONNECTION_LIMIT
from ZServer import CONNECTION_LIMIT, requestCloseOnExec
from PubCore import handle
from PubCore.ZEvent import Wakeup
......@@ -132,6 +132,7 @@ class PCGIChannel(asynchat.async_chat):
self.server = server
self.addr = addr
asynchat.async_chat.__init__ (self, sock)
requestCloseOnExec(sock)
self.env={}
self.data=StringIO()
self.set_terminator(10)
......
......@@ -119,6 +119,20 @@ try:
except:
pass
# A routine to try to arrange for request sockets to be closed
# on exec. This makes it easier for folks who spawn long running
# processes from Zope code. Thanks to Dieter Maurer for this.
try:
import fcntl, FCNTL
FCNTL.F_SETFD; FCNTL.FD_CLOEXEC
def requestCloseOnExec(sock):
fcntl.fcntl(sock.fileno(), FCNTL.F_SETFD, FCNTL.FD_CLOEXEC)
except (ImportError, AttributeError):
def requestCloseOnExec(sock):
pass
from medusa import resolver, logger, asyncore
from HTTPServer import zhttp_server, zhttp_handler
from PCGIServer import PCGIServer
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment