- simplify parameters
[oweals/gnunet.git] / src / datastore / datastore_api.c
index fcfc076d276b5694eead27c4cf7ba580e3e14f4a..fab3bf0ca1929cca3935973910c4052cd0d1f20e 100644 (file)
@@ -393,7 +393,7 @@ timeout_queue_entry (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
                             gettext_noop ("# queue entry timeouts"), 1,
                             GNUNET_NO);
   qe->task = GNUNET_SCHEDULER_NO_TASK;
-  GNUNET_assert (qe->was_transmitted == GNUNET_NO);
+  GNUNET_assert (GNUNET_NO == qe->was_transmitted);
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Timeout of request in datastore queue\n");
   qe->response_proc (qe->h, NULL);
 }
@@ -475,7 +475,7 @@ make_queue_entry (struct GNUNET_DATASTORE_Handle *h, size_t msize,
       GNUNET_assert (pos->response_proc != NULL);
       /* move 'pos' element to head so that it will be
        * killed on 'NULL' call below */
-      LOG (GNUNET_ERROR_TYPE_DEBUG, "Dropping request from datastore queue\n");
+      LOG (GNUNET_ERROR_TYPE_DEBUG, "Dropping request from datastore queue\n");     
       GNUNET_CONTAINER_DLL_remove (h->queue_head, h->queue_tail, pos);
       GNUNET_CONTAINER_DLL_insert (h->queue_head, h->queue_tail, pos);
       GNUNET_STATISTICS_update (h->stats,
@@ -512,12 +512,7 @@ try_reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct GNUNET_DATASTORE_Handle *h = cls;
 
-  if (h->retry_time.rel_value < GNUNET_CONSTANTS_SERVICE_RETRY.rel_value)
-    h->retry_time = GNUNET_CONSTANTS_SERVICE_RETRY;
-  else
-    h->retry_time = GNUNET_TIME_relative_multiply (h->retry_time, 2);
-  if (h->retry_time.rel_value > GNUNET_CONSTANTS_SERVICE_TIMEOUT.rel_value)
-    h->retry_time = GNUNET_CONSTANTS_SERVICE_TIMEOUT;
+  h->retry_time = GNUNET_TIME_STD_BACKOFF (h->retry_time);
   h->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
   h->client = GNUNET_CLIENT_connect ("datastore", h->cfg);
   if (h->client == NULL)
@@ -802,7 +797,7 @@ process_status_message (void *cls, const struct GNUNET_MessageHeader *msg)
   GNUNET_STATISTICS_update (h->stats,
                             gettext_noop ("# status messages received"), 1,
                             GNUNET_NO);
-  h->retry_time.rel_value = 0;
+  h->retry_time = GNUNET_TIME_UNIT_ZERO;
   process_queue (h);
   if (rc.cont != NULL)
     rc.cont (rc.cont_cls, status, 
@@ -1153,14 +1148,14 @@ process_result_message (void *cls, const struct GNUNET_MessageHeader *msg)
   const struct DataMessage *dm;
   int was_transmitted;
 
-  if (msg == NULL)
+  if (NULL == msg)
   {
     qe = h->queue_head;
     GNUNET_assert (NULL != qe);
     rc = qe->qc.rc;
     was_transmitted = qe->was_transmitted;
     free_queue_entry (qe);
-    if (was_transmitted == GNUNET_YES)
+    if (GNUNET_YES == was_transmitted)
     {
       LOG (GNUNET_ERROR_TYPE_WARNING,
            _("Failed to receive response from database.\n"));
@@ -1170,7 +1165,7 @@ process_result_message (void *cls, const struct GNUNET_MessageHeader *msg)
     {
       process_queue (h);
     }
-    if (rc.proc != NULL)
+    if (NULL != rc.proc)
       rc.proc (rc.proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS,
                0);
     return;
@@ -1184,7 +1179,7 @@ process_result_message (void *cls, const struct GNUNET_MessageHeader *msg)
     free_queue_entry (qe);
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Received end of result set, new queue size is %u\n", h->queue_size);
-    h->retry_time.rel_value = 0;
+    h->retry_time = GNUNET_TIME_UNIT_ZERO;
     h->result_count = 0;
     process_queue (h);
     if (rc.proc != NULL)
@@ -1231,7 +1226,7 @@ process_result_message (void *cls, const struct GNUNET_MessageHeader *msg)
        (unsigned long long) GNUNET_ntohll (dm->uid), ntohl (dm->type),
        ntohl (dm->size), GNUNET_h2s (&dm->key));
   free_queue_entry (qe);
-  h->retry_time.rel_value = 0;
+  h->retry_time = GNUNET_TIME_UNIT_ZERO;
   process_queue (h);
   if (rc.proc != NULL)
     rc.proc (rc.proc_cls, &dm->key, ntohl (dm->size), &dm[1], ntohl (dm->type),