another attempt to fix http server crashing problem
it worked in test, hope it works

Change-Id: I452eeb203c96bdcdce642e0ac5f39fb6e03fca6c
diff --git a/gui/chronosharegui.cpp b/gui/chronosharegui.cpp
index 1dbb402..bc02c70 100644
--- a/gui/chronosharegui.cpp
+++ b/gui/chronosharegui.cpp
@@ -164,6 +164,8 @@
 
   delete m_watcher; // stop filewatching ASAP
   delete m_dispatcher; // stop dispatcher ASAP, but after watcher (to prevent triggering callbacks on deleted object)
+  m_httpServer->handle_stop();
+  m_httpServerThread.join();
   delete m_httpServer;
 
   // cleanup
diff --git a/server/server.cpp b/server/server.cpp
index 5d73549..df790ed 100644
--- a/server/server.cpp
+++ b/server/server.cpp
@@ -29,14 +29,12 @@
   // Register to handle the signals that indicate when the server should exit.
   // It is safe to register for the same signal multiple times in a program,
   // provided all registration for the specified signal is made through Asio.
-  /*
   signals_.add(SIGINT);
   signals_.add(SIGTERM);
 #if defined(SIGQUIT)
   signals_.add(SIGQUIT);
 #endif // defined(SIGQUIT)
   signals_.async_wait(boost::bind(&server::handle_stop, this));
-  */
 
   // Open the acceptor with the option to reuse the address (i.e. SO_REUSEADDR).
   boost::asio::ip::tcp::resolver resolver(io_service_);
@@ -54,7 +52,7 @@
 
 server::~server()
 {
-  handle_stop();
+  // handle_stop();
 }
 
 void server::run()
@@ -99,6 +97,11 @@
   // will exit.
   acceptor_.close();
   connection_manager_.stop_all();
+  // although they say io_service::run() would stop, but it didn't happen..
+  // the thread join was blocking, waiting for io_service::run() to finish
+  // even after handle_stop() call..
+  // so just force it quit, no harm here.
+  io_service_.stop();
 }
 
 } // namespace server
diff --git a/server/server.hpp b/server/server.hpp
index d6e50a9..b82088b 100644
--- a/server/server.hpp
+++ b/server/server.hpp
@@ -31,15 +31,16 @@
   explicit server(const std::string& address, const std::string& port,
       const std::string& doc_root);
 
+  ~server();
+
   /// Run the server's io_service loop.
   void run();
 
-  ~server();
-
-private:
   /// Handle a request to stop the server.
   void handle_stop();
 
+private:
+
   /// Initiate an asynchronous accept operation.
   void start_accept();