fix misc namestore crashes from pq migration
authorChristian Grothoff <christian@grothoff.org>
Fri, 23 Jun 2017 14:05:07 +0000 (16:05 +0200)
committerChristian Grothoff <christian@grothoff.org>
Fri, 23 Jun 2017 14:05:07 +0000 (16:05 +0200)
src/namestore/gnunet-service-namestore.c
src/namestore/namestore_api.c
src/namestore/plugin_namestore_postgres.c
src/zonemaster/gnunet-service-zonemaster.c

index 6cb4290a04b020a3cdf70e7e3b92f983021245a4..b27cfb732a7794a36a730b2bed3703852a7e5a9f 100644 (file)
@@ -414,9 +414,12 @@ get_nick_record (const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone)
   struct GNUNET_GNSRECORD_Data *nick;
   int res;
 
-  res = GSN_database->lookup_records (GSN_database->cls, zone,
+  nick = NULL;
+  res = GSN_database->lookup_records (GSN_database->cls,
+                                     zone,
                                       GNUNET_GNS_MASTERZONE_STR,
-                                      &lookup_nick_it, &nick);
+                                      &lookup_nick_it,
+                                     &nick);
   if ( (GNUNET_OK != res) ||
        (NULL == nick) )
   {
index 933ba7b950d808506f4483d3d6d108f910b73385..92068cc01f2528e461ef057d2553dbc3fef8d6c4 100644 (file)
@@ -1303,11 +1303,14 @@ GNUNET_NAMESTORE_zone_iteration_stop (struct GNUNET_NAMESTORE_ZoneIterator *it)
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Sending ZONE_ITERATION_STOP message\n");
-  env = GNUNET_MQ_msg (msg,
-                       GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP);
-  msg->gns_header.r_id = htonl (it->op_id);
-  GNUNET_MQ_send (h->mq,
-                  env);
+  if (NULL != h->mq)
+  {
+    env = GNUNET_MQ_msg (msg,
+                        GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP);
+    msg->gns_header.r_id = htonl (it->op_id);
+    GNUNET_MQ_send (h->mq,
+                   env);
+  }
   free_ze (it);
 }
 
index c2ea3d0a643488f2704b2b83e207d6830ced1fa6..491cec1cb569f63f1b8591417fbb823f35868ac2 100644 (file)
@@ -229,7 +229,7 @@ namestore_postgres_store_records (void *cls,
     res = GNUNET_PQ_eval_prepared_non_select (plugin->dbh,
                                               "store_records",
                                               params);
-    if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != res)
+    if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != res)
       return GNUNET_SYSERR;
   }
   return GNUNET_OK;
@@ -372,7 +372,7 @@ namestore_postgres_lookup_records (void *cls,
                                               params,
                                               &parse_result_call_iterator,
                                               &pc);
-  if (res < 0)
+  if (res <= 0)
     return GNUNET_SYSERR;
   return GNUNET_OK;
 }
index 08a09de34354167e3632e7be9cca166764b6a8bd..b3a2cb8b3965d3311093a88e6777dadfaa63f08d 100644 (file)
@@ -648,7 +648,8 @@ handle_monitor_event (void *cls,
 static void
 monitor_sync_event (void *cls)
 {
-  GNUNET_assert (NULL == zone_publish_task);
+  if ( (NULL == zone_publish_task) &&
+       (NULL == namestore_iter) )
   zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_start,
                                                 NULL);
 }