Quellcode durchsuchen

implement request_resume

Christian Grothoff vor 8 Jahren
Ursprung
Commit
9562d1656d

+ 1 - 1
src/lib/connection_add.c

@@ -369,7 +369,7 @@ thread_main_handle_connection (void *data)
            * moved immediately to cleanup list. Otherwise connection
            * will stay in suspended list until 'urh' will be marked
            * with 'was_closed' by application. */
-          MHD_resume_connection (con);
+          MHD_request_resume (&con->request);
 
           /* skip usual clean up  */
           return (MHD_THRD_RTRN_TYPE_) 0;

+ 1 - 1
src/lib/daemon_epoll.c

@@ -188,7 +188,7 @@ run_epoll_for_upgrade (struct MHD_Daemon *daemon)
            * will be moved immediately to cleanup list. Otherwise
            * connection will stay in suspended list until 'pos' will
            * be marked with 'was_closed' by application. */
-          MHD_resume_connection (pos->connection);
+          MHD_request_resume (&pos->connection->request);
         }
     }
 

+ 1 - 1
src/lib/daemon_poll.c

@@ -326,7 +326,7 @@ MHD_daemon_poll_all_ (struct MHD_Daemon *daemon,
              * moved immediately to cleanup list. Otherwise connection
              * will stay in suspended list until 'urh' will be marked
              * with 'was_closed' by application. */
-            MHD_resume_connection(urh->connection);
+            MHD_request_resume (&urh->connection->request);
           }
       }
 #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */

+ 1 - 1
src/lib/daemon_select.c

@@ -468,7 +468,7 @@ internal_run_from_select (struct MHD_Daemon *daemon,
           MHD_connection_finish_forward_ (urh->connection);
           urh->clean_ready = true;
           /* Resuming will move connection to cleanup list. */
-          MHD_resume_connection(urh->connection);
+          MHD_request_resume (&urh->connection->request);
         }
     }
 #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */

+ 5 - 0
src/lib/internal.h

@@ -1541,6 +1541,11 @@ struct MHD_Daemon
    */
   bool was_quiesced;
 
+  /**
+   * Is some connection wanting to resume?
+   */
+  bool resuming;
+
   /**
    * Allow reusing the address:port combination when binding.
    * See #MHD_daemon_listen_allow_address_reuse().

+ 18 - 1
src/lib/request_resume.c

@@ -42,7 +42,24 @@
 void
 MHD_request_resume (struct MHD_Request *request)
 {
-  abort (); // not implemented...
+  struct MHD_Daemon *daemon = request->daemon;
+  
+  if (daemon->disallow_suspend_resume)
+    MHD_PANIC (_("Cannot resume connections without enabling MHD_ALLOW_SUSPEND_RESUME!\n"));
+  MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
+  request->connection->resuming = true;
+  daemon->resuming = true;
+  MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
+  if ( (MHD_ITC_IS_VALID_(daemon->itc)) &&
+       (! MHD_itc_activate_ (daemon->itc,
+			     "r")) )
+    {
+#ifdef HAVE_MESSAGES
+      MHD_DLOG (daemon,
+		MHD_SC_ITC_USE_FAILED,
+                _("Failed to signal resume via inter-thread communication channel."));
+#endif
+    }
 }
 
 /* end of request_resume.c */