http://redmine.emweb.be/http://redmine.emweb.be/favicon.ico?16934085252014-04-04T15:10:26ZRedmineWt - Bug #2901: Application sessions are not always terminated cleanlyhttp://redmine.emweb.be/issues/2901?journal_id=88302014-04-04T15:10:26ZKoen Deforchekoen@emweb.be
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>InProgress</i></li><li><strong>Assignee</strong> set to <i>Wim Dumon</i></li><li><strong>Target version</strong> changed from <i>3.3.2</i> to <i>3.3.3</i></li></ul> Wt - Bug #2901: Application sessions are not always terminated cleanlyhttp://redmine.emweb.be/issues/2901?journal_id=88362014-04-04T17:12:10ZWim Dumonwim@emweb.be
<ul><li><strong>Status</strong> changed from <i>InProgress</i> to <i>Feedback</i></li></ul><p>Well spot, I learned today about Windows' signal handling :-)</p>
<p>My conclusion: Wt's waitForShutdown is a generic method, which is in many cases doing what you want. But I can imagine very well that you don't want your application to terminate without cleanup on the 'special signals' CTRL_CLOSE_EVENT, CTRL_LOGOFF_EVENT, and CTRL_SHUTDOWN_EVENT.</p>
<p>My recommendation to you, is not to use Wt's waitForShutdown() since you want to handle the special signals in a special way, but to write your own. We can never know when your application cleaned up its state, at most we could know when all WServer objects are deleted (but we currently don't maintain a list). Any solution we would come up with, would not work for a certain use case.</p>
<p>Does this make sense?</p>
<p>Wim.</p>
Wt - Bug #2901: Application sessions are not always terminated cleanlyhttp://redmine.emweb.be/issues/2901?journal_id=88372014-04-04T22:18:24ZEivind Midtgårdeivind@learntd.no
<ul></ul><p>Hi Wim,</p>
<p>I'll try that. I had hoped that you could use my code as a starting point. (I would have tried reimplementing your waitForShutdown myself, but so far I have not been able to compile Wt with CMake, and each time I have tried compiling other systems with CMake something has gone wrong, so I have given up on CMake: I now pretend it doesn't exist. Maybe I should try once more.)</p>
<p>There is one thing I need to know: In your console_ctrl_handler you do this:</p>
<pre><code> boost::mutex::scoped_lock terminationLock(terminationMutex);
terminationRequested = true;
terminationCondition.notify_all(); // should be just 1
</code></pre>
<p>Is that something that my code has to do? If so, I believe it will be necessary to add a function to Wt that user-written 'waitForShutdown' functions will have to call when they have finished waiting, so that you have a place to put Wt cleanup code. Also, I wonder if implementing a shutdown function myself will interfere with WRun, which calls your waitForShutdown. I don't use WRun, but it is a pity if all Windows users will have to implement their own waitForShutdown.</p>
<p>Regards,<br><br>
Eivind</p>
Wt - Bug #2901: Application sessions are not always terminated cleanlyhttp://redmine.emweb.be/issues/2901?journal_id=88522014-04-07T09:27:20ZWim Dumonwim@emweb.be
<ul></ul><p>Hi Eivind,</p>
<p>Wt's waitForShutdown() really simply blocks until ctrl-c has been pressed. It uses a boost mutex and a boost condition variable to transfer the event from the console_ctrl_handler to the thread that is blocked by waitForShutdown().</p>
<p>With respect to WRun, you don't have to use Wt's WRun. The documentation of WRun shows you its implementation. Copy-paste that in your project, and replace waitForShutdown() with your version of waitForShutdown().</p>
<p>What I could do, is add a sleep of e.g. 5 seconds at the end of console_ctrl_handler(). Is my assumption correct that if main() exits, this thread will be terminated too? That would then mean that the default waitForShutdown() would give the application at most a few seconds to terminate cleanly. If your application needs more time, you'd have to write your own.</p>
<p>BR,<br><br>
Wim.</p>
Wt - Bug #2901: Application sessions are not always terminated cleanlyhttp://redmine.emweb.be/issues/2901?journal_id=94242014-05-27T14:29:29ZKoen Deforchekoen@emweb.be
<ul><li><strong>Target version</strong> changed from <i>3.3.3</i> to <i>3.3.4</i></li></ul>