Hi.
In my Wt application we have class Application that is derived from Wt::WApplication.
And we perform  some cleanup in ~Application() destructor.

I've noticed that destructor is never called in FCGI mode when I do "apachectl restart" (although the sessions really exist). On the other hand it's called when I deploy application in wthttp mode and stop it using CTRL+C.

I found 2 faulty places:
1) Wt::~WApplication() destructor has to be declared virtual if we want the derived destructor to be called when we make deletion on a pointer to a base class. For some reason derived destructor is called on my setup even without virtual declaration, but anyway C++ standard says the way I said. And this could lead to problems with other OS/compilers if you don't declare virtual Wt::~WApplication().

2) Apache restarts process with SIGHUP. And it's not handled by Wt in FCGI connector. Therefore we have 1) memory leak, 2) no destructor called - each time we make restart.


Patch attached.

--
Andrii Arsirii
Streamco
http://streamco.org.ua

Index: src/fcgi/Server.C
===================================================================
--- src/fcgi/Server.C	(revision 4772)
+++ src/fcgi/Server.C	(working copy)
@@ -569,6 +569,11 @@
   doShutdown("SIGUSR1");
 }
 
+static void handleSigHup(int)
+{
+  doShutdown("SIGHUP");
+}
+
 void runSession(Configuration& conf, std::string sessionId)
 {
   int s = socket(AF_UNIX, SOCK_STREAM, 0);
@@ -717,6 +722,9 @@
     if (signal(SIGUSR1, Wt::handleSigUsr1) == SIG_ERR) 
       conf.log("error") << "Cannot catch SIGUSR1: signal(): "
 			<< strerror(errno);
+    if (signal(SIGHUP, Wt::handleSigHup) == SIG_ERR)
+      conf.log("error") << "Cannot catch SIGHUP: signal(): "
+			<< strerror(errno);
 
     if (createApplication)
       entryPoints.push_back(EntryPoint(WebSession::Application,
Index: src/Wt/WApplication
===================================================================
--- src/Wt/WApplication	(revision 4772)
+++ src/Wt/WApplication	(working copy)
@@ -144,7 +144,7 @@
    * The destructor deletes the root() container, and as a consequence
    * the entire widget tree.
    */
-  ~WApplication();
+  virtual ~WApplication();
 
   /*! \brief Returns the current application instance.
    *
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to