Reduced duplication
authorBart Polot <bart@net.in.tum.de>
Fri, 4 Nov 2011 20:34:14 +0000 (20:34 +0000)
committerBart Polot <bart@net.in.tum.de>
Fri, 4 Nov 2011 20:34:14 +0000 (20:34 +0000)
src/testing/testing.c

index 6edc1fc8c7010eae6232005b76f5d2f2f0a458c2..b778b7d036d8ed4cd60cfc75c2949f64802aa2eb 100644 (file)
@@ -1830,18 +1830,6 @@ notify_connect_result (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     ctx->hello_send_task = GNUNET_SCHEDULER_NO_TASK;
   }
 
-  if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
-  {
-    if (ctx->d1th != NULL)
-      GNUNET_TRANSPORT_disconnect (ctx->d1th);
-    ctx->d1th = NULL;
-    if (ctx->d1core != NULL)
-      GNUNET_CORE_disconnect (ctx->d1core);
-    ctx->d1core = NULL;
-    GNUNET_free (ctx);
-    return;
-  }
-
   if (ctx->d1th != NULL)
     GNUNET_TRANSPORT_disconnect (ctx->d1th);
   ctx->d1th = NULL;
@@ -1849,6 +1837,12 @@ notify_connect_result (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     GNUNET_CORE_disconnect (ctx->d1core);
   ctx->d1core = NULL;
 
+  if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
+  {
+    GNUNET_free (ctx);
+    return;
+  }
+
   if (ctx->connected == GNUNET_YES)
   {
     if (ctx->cb != NULL)