gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r21156 - gnunet/src/util
Date: Wed, 25 Apr 2012 16:45:39 +0200

Author: grothoff
Date: 2012-04-25 16:45:39 +0200 (Wed, 25 Apr 2012)
New Revision: 21156

Modified:
   gnunet/src/util/test_service.c
Log:
-handle timeout better

Modified: gnunet/src/util/test_service.c
===================================================================
--- gnunet/src/util/test_service.c      2012-04-25 14:42:53 UTC (rev 21155)
+++ gnunet/src/util/test_service.c      2012-04-25 14:45:39 UTC (rev 21156)
@@ -44,11 +44,31 @@
 static struct GNUNET_CLIENT_Connection *client;
 
 
+
+
+static void
+do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  GNUNET_CLIENT_disconnect (client);
+  client = NULL;
+  GNUNET_SERVICE_stop (sctx);
+  sctx = NULL;
+}
+
+
 static size_t
 build_msg (void *cls, size_t size, void *buf)
 {
   struct GNUNET_MessageHeader *msg = buf;
 
+  if (size < sizeof (struct GNUNET_MessageHeader))
+  {
+    /* timeout */
+    GNUNET_SCHEDULER_add_now (&do_stop, NULL);
+    ok = 1;
+    return 0;
+  }
+
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client connected, transmitting\n");
   GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader));
   msg->type = htons (MY_TYPE);
@@ -76,14 +96,6 @@
 
 
 static void
-do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
-  GNUNET_CLIENT_disconnect (client);
-  GNUNET_SERVICE_stop (sctx);
-}
-
-
-static void
 recv_cb (void *cls, struct GNUNET_SERVER_Client *sc,
          const struct GNUNET_MessageHeader *message)
 {




reply via email to

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