Commit d825f158 authored by Jim Fulton's avatar Jim Fulton Committed by GitHub

Merge pull request #52 from zopefoundation/rehabilitate-mtacceptor

Rehabilitate mtacceptor
parents a9330b7e b971495a
......@@ -8,6 +8,12 @@ matrix:
python: 3.4
- os: linux
python: 3.5
- os: linux
python: 3.4
env: ZEO_MTACCEPTOR=1
- os: linux
python: 3.5
env: ZEO_MTACCEPTOR=1
install:
- pip install -U setuptools
- python bootstrap.py
......
......@@ -49,7 +49,10 @@ from ZODB.POSException import TransactionError, ReadOnlyError, ConflictError
from ZODB.serialize import referencesf
from ZODB.utils import oid_repr, p64, u64, z64, Lock, RLock
from .asyncio.server import Acceptor
if os.environ.get("ZEO_MTACCEPTOR"): # mainly for tests
from .asyncio.mtacceptor import Acceptor
else:
from .asyncio.server import Acceptor
logger = logging.getLogger('ZEO.StorageServer')
......@@ -655,6 +658,7 @@ class StorageServer:
transaction_timeout=None,
ssl=None,
client_conflict_resolution=False,
Acceptor=Acceptor,
):
"""StorageServer constructor.
......
......@@ -51,6 +51,7 @@ else:
import asyncore
import socket
import threading
import time
from .server import ServerProtocol
......@@ -130,7 +131,7 @@ class Acceptor(asyncore.dispatcher):
break
if isinstance(addr, tuple) and addr[1] == 0:
self.addr = addr = self.socket.getsockname()
self.addr = addr = self.socket.getsockname()[:2]
logger.info("listening on %s", str(addr))
self.listen(5)
......@@ -177,20 +178,24 @@ class Acceptor(asyncore.dispatcher):
if self.ssl_context is None:
cr = loop.create_connection((lambda : protocol), sock=sock)
else:
#######################################################
# XXX See http://bugs.python.org/issue27392 :(
_make_ssl_transport = loop._make_ssl_transport
def make_ssl_transport(*a, **kw):
kw['server_side'] = True
return _make_ssl_transport(*a, **kw)
loop._make_ssl_transport = make_ssl_transport
#
#######################################################
cr = loop.create_connection(
(lambda : protocol), sock=sock,
ssl=self.ssl_context,
server_hostname='fu' # http://bugs.python.org/issue27391
)
if hasattr(loop, 'connect_accepted_socket'):
loop.connect_accepted_socket(
(lambda : protocol), sock, ssl=self.ssl_context)
else:
#######################################################
# XXX See http://bugs.python.org/issue27392 :(
_make_ssl_transport = loop._make_ssl_transport
def make_ssl_transport(*a, **kw):
kw['server_side'] = True
return _make_ssl_transport(*a, **kw)
loop._make_ssl_transport = make_ssl_transport
#
#######################################################
cr = loop.create_connection(
(lambda : protocol), sock=sock,
ssl=self.ssl_context,
server_hostname=''
)
asyncio.async(cr, loop=loop)
loop.run_forever()
......
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