summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew MacIntyre <andymac@bullseye.apana.org.au>2004-04-11 12:03:57 (GMT)
committerAndrew MacIntyre <andymac@bullseye.apana.org.au>2004-04-11 12:03:57 (GMT)
commitdaedf218524e1c96c289f1785c8f5092642b79ea (patch)
tree95170e8e96177f059f9bd18bc50faf5c8c101610
parentcf6f1b69eb5f491dd3cba6c5c90bcb344d4b3a96 (diff)
downloadcpython-daedf218524e1c96c289f1785c8f5092642b79ea.zip
cpython-daedf218524e1c96c289f1785c8f5092642b79ea.tar.gz
cpython-daedf218524e1c96c289f1785c8f5092642b79ea.tar.bz2
Fixes for AF_UNIX support on OS/2:
- return the full size of the sockaddr_un structure, without which bind() fails with EINVAL; - set test_socketserver to use a socket name that meets the form required by the underlying implementation; - don't bother exercising the forking AF_UNIX tests on EMX - its fork() can't handle the stress.
-rw-r--r--Lib/test/test_socketserver.py23
-rw-r--r--Modules/socketmodule.c4
2 files changed, 23 insertions, 4 deletions
diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py
index cee5593..1245ba5 100644
--- a/Lib/test/test_socketserver.py
+++ b/Lib/test/test_socketserver.py
@@ -94,6 +94,19 @@ def pickaddr(proto):
return (host, pickport())
else:
fn = TESTFN + str(pickport())
+ if os.name == 'os2':
+ # AF_UNIX socket names on OS/2 require a specific prefix
+ # which can't include a drive letter and must also use
+ # backslashes as directory separators
+ if fn[1] == ':':
+ fn = fn[2:]
+ if fn[0] in (os.sep, os.altsep):
+ fn = fn[1:]
+ fn = os.path.join('\socket', fn)
+ if os.sep == '/':
+ fn = fn.replace(os.sep, os.altsep)
+ else:
+ fn = fn.replace(os.altsep, os.sep)
testfiles.append(fn)
return fn
@@ -135,11 +148,13 @@ if not hasattr(socket, 'AF_UNIX'):
dgramservers = []
else:
class ForkingUnixStreamServer(ForkingMixIn, UnixStreamServer): pass
- streamservers = [UnixStreamServer, ThreadingUnixStreamServer,
- ForkingUnixStreamServer]
+ streamservers = [UnixStreamServer, ThreadingUnixStreamServer]
+ if hasattr(os, 'fork') and os.name not in ('os2',):
+ streamservers.append(ForkingUnixStreamServer)
class ForkingUnixDatagramServer(ForkingMixIn, UnixDatagramServer): pass
- dgramservers = [UnixDatagramServer, ThreadingUnixDatagramServer,
- ForkingUnixDatagramServer]
+ dgramservers = [UnixDatagramServer, ThreadingUnixDatagramServer]
+ if hasattr(os, 'fork') and os.name not in ('os2',):
+ dgramservers.append(ForkingUnixDatagramServer)
def testall():
testloop(socket.AF_INET, tcpservers, MyStreamHandler, teststream)
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index d973033..0989171 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -966,7 +966,11 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
memcpy(addr->sun_path, path, len);
addr->sun_path[len] = 0;
*addr_ret = (struct sockaddr *) addr;
+#if defined(PYOS_OS2)
+ *len_ret = sizeof(*addr);
+#else
*len_ret = len + sizeof(*addr) - sizeof(addr->sun_path);
+#endif
return 1;
}
#endif /* AF_UNIX */