version 0.3.15
[fms.git] / src / http / httpthread.cpp
index 89edc93..2ddfbcd 100644 (file)
@@ -25,28 +25,39 @@ void HTTPThread::run()
 {\r
        m_log->debug("HTTPThread::run thread started.");\r
 \r
-       Poco::Net::ServerSocket sock(m_listenport);\r
-       Poco::Net::HTTPServerParams* pParams = new Poco::Net::HTTPServerParams;\r
-       pParams->setMaxQueued(30);\r
-       pParams->setMaxThreads(5);\r
-       Poco::Net::HTTPServer srv(new FMSHTTPRequestHandlerFactory,sock,pParams);\r
+       try\r
+       {\r
+               Poco::Net::ServerSocket sock(m_listenport);\r
+               Poco::Net::HTTPServerParams* pParams = new Poco::Net::HTTPServerParams;\r
+               pParams->setMaxQueued(30);\r
+               pParams->setMaxThreads(5);\r
+               Poco::Net::HTTPServer srv(new FMSHTTPRequestHandlerFactory,sock,pParams);\r
+\r
+               srv.start();\r
+               m_log->trace("Started HTTPServer");\r
 \r
-       srv.start();\r
-       m_log->trace("Started HTTPServer");\r
+               do\r
+               {\r
+                       Poco::Thread::sleep(1000);\r
+               }while(!IsCancelled());\r
 \r
-       do\r
+               m_log->trace("Trying to stop HTTPServer");\r
+               srv.stop();\r
+               m_log->trace("Stopped HTTPServer");\r
+               \r
+               m_log->trace("Waiting for current HTTP requests to finish");\r
+               while(srv.currentConnections()>0)\r
+               {\r
+                       Poco::Thread::sleep(500);\r
+               }\r
+       }\r
+       catch(Poco::Exception &e)\r
        {\r
-               Poco::Thread::sleep(1000);\r
-       }while(!IsCancelled());\r
-\r
-       m_log->trace("Trying to stop HTTPServer");\r
-       srv.stop();\r
-       m_log->trace("Stopped HTTPServer");\r
-       \r
-       m_log->trace("Waiting for current HTTP requests to finish");\r
-       while(srv.currentConnections()>0)\r
+               m_log->fatal("HTTPThread::run caught "+e.displayText());\r
+       }\r
+       catch(...)\r
        {\r
-               Poco::Thread::sleep(500);\r
+               m_log->fatal("HTTPThread::run caught unknown exception");\r
        }\r
 \r
        m_log->debug("HTTPThread::run thread exiting.");\r