changeset 11:09f1eceaccec

merge
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 20 Jul 2012 11:46:52 +0200
parents e67a4e1996c1 (current diff) 27e2bbc11200 (diff)
children c38716a8a146
files
diffstat 2 files changed, 19 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/Core/HttpServer/MongooseServer.cpp	Fri Jul 20 11:02:13 2012 +0200
+++ b/Core/HttpServer/MongooseServer.cpp	Fri Jul 20 11:46:52 2012 +0200
@@ -339,7 +339,7 @@
     }
 
     typedef boost::find_iterator<std::string::iterator> FindIterator;
-    typedef boost::iterator_range<std::string::iterator> Range;
+    typedef boost::iterator_range<char*> Range;
 
     //chunkStore.Print();
 
@@ -353,7 +353,7 @@
       {
         if (last != FindIterator())
         {
-/*          Range part(&last->back(), &it->front());
+          Range part(&last->back(), &it->front());
           Range content = boost::find_first(part, "\r\n\r\n");
           if (content != Range())
           {
@@ -379,7 +379,7 @@
                 return chunkStore.Store(completedFile, chunkData, chunkSize, fileName->second, fileSize);
               }
             }
-          }*/
+          }
         }
 
         last = it;
--- a/Core/Toolbox.cpp	Fri Jul 20 11:02:13 2012 +0200
+++ b/Core/Toolbox.cpp	Fri Jul 20 11:46:52 2012 +0200
@@ -32,20 +32,28 @@
 #endif
 
 #if defined(__linux)
+#include <signal.h>
 #include <unistd.h>
 #endif
 
-#include <signal.h>
 
 namespace Palantir
 {
   static bool finish;
 
+#if defined(_WIN32)
+  static BOOL WINAPI ConsoleControlHandler(DWORD dwCtrlType)
+  {
+	// http://msdn.microsoft.com/en-us/library/ms683242(v=vs.85).aspx
+	finish = true;
+	return true;
+  }
+#else
   static void SignalHandler(int)
   {
     finish = true;
   }
-
+#endif
 
   void Toolbox::Sleep(uint32_t seconds)
   {
@@ -72,9 +80,10 @@
 
   void Toolbox::ServerBarrier()
   {
+#if defined(_WIN32)
+	SetConsoleCtrlHandler(ConsoleControlHandler, true);
+#else
     signal(SIGINT, SignalHandler);
-
-#if !defined(_WIN32)
     signal(SIGQUIT, SignalHandler);
 #endif
   
@@ -84,9 +93,10 @@
       USleep(100000);
     }
 
+#if defined(_WIN32)
+	SetConsoleCtrlHandler(ConsoleControlHandler, false);
+#else
     signal(SIGINT, NULL);
-
-#if !defined(_WIN32)
     signal(SIGQUIT, NULL);
 #endif
   }