Tcl Source Code

Artifact [2d36bde34e]
Login

Artifact 2d36bde34e1cf922420774506498786c5197b5c6:

Attachment "servconfig.patch" to ticket [3394732fff] added by ferrieux 2011-08-21 06:20:41.
Index: unix/tclUnixSock.c
===================================================================
--- unix/tclUnixSock.c
+++ unix/tclUnixSock.c
@@ -815,20 +815,28 @@
 				 * TCL_READABLE, TCL_WRITABLE and
 				 * TCL_EXCEPTION. */
 {
     TcpState *statePtr = (TcpState *) instanceData;
      
-    if (statePtr->flags & TCP_ASYNC_CONNECT) {
-        /* Async sockets use a FileHandler internally while connecting, so we
-         * need to cache this request until the connection has succeeded. */
-        statePtr->filehandlers = mask;
-    } else if (mask) {
-        Tcl_CreateFileHandler(statePtr->fds.fd, mask,
-                              (Tcl_FileProc *) Tcl_NotifyChannel,
-                              (ClientData) statePtr->channel);
-    } else {
-        Tcl_DeleteFileHandler(statePtr->fds.fd);
+    /*
+     * Make sure we don't mess with server sockets since they will never be
+     * readable or writable at the Tcl level. This keeps Tcl scripts from
+     * interfering with the -accept behavior.
+     */
+
+    if (!statePtr->acceptProc) {
+        if (statePtr->flags & TCP_ASYNC_CONNECT) {
+            /* Async sockets use a FileHandler internally while connecting, so we
+             * need to cache this request until the connection has succeeded. */
+            statePtr->filehandlers = mask;
+        } else if (mask) {
+            Tcl_CreateFileHandler(statePtr->fds.fd, mask,
+                                  (Tcl_FileProc *) Tcl_NotifyChannel,
+                                  (ClientData) statePtr->channel);
+        } else {
+            Tcl_DeleteFileHandler(statePtr->fds.fd);
+        }
     }
 }
 
 /*
  *----------------------------------------------------------------------