[CalendarServer-changes] [14749] CalendarServer/branches/users/sagen/request-socket
source_changes at macosforge.org
source_changes at macosforge.org
Mon May 4 20:35:07 PDT 2015
Revision: 14749
http://trac.calendarserver.org//changeset/14749
Author: sagen at apple.com
Date: 2015-05-04 20:35:07 -0700 (Mon, 04 May 2015)
Log Message:
-----------
Starting work on unix domain socket file support for requests
Modified Paths:
--------------
CalendarServer/branches/users/sagen/request-socket/calendarserver/tap/caldav.py
CalendarServer/branches/users/sagen/request-socket/requirements-stable.txt
CalendarServer/branches/users/sagen/request-socket/twistedcaldav/stdconfig.py
CalendarServer/branches/users/sagen/request-socket/txweb2/channel/http.py
CalendarServer/branches/users/sagen/request-socket/txweb2/metafd.py
Modified: CalendarServer/branches/users/sagen/request-socket/calendarserver/tap/caldav.py
===================================================================
--- CalendarServer/branches/users/sagen/request-socket/calendarserver/tap/caldav.py 2015-05-05 03:33:50 UTC (rev 14748)
+++ CalendarServer/branches/users/sagen/request-socket/calendarserver/tap/caldav.py 2015-05-05 03:35:07 UTC (rev 14749)
@@ -1112,17 +1112,20 @@
# Inherit a single socket to receive accept()ed connections via
# recvmsg() and SCM_RIGHTS.
- try:
- contextFactory = self.createContextFactory()
- except SSLError, e:
- self.log.error(
- "Unable to set up SSL context factory: {error}",
- error=e
- )
- # None is okay as a context factory for ReportingHTTPService as
- # long as we will never receive a file descriptor with the
- # 'SSL' tag on it, since that's the only time it's used.
+ if config.RequestSocket:
contextFactory = None
+ else:
+ try:
+ contextFactory = self.createContextFactory()
+ except SSLError, e:
+ self.log.error(
+ "Unable to set up SSL context factory: {error}",
+ error=e
+ )
+ # None is okay as a context factory for ReportingHTTPService as
+ # long as we will never receive a file descriptor with the
+ # 'SSL' tag on it, since that's the only time it's used.
+ contextFactory = None
ReportingHTTPService(
requestFactory, int(config.MetaFD), contextFactory
@@ -1750,41 +1753,47 @@
s._inheritedSockets = []
dispatcher = None
- for bindAddress in self._allBindAddresses():
- self._validatePortConfig()
- if config.UseMetaFD:
- portsList = [(config.BindHTTPPorts, "TCP")]
- if config.EnableSSL:
- portsList.append((config.BindSSLPorts, "SSL"))
- for ports, description in portsList:
- for port in ports:
- cl.addPortService(
- description, port, bindAddress,
- config.ListenBacklog
+ if config.RequestSocket:
+ cl.addSocketFileService(
+ "TCP", config.RequestSocket, config.ListenBacklog
+ )
+
+ else:
+ for bindAddress in self._allBindAddresses():
+ self._validatePortConfig()
+ if config.UseMetaFD:
+ portsList = [(config.BindHTTPPorts, "TCP")]
+ if config.EnableSSL:
+ portsList.append((config.BindSSLPorts, "SSL"))
+ for ports, description in portsList:
+ for port in ports:
+ cl.addPortService(
+ description, port, bindAddress,
+ config.ListenBacklog
+ )
+ else:
+ def _openSocket(addr, port):
+ log.info(
+ "Opening socket for inheritance at {address}:{port}",
+ address=addr, port=port
)
- else:
- def _openSocket(addr, port):
- log.info(
- "Opening socket for inheritance at {address}:{port}",
- address=addr, port=port
- )
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- sock.setblocking(0)
- sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
- sock.bind((addr, port))
- sock.listen(config.ListenBacklog)
- s._inheritedSockets.append(sock)
- return sock
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ sock.setblocking(0)
+ sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
+ sock.bind((addr, port))
+ sock.listen(config.ListenBacklog)
+ s._inheritedSockets.append(sock)
+ return sock
- for portNum in config.BindHTTPPorts:
- sock = _openSocket(bindAddress, int(portNum))
- inheritFDs.append(sock.fileno())
-
- if config.EnableSSL:
- for portNum in config.BindSSLPorts:
+ for portNum in config.BindHTTPPorts:
sock = _openSocket(bindAddress, int(portNum))
- inheritSSLFDs.append(sock.fileno())
+ inheritFDs.append(sock.fileno())
+ if config.EnableSSL:
+ for portNum in config.BindSSLPorts:
+ sock = _openSocket(bindAddress, int(portNum))
+ inheritSSLFDs.append(sock.fileno())
+
# Start listening on the stats socket, for administrators to inspect
# the current stats on the server.
stats = None
Modified: CalendarServer/branches/users/sagen/request-socket/requirements-stable.txt
===================================================================
--- CalendarServer/branches/users/sagen/request-socket/requirements-stable.txt 2015-05-05 03:33:50 UTC (rev 14748)
+++ CalendarServer/branches/users/sagen/request-socket/requirements-stable.txt 2015-05-05 03:35:07 UTC (rev 14749)
@@ -36,7 +36,7 @@
#pyOpenSSL
pycrypto==2.6.1
- --editable svn+http://svn.calendarserver.org/repository/calendarserver/twext/trunk@14741#egg=twextpy
+ --editable svn+http://svn.calendarserver.org/repository/calendarserver/twext/trunk@14748#egg=twextpy
cffi==0.8.6
pycparser==2.10
#twisted
Modified: CalendarServer/branches/users/sagen/request-socket/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/branches/users/sagen/request-socket/twistedcaldav/stdconfig.py 2015-05-05 03:33:50 UTC (rev 14748)
+++ CalendarServer/branches/users/sagen/request-socket/twistedcaldav/stdconfig.py 2015-05-05 03:35:07 UTC (rev 14749)
@@ -173,6 +173,9 @@
#
# This configures the actual network address that the server binds to.
#
+
+ "RequestSocket": "caldavd_requests.sock",
+
"BindAddresses": [], # List of IP addresses to bind to [empty = all]
"BindHTTPPorts": [], # List of port numbers to bind to for HTTP
# [empty = same as "Port"]
@@ -1213,6 +1216,7 @@
("RunRoot", "PIDFile"),
("RunRoot", ("Stats", "UnixStatsSocket",)),
("RunRoot", "ControlSocket"),
+ ("RunRoot", "RequestSocket"),
("RunRoot", ("Memcached", "Pools", "Default", "MemcacheSocket")),
("RunRoot", ("DirectoryProxy", "SocketPath",)),
]
Modified: CalendarServer/branches/users/sagen/request-socket/txweb2/channel/http.py
===================================================================
--- CalendarServer/branches/users/sagen/request-socket/txweb2/channel/http.py 2015-05-05 03:33:50 UTC (rev 14748)
+++ CalendarServer/branches/users/sagen/request-socket/txweb2/channel/http.py 2015-05-05 03:35:07 UTC (rev 14749)
@@ -116,7 +116,7 @@
if hostname is None:
try:
hostname = socket.gethostbyaddr(hostaddr)[0]
- except socket.herror:
+ except (socket.herror, socket.gaierror):
hostname = hostaddr
_cachedHostNames[hostaddr] = hostname
return hostname
Modified: CalendarServer/branches/users/sagen/request-socket/txweb2/metafd.py
===================================================================
--- CalendarServer/branches/users/sagen/request-socket/txweb2/metafd.py 2015-05-05 03:33:50 UTC (rev 14748)
+++ CalendarServer/branches/users/sagen/request-socket/txweb2/metafd.py 2015-05-05 03:35:07 UTC (rev 14749)
@@ -34,6 +34,7 @@
from twisted.python.util import FancyStrMixin
from twisted.internet.tcp import Server
from twext.internet.sendfdport import IStatusWatcher
+from twext.internet.socketfile import MaxAcceptSocketFileServer
log = Logger()
@@ -112,6 +113,7 @@
Create a TCP transport, from a socket object passed by the parent.
"""
self._connectionCount += 1
+ print("XYZZY create transport", peer)
transport = Server(skt, protocol, peer, JustEnoughLikeAPort,
self._connectionCount, reactor)
if data == 'SSL':
@@ -345,6 +347,14 @@
).setServiceParent(self)
+ def addSocketFileService(self, description, address, backlog=None):
+ lipf = LimitingInheritingProtocolFactory(self, description)
+ self.factories.append(lipf)
+ MaxAcceptSocketFileServer(
+ lipf, address, backlog=backlog
+ ).setServiceParent(self)
+
+
# IStatusWatcher
def initialStatus(self):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150504/a4e4c41b/attachment-0001.html>
More information about the calendarserver-changes
mailing list