Преглед на файлове

Added debug print for connection suspend/resume

Evgeny Grin (Karlson2k) преди 10 месеца
родител
ревизия
598655d9f6
променени са 5 файла, в които са добавени 55 реда и са изтрити 3 реда
  1. 5 0
      src/incl_priv/mhd_sys_options.h
  2. 10 0
      src/mhd2/events_process.c
  3. 9 0
      src/mhd2/request_resume.c
  4. 14 0
      src/mhd2/stream_process_request.c
  5. 17 3
      src/mhd2/stream_process_states.c

+ 5 - 0
src/incl_priv/mhd_sys_options.h

@@ -521,6 +521,11 @@
 /* #  define mhd_DEBUG_EXTR_EVENTS 1 */
 #endif
 
+#ifndef mhd_DEBUG_SUSPEND_RESUME
+/* Use debug-print for suspending and resuming of the requests */
+/* #  define mhd_DEBUG_SUSPEND_RESUME 1 */
+#endif
+
 #ifndef MHD_AUTH_DIGEST_DEF_TIMEOUT
 #  define MHD_AUTH_DIGEST_DEF_TIMEOUT 90
 #endif /* ! MHD_AUTH_DIGEST_DEF_TIMEOUT */

+ 10 - 0
src/mhd2/events_process.c

@@ -30,6 +30,10 @@
 #include "mhd_assert.h"
 #include "mhd_unreachable.h"
 
+#ifdef mhd_DEBUG_SUSPEND_RESUME
+#  include <stdio.h>
+#endif /* mhd_DEBUG_SUSPEND_RESUME */
+
 #include "mhd_locks.h"
 
 #include "mhd_socket_type.h"
@@ -132,6 +136,12 @@ daemon_resume_conns_if_needed (struct MHD_Daemon *restrict d)
       continue;
 
     mhd_assert (c->suspended);
+#ifdef mhd_DEBUG_SUSPEND_RESUME
+    fprintf (stderr,
+             "%%%%%%   Resuming connection, FD: %llu\n",
+             (unsigned long long) c->sk.fd);
+#endif /* mhd_DEBUG_SUSPEND_RESUME */
+
     c->suspended = false;
     mhd_stream_resumed_activity_mark (c);
     mhd_conn_mark_ready (c, d); /* Force processing connection in this round */

+ 9 - 0
src/mhd2/request_resume.c

@@ -28,6 +28,10 @@
 
 #include "mhd_cntnr_ptr.h"
 
+#ifdef mhd_DEBUG_SUSPEND_RESUME
+#  include <stdio.h>
+#endif /* mhd_DEBUG_SUSPEND_RESUME */
+
 #include "mhd_daemon.h"
 #include "mhd_connection.h"
 
@@ -44,6 +48,11 @@ MHD_request_resume (struct MHD_Request *request)
   struct MHD_Daemon *d = c->daemon;
 
   c->resuming = true;
+#ifdef mhd_DEBUG_SUSPEND_RESUME
+  fprintf (stderr,
+           "%%%%%% Requested conn resume, FD: %llu\n",
+           (unsigned long long) c->sk.fd);
+#endif /* mhd_DEBUG_SUSPEND_RESUME */
   d->threading.resume_requested = true;
   mhd_daemon_trigger_itc (d);
 }

+ 14 - 0
src/mhd2/stream_process_request.c

@@ -40,6 +40,10 @@
 
 #include "sys_malloc.h"
 
+#ifdef mhd_DEBUG_SUSPEND_RESUME
+#  include <stdio.h>
+#endif /* mhd_DEBUG_SUSPEND_RESUME */
+
 #include "mhd_str_types.h"
 #include "mhd_str_macros.h"
 #include "mhd_str.h"
@@ -3002,6 +3006,11 @@ mhd_stream_call_app_request_cb (struct MHD_Connection *restrict c)
 #endif /* MHD_SUPPORT_POST_PARSER */
   case mhd_ACTION_SUSPEND:
     c->suspended = true;
+#ifdef mhd_DEBUG_SUSPEND_RESUME
+    fprintf (stderr,
+             "%%%%%% Suspending connection, FD: %llu\n",
+             (unsigned long long) c->sk.fd);
+#endif /* mhd_DEBUG_SUSPEND_RESUME */
     return false;
 #ifdef MHD_SUPPORT_UPGRADE
   case mhd_ACTION_UPGRADE:
@@ -3063,6 +3072,11 @@ mhd_stream_process_upload_action (struct MHD_Connection *restrict c,
     return false;
   case mhd_UPLOAD_ACTION_SUSPEND:
     c->suspended = true;
+#ifdef mhd_DEBUG_SUSPEND_RESUME
+    fprintf (stderr,
+             "%%%%%% Suspending connection, FD: %llu\n",
+             (unsigned long long) c->sk.fd);
+#endif /* mhd_DEBUG_SUSPEND_RESUME */
     return false;
 #ifdef MHD_SUPPORT_UPGRADE
   case mhd_UPLOAD_ACTION_UPGRADE:

+ 17 - 3
src/mhd2/stream_process_states.c

@@ -55,6 +55,10 @@
 #  include "upgrade_proc.h"
 #endif /* MHD_SUPPORT_UPGRADE */
 
+#ifdef mhd_DEBUG_SUSPEND_RESUME
+#  include <stdio.h>
+#endif /* mhd_DEBUG_SUSPEND_RESUME */
+
 MHD_INTERNAL MHD_FN_PAR_NONNULL_ALL_ void
 mhd_conn_event_loop_state_update (struct MHD_Connection *restrict c)
 {
@@ -186,11 +190,16 @@ mhd_conn_event_loop_state_update (struct MHD_Connection *restrict c)
 static MHD_FN_PAR_NONNULL_ALL_ void
 finish_resume (struct MHD_Connection *restrict c)
 {
-  mhd_assert (! c->suspended);
   mhd_assert (c->resuming);
-  mhd_assert (MHD_EVENT_LOOP_INFO_PROCESS == c->event_loop_info);
-
   c->resuming = false;
+
+#ifdef mhd_DEBUG_SUSPEND_RESUME
+  fprintf (stderr,
+           "%%%%%%    Resumed connection, FD: %llu\n",
+           (unsigned long long) c->sk.fd);
+#endif /* mhd_DEBUG_SUSPEND_RESUME */
+  mhd_assert (! c->suspended);
+  mhd_assert (MHD_EVENT_LOOP_INFO_PROCESS == c->event_loop_info);
 }
 
 
@@ -526,6 +535,11 @@ mhd_conn_process_data (struct MHD_Connection *restrict c)
 
     mhd_conn_mark_unready (c, d);
     mhd_conn_remove_from_timeout_lists (c);
+#ifdef mhd_DEBUG_SUSPEND_RESUME
+    fprintf (stderr,
+             "%%%%%%          Suspended connection, FD: %llu\n",
+             (unsigned long long) c->sk.fd);
+#endif /* mhd_DEBUG_SUSPEND_RESUME */
     return true;
   }