gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r8285 - GNUnet/src/applications/tbench


From: gnunet
Subject: [GNUnet-SVN] r8285 - GNUnet/src/applications/tbench
Date: Fri, 20 Feb 2009 18:51:13 -0700

Author: grothoff
Date: 2009-02-20 18:51:13 -0700 (Fri, 20 Feb 2009)
New Revision: 8285

Modified:
   GNUnet/src/applications/tbench/tbench.c
Log:
better shutdown support

Modified: GNUnet/src/applications/tbench/tbench.c
===================================================================
--- GNUnet/src/applications/tbench/tbench.c     2009-02-21 00:21:52 UTC (rev 
8284)
+++ GNUnet/src/applications/tbench/tbench.c     2009-02-21 01:51:13 UTC (rev 
8285)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2001, 2002, 2004, 2005, 2006 Christian Grothoff (and other 
contributing authors)
+     (C) 2001, 2002, 2004, 2005, 2006, 2009 Christian Grothoff (and other 
contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -28,7 +28,7 @@
 #include "gnunet_protocols.h"
 #include "tbench.h"
 
-#define DEBUG_TBENCH GNUNET_NO
+#define DEBUG_TBENCH GNUNET_YES
 
 typedef struct
 {
@@ -60,6 +60,8 @@
 
 static struct GNUNET_Semaphore *postsem;
 
+static struct GNUNET_CronManager * cron;
+
 /**
  * What is the current iteration counter? (Used to verify
  * that replies match the current request series).
@@ -277,6 +279,13 @@
 
   for (iteration = 0; iteration < iterations; iteration++)
     {
+      if (GNUNET_YES == GNUNET_shutdown_test())
+       {
+         GNUNET_free (p2p);
+         GNUNET_free (results);
+         GNUNET_mutex_unlock (lock);
+         return GNUNET_SYSERR;
+       }
       results[iteration].maxPacketNumber = msgCnt;
       results[iteration].packetsReceived = GNUNET_malloc (msgCnt);
       memset (results[iteration].packetsReceived, 0, msgCnt);
@@ -300,12 +309,18 @@
       endTime = startTime + GNUNET_ntohll (msg->timeOut);
 
       timeoutOccured = GNUNET_NO;
-      GNUNET_cron_add_job (coreAPI->cron,
+      GNUNET_cron_add_job (cron,
                            &semaUp,
                            GNUNET_ntohll (msg->timeOut) *
                            GNUNET_CRON_MILLISECONDS, 0, postsem);
       for (packetNum = 0; packetNum < msgCnt; packetNum++)
         {
+         if (GNUNET_YES == GNUNET_shutdown_test())
+           {
+             GNUNET_free(p2p);
+             GNUNET_free (results);
+             return GNUNET_SYSERR;
+           }
           now = GNUNET_get_time ();
           p2p->packetNum = htonl (packetNum);
 #if DEBUG_TBENCH
@@ -412,7 +427,8 @@
       capi->cs_handler_register (GNUNET_CS_PROTO_TBENCH_REQUEST,
                                  &csHandleTBenchRequest))
     ok = GNUNET_SYSERR;
-
+  cron = GNUNET_cron_create(capi->ectx);
+  GNUNET_cron_start(cron);
   GNUNET_GE_ASSERT (capi->ectx,
                     0 == GNUNET_GC_set_configuration_value_string (capi->cfg,
                                                                    capi->ectx,
@@ -434,6 +450,9 @@
   coreAPI->cs_handler_unregister (GNUNET_CS_PROTO_TBENCH_REQUEST,
                                   &csHandleTBenchRequest);
   GNUNET_mutex_destroy (lock);
+  GNUNET_cron_stop(cron);
+  GNUNET_cron_destroy (cron);
+  cron = NULL;
   lock = NULL;
   coreAPI = NULL;
 }





reply via email to

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