gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r15204 - gnunet/src/util


From: gnunet
Subject: [GNUnet-SVN] r15204 - gnunet/src/util
Date: Wed, 11 May 2011 15:49:16 +0200

Author: grothoff
Date: 2011-05-11 15:49:16 +0200 (Wed, 11 May 2011)
New Revision: 15204

Modified:
   gnunet/src/util/server.c
Log:
more comprehensive error reporting

Modified: gnunet/src/util/server.c
===================================================================
--- gnunet/src/util/server.c    2011-05-11 13:49:15 UTC (rev 15203)
+++ gnunet/src/util/server.c    2011-05-11 13:49:16 UTC (rev 15204)
@@ -169,6 +169,16 @@
   GNUNET_SCHEDULER_TaskIdentifier restart_task;
 
   /**
+   * Task that warns about missing calls to 'GNUNET_SERVER_receive_done'.
+   */
+  GNUNET_SCHEDULER_TaskIdentifier warn_task;
+
+  /**
+   * Time when the warn task was started.
+   */
+  struct GNUNET_TIME_Absolute warn_start;
+
+  /**
    * Last activity on this socket (used to time it out
    * if reference_count == 0).
    */
@@ -216,6 +226,11 @@
    * be used in special cases!
    */
   int persist;
+  
+  /**
+   * Type of last message processed (for warn_no_receive_done).
+   */
+  uint16_t warn_type;
 };
 
 
@@ -557,6 +572,29 @@
 
 
 /**
+ * Task run to warn about missing calls to 'GNUNET_SERVER_receive_done'.
+ *
+ * @param cls our 'struct GNUNET_SERVER_Client*' to process more requests from
+ * @param tc scheduler context (unused)
+ */
+static void
+warn_no_receive_done (void *cls, 
+                     const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  struct GNUNET_SERVER_Client *client = cls;
+
+  client->warn_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+                                                   &warn_no_receive_done,
+                                                   client);
+  if (0 == (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason))
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+               _("Processing code for message of type %u did not call 
GNUNET_SERVER_receive_done after %llums\n"),
+               (unsigned int) client->warn_type,
+               (unsigned long long) GNUNET_TIME_absolute_get_duration 
(client->warn_start).rel_value);
+}
+
+
+/**
  * Inject a message into the server, pretend it came
  * from the specified client.  Delivery of the message
  * will happen instantly (if a handler is installed;
@@ -614,7 +652,17 @@
                   return GNUNET_SYSERR;
                 }
               if (sender != NULL)
-                sender->suspended++;
+               {
+                 if (0 == sender->suspended)
+                   {
+                     sender->warn_start = GNUNET_TIME_absolute_get ();
+                     sender->warn_task = GNUNET_SCHEDULER_add_delayed 
(GNUNET_TIME_UNIT_SECONDS,
+                                                                       
&warn_no_receive_done,
+                                                                       sender);
+                     sender->warn_type = type;
+                   }
+                 sender->suspended++;
+               }
               mh->callback (mh->callback_cls, sender, message);
               found = GNUNET_YES;
             }
@@ -1012,6 +1060,11 @@
       GNUNET_SCHEDULER_cancel (client->restart_task);
       client->restart_task = GNUNET_SCHEDULER_NO_TASK;
     }
+  if (client->warn_task != GNUNET_SCHEDULER_NO_TASK)
+    {
+      GNUNET_SCHEDULER_cancel (client->warn_task);
+      client->warn_task = GNUNET_SCHEDULER_NO_TASK;
+    }
   if (GNUNET_YES == client->receive_pending)
     {
       GNUNET_CONNECTION_receive_cancel (client->connection);
@@ -1041,6 +1094,11 @@
          GNUNET_SCHEDULER_cancel (client->restart_task);
          client->restart_task = GNUNET_SCHEDULER_NO_TASK;
        }
+      if (client->warn_task != GNUNET_SCHEDULER_NO_TASK)
+       {
+         GNUNET_SCHEDULER_cancel (client->warn_task);
+         client->warn_task = GNUNET_SCHEDULER_NO_TASK;
+       }
       n = server->disconnect_notify_list;
       while (n != NULL)
         {
@@ -1148,6 +1206,11 @@
 #endif
       return;
     }
+  if (GNUNET_SCHEDULER_NO_TASK != client->warn_task)
+    {
+      GNUNET_SCHEDULER_cancel (client->warn_task);
+      client->warn_task = GNUNET_SCHEDULER_NO_TASK;
+    }
   if (client->in_process_client_buffer == GNUNET_YES)
     {
 #if DEBUG_SERVER




reply via email to

[Prev in Thread] Current Thread [Next in Thread]