]> granicus.if.org Git - python/commitdiff
Add setsockopt...SO_REUSEADDR to avoid stupid waiting when killing and
authorGuido van Rossum <guido@python.org>
Thu, 25 Dec 1997 04:48:51 +0000 (04:48 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 25 Dec 1997 04:48:51 +0000 (04:48 +0000)
restarting the server.

Demo/pysvr/pysvr.c

index b1397c9615c261ecc6afba46be127b89bad0db49..e41d88e1ae1c84fe184314a67bcdb13740d39607 100644 (file)
@@ -111,6 +111,11 @@ main_thread(int port)
                exit(1);
        }
 
+#ifdef SO_REUSEADDR
+       i = 1;
+       setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *) &i, sizeof i);
+#endif
+
        memset((char *)&addr, '\0', sizeof addr);
        addr.sin_family = AF_INET;
        addr.sin_port = htons(port);
@@ -214,7 +219,6 @@ init_python()
        if (gtstate)
                return;
        Py_Initialize(); /* Initialize the interpreter */
-       Py_Initialize(); /* Initialize the interpreter */
        PyEval_InitThreads(); /* Create (and acquire) the interpreter lock */
        gtstate = PyEval_SaveThread(); /* Release the thread state */
 }