Add setsockopt...SO_REUSEADDR to avoid stupid waiting when killing and

restarting the server.
This commit is contained in:
Guido van Rossum 1997-12-25 04:48:51 +00:00
parent ccb5ec62e1
commit 643f8f62b4
1 changed files with 5 additions and 1 deletions

View 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 */
}