I was reading this error from the umpteenth news poster about 2.0.35 Win2000
failure...

I have the same problem in installing Apache 2.0.35 on WIndows XP:
[Tue Apr 16 20:39:08 2002] [notice] Parent: Created child process 2628
[Tue Apr 16 20:39:08 2002] [notice] Child 2628: Child process is
running
[Tue Apr 16 20:39:09 2002] [crit] (32538)An operation was attempted on
something that is not a socket.  : Parent: WSADuplicateSocket failed
for socket 3308280.
Check the FAQ.

It occured to me that maybe - if we maintain the handle identity - it might
overcome the "Not a socket" error.

Attached is a patch that doesn't change the socket HANDLE.  Any
objections to at least attempting this? 
Index: server/mpm/winnt/mpm_winnt.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/winnt/mpm_winnt.c,v
retrieving revision 1.263
diff -u -r1.263 mpm_winnt.c
--- server/mpm/winnt/mpm_winnt.c        10 Apr 2002 17:02:00 -0000      1.263
+++ server/mpm/winnt/mpm_winnt.c        17 Apr 2002 05:03:50 -0000
@@ -527,15 +527,32 @@
 
     for (lr = ap_listeners; lr; lr = lr->next) {
         apr_os_sock_get(&nsd,lr->sd);
-        if (!DuplicateHandle(hProcess, (HANDLE) nsd, hProcess, &dup, 
-                             0, FALSE, DUPLICATE_SAME_ACCESS)) {
-            ap_log_error(APLOG_MARK, APLOG_ERR, apr_get_os_error(), ap_server_conf,
-                         "set_listeners_noninheritable: DuplicateHandle failed.");
+        if (osver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
+            if (!DuplicateHandle(hProcess, (HANDLE) nsd, hProcess, &dup, 
+                                 0, FALSE, DUPLICATE_SAME_ACCESS)) {
+                ap_log_error(APLOG_MARK, APLOG_ERR, apr_get_os_error(), 
+ap_server_conf,
+                             "set_listeners_noninheritable: DuplicateHandle failed.");
+            }
+            else {
+                closesocket(nsd);
+                nsd = (SOCKET) dup;
+                apr_os_sock_put(&lr->sd, &nsd, p);
+            }
         }
         else {
-            closesocket(nsd);
-            nsd = (SOCKET) dup;
-            apr_os_sock_put(&lr->sd, &nsd, p);
+            /* A different approach.  Many users report errors such as 
+             * (32538)An operation was attempted on something that is not 
+             * a socket.  : Parent: WSADuplicateSocket failed...
+             *
+             * This appears that the duplicated handle is no longer recognized
+             * as a socket handle.  SetHandleInformation should overcome that
+             * problem by not altering the handle identifier.  But this won't
+             * work on 9x - it's unsupported.
+             */
+            if (!SetHandleInformation(nsd, HANDLE_FLAG_INHERIT, 0)) {
+                ap_log_error(APLOG_MARK, APLOG_ERR, apr_get_os_error(), 
+ap_server_conf,
+                             "set_listeners_noninheritable: SetHandleInformation 
+failed.");
+            }
         }
     }
 



Reply via email to