On 08/07/2013 02:33 PM, LRN wrote:
> I think that someone have sent a message to you directly, as i don't
> have it (and the patches mentioned in it) in my inbox.
> Or maybe mailing list is being sluggish.

I CC'd the list, but I have not received my reply yet so yes it looks like the
mailing list ate it. I will reply with the patch here.

Thanks,
Michael
--- ../SOURCES/libmicrohttpd-0.9.27/src/microhttpd/daemon.c	2013-08-06 13:05:12.574432427 -0500
+++ libmicrohttpd-0.9.27/src/microhttpd/daemon.c	2013-08-07 10:48:52.423404283 -0500
@@ -1388,7 +1388,11 @@
   /* drain signaling pipe to avoid spinning select */
   if ( (-1 != daemon->wpipe[0]) &&
        (FD_ISSET (daemon->wpipe[0], read_fd_set)) )
+#ifndef WINDOWS
     (void) read (daemon->wpipe[0], &tmp, sizeof (tmp));
+#else
+    ReadFile((HANDLE) daemon->wpipe[0], &tmp, sizeof (tmp), NULL, NULL);
+#endif
 
   if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
     {
@@ -1441,9 +1445,6 @@
   DWORD dwBytes;
 #endif
 
-#ifdef WINDOWS
-loop_select:
-#endif
   timeout.tv_sec = 0;
   timeout.tv_usec = 0;
   if (MHD_YES == daemon->shutdown)
@@ -1544,15 +1545,22 @@
       {
         if (! PeekNamedPipe((HANDLE) daemon->wpipe[0], NULL, 0, NULL, &dwBytes, NULL))
           {
-            goto loop_select;
+            FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+                          FORMAT_MESSAGE_FROM_SYSTEM |
+                          FORMAT_MESSAGE_IGNORE_INSERTS,
+                          NULL,
+                          (DWORD) GetLastError(),
+                          MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+                          (LPTSTR) &msgBuffer,
+                          0, NULL);
+            MHD_DLOG (daemon, "PeekNamedPipe failed: %s\n", msgBuffer);
+            LocalFree(msgBuffer);
+            return MHD_NO;
           }
-        else if (dwBytes)
+
+        if (dwBytes)
           FD_SET (daemon->wpipe[0], &rs);
-        else
-          goto loop_select;
       }
-    else
-      goto loop_select;
   }
 #endif
 
@@ -2837,7 +2845,11 @@
     }
   if (-1 != daemon->wpipe[1])
     {
+#ifndef WINDOWS
       if (1 != write (daemon->wpipe[1], "e", 1))
+#else
+      if (! WriteFile ((HANDLE) daemon->wpipe[1], (LPCVOID) "e", 1, NULL, NULL))
+#endif
 	MHD_PANIC ("failed to signal shutdownn via pipe");
     }
 #ifdef HAVE_LISTEN_SHUTDOWN

Reply via email to