- remove name if no rec is left
authorMatthias Wachs <wachs@net.in.tum.de>
Wed, 21 Mar 2012 17:22:21 +0000 (17:22 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Wed, 21 Mar 2012 17:22:21 +0000 (17:22 +0000)
src/namestore/gnunet-service-namestore.c

index 5647dd3115079ad1b83215b981267a062e4039a5..493d1f57446dad55d1b82353e8d86fd54c55f2e1 100644 (file)
@@ -985,6 +985,7 @@ struct RemoveRecordContext
 {
   struct GNUNET_NAMESTORE_RecordData *rd;
   struct GNUNET_CRYPTO_RsaPrivateKey *pkey;
+  int remove_name;
   uint16_t op_res;
 };
 
@@ -1046,6 +1047,26 @@ handle_record_remove_it (void *cls,
     return;
   }
 
+  if (rd_count-1 == 0)
+  {
+    struct GNUNET_CRYPTO_ShortHashCode pubkey_hash;
+    GNUNET_CRYPTO_short_hash (zone_key, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &pubkey_hash);
+    res = GSN_database->remove_records (GSN_database->cls,
+                                        &pubkey_hash,
+                                        name);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "No records left for name `%s', removing name\n",
+                name, res);
+    if (GNUNET_OK != res)
+    {
+      /* Could put records into database */
+      rrc->op_res = 4;
+      return;
+    }
+    rrc->op_res = 0;
+    return;
+  }
+
   rd_count_new = rd_count -1;
   struct GNUNET_NAMESTORE_RecordData rd_new[rd_count_new];