Hey Alex,

2010/2/22 Alex Sadovsky <[email protected]>:
> Koen,
>
> I could not reproduce the effect with your unmodified source. But when
> I changed the timer interval from 2000 to 500 I could easily get the
> desired result in 30 seconds of clicking "create dialog"/"Ok" as fast
> as my hand allows.

So could I now too without breaking my wrist. Thanks !

And I identified the problem (the recursive event loop was ignoring
other signal notifications that piggy backed on the same request, in
this case the timer event). And I think I have implemented a solid fix
in latest git.

If you want to back-port to Wt-3.0.0, I think the patch in attachment
should apply more or less.

Regards,
koen
commit f4efa76ea9350a0021a058ed3d2523fe6878e18b
Author: Koen Deforche <[email protected]>
Date:   Tue Feb 23 17:35:58 2010 +0100

    fix recursive eventloop interfering with multiple signal notification error

diff --git a/src/web/WebSession.C b/src/web/WebSession.C
index cc2ecdb..6cb6755 100644
--- a/src/web/WebSession.C
+++ b/src/web/WebSession.C
@@ -477,7 +477,7 @@ WebSession::Handler::Handler(WebSession& session, bool takeLock)
 
 WebSession::Handler::Handler(WebSession& session,
 			     WebRequest& request, WebResponse& response)
-  :
+  : 
 #ifdef WT_THREADED
     lock_(session.mutex_),
     prevHandler_(0),
@@ -669,6 +669,9 @@ void WebSession::doRecursiveEventLoop()
    * Finish the request that is being handled
    */
   Handler *handler = WebSession::Handler::instance();
+
+  handler->session()->notifySignal(WEvent(*handler, WebRenderer::Update));
+
   if (handler->response())
     handler->session()->render(*handler, app_->environment().ajax()
 			       ? WebRenderer::Update : WebRenderer::Page);
@@ -712,8 +715,6 @@ bool WebSession::unlockRecursiveEventLoop()
    */
   Handler *handler = WebSession::Handler::instance();
  
-  // handlerPrevious can be 0 if the event loop was already unlocked by
-  // another event while doing WApplication::processEvents()
   recursiveEventLoop_->setRequest(handler->request(), handler->response());
   handler->setRequest(0, 0);
 
@@ -1205,6 +1206,7 @@ void WebSession::notify(const WEvent& event)
 	     */
 
 	    try {
+	      handler.nextSignal = 0;
 	      notifySignal(event);
 	    } catch (std::exception& e) {
 	      log("error") << "Error during event handling: " << e.what();
@@ -1396,15 +1398,18 @@ void WebSession::notifySignal(const WEvent& e)
   renderer_.saveChanges();
 
   // Reorder signals, as browsers sometimes generate them in a strange order
-  std::vector<unsigned int> order = getSignalProcessingOrder(e);
-  for (unsigned i = 0; i < order.size(); ++i) {
+  if (handler.nextSignal == 0)
+    handler.signalOrder = getSignalProcessingOrder(e);
+
+  for (unsigned i = handler.nextSignal; i < handler.signalOrder.size(); ++i) {
     if (!handler.request())
       return;
 
     const WebRequest& request = *handler.request();
 
-    std::string se = i > 0
-      ? 'e' + boost::lexical_cast<std::string>(i) : std::string();
+    int signalI = handler.signalOrder[i];
+    std::string se = signalI > 0
+      ? 'e' + boost::lexical_cast<std::string>(signalI) : std::string();
     const std::string *signalE = getSignal(request, se);
 
     if (!signalE)
@@ -1412,6 +1417,8 @@ void WebSession::notifySignal(const WEvent& e)
 
     propagateFormValues(e, se);
 
+    handler.nextSignal = i + 1;
+
     if (*signalE == "hash") {
       const std::string *hashE = request.getParameter(se + "_");
       if (hashE) {
diff --git a/src/web/WebSession.h b/src/web/WebSession.h
index 72f6d80..6456dbc 100644
--- a/src/web/WebSession.h
+++ b/src/web/WebSession.h
@@ -157,6 +157,9 @@ public:
     WebSession *session() const { return &session_; }
     void killSession();
 
+    int nextSignal;
+    std::vector<unsigned int> signalOrder;
+
   private:
     void init();
 
------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to