changeset 1652:4e027adb9f25

add unix socket support to thfcgi
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 31 Oct 2006 22:06:16 +0100
parents 5c15ab661922
children 5b15b6e010cf
files MoinMoin/support/thfcgi.py
diffstat 1 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/support/thfcgi.py	Tue Oct 31 22:06:02 2006 +0100
+++ b/MoinMoin/support/thfcgi.py	Tue Oct 31 22:06:16 2006 +0100
@@ -545,10 +545,19 @@
         """Create socket and verify FCGI environment."""
         try:
             if self.__port:
-                s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-                s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
-                # bind to the localhost
-                s.bind(('127.0.0.1', self.__port))
+                if isinstance(self.__port, str):
+                    try:
+                        os.unlink(self.__port)
+                    except:
+                        pass
+                    s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+                    s.bind(self.__port)
+                    # os.chmod(self.__port, 0660)
+                else:
+                    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+                    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
+                    # bind to the localhost
+                    s.bind(('127.0.0.1', self.__port))
                 s.listen(1)
             else:
                 if hasattr(socket, 'fromfd'):