From: Guido van Rossum Date: Thu, 25 Dec 1997 04:48:51 +0000 (+0000) Subject: Add setsockopt...SO_REUSEADDR to avoid stupid waiting when killing and X-Git-Tag: v1.5~72 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=643f8f62b4a81d8d842d530f54d83f7751b2fb6e;p=thirdparty%2FPython%2Fcpython.git Add setsockopt...SO_REUSEADDR to avoid stupid waiting when killing and restarting the server. --- diff --git a/Demo/pysvr/pysvr.c b/Demo/pysvr/pysvr.c index b1397c9615c2..e41d88e1ae1c 100644 --- a/Demo/pysvr/pysvr.c +++ b/Demo/pysvr/pysvr.c @@ -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 */ }