SHUTDOWN
[oweals/gnunet.git] / src / statistics / statistics_api.c
index 5bca6c786b67f38a59f68ceca31f70e9fe7f04ba..d44bc77d11c25ed310103a5acc6963cb62226851 100644 (file)
@@ -738,7 +738,12 @@ GNUNET_STATISTICS_create (const char *subsystem,
   ret->cfg = cfg;
   ret->subsystem = GNUNET_strdup (subsystem);
   ret->backoff = GNUNET_TIME_UNIT_MILLISECONDS;
-  try_connect (ret);
+  if (GNUNET_YES != try_connect (ret))
+    {
+      GNUNET_free (ret->subsystem);
+      GNUNET_free (ret);
+      return NULL;
+    }
   return ret;
 }
 
@@ -761,6 +766,7 @@ GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h,
   struct GNUNET_TIME_Relative timeout;
   int i;
 
+  if (h == NULL) return;
   if (GNUNET_SCHEDULER_NO_TASK != h->backoff_task)
     GNUNET_SCHEDULER_cancel (h->backoff_task);
   if (sync_first)
@@ -913,6 +919,7 @@ schedule_action (struct GNUNET_STATISTICS_Handle *h)
     }
 }
 
+
 /**
  * Get statistic from the peer.
  *
@@ -1020,6 +1027,8 @@ GNUNET_STATISTICS_watch (struct GNUNET_STATISTICS_Handle *handle,
 {
   struct GNUNET_STATISTICS_WatchEntry *w;
 
+  if (handle == NULL) 
+    return GNUNET_SYSERR;
   w = GNUNET_malloc (sizeof (struct GNUNET_STATISTICS_WatchEntry));
   w->subsystem = GNUNET_strdup (subsystem);
   w->name = GNUNET_strdup (name);