gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r29199 - gnunet/src/namestore


From: gnunet
Subject: [GNUnet-SVN] r29199 - gnunet/src/namestore
Date: Wed, 11 Sep 2013 14:22:57 +0200

Author: wachs
Date: 2013-09-11 14:22:57 +0200 (Wed, 11 Sep 2013)
New Revision: 29199

Modified:
   gnunet/src/namestore/gnunet-service-namestore.c
   gnunet/src/namestore/plugin_namestore_sqlite.c
Log:
- iterator NULL check
- do no empty name if it did not exist before


Modified: gnunet/src/namestore/gnunet-service-namestore.c
===================================================================
--- gnunet/src/namestore/gnunet-service-namestore.c     2013-09-11 12:20:03 UTC 
(rev 29198)
+++ gnunet/src/namestore/gnunet-service-namestore.c     2013-09-11 12:22:57 UTC 
(rev 29199)
@@ -613,16 +613,15 @@
     GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
     return;
   }
-  {
-    struct GNUNET_NAMESTORE_RecordData rd[rd_count];
+  struct GNUNET_NAMESTORE_RecordData rd[rd_count];
 
-    if (GNUNET_OK !=
-       GNUNET_NAMESTORE_records_deserialize (rd_ser_len, rd_ser, rd_count, rd))
-    {
-      GNUNET_break (0);
-      GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
-      return;
-    }
+       if (GNUNET_OK !=
+                       GNUNET_NAMESTORE_records_deserialize (rd_ser_len, 
rd_ser, rd_count, rd))
+       {
+               GNUNET_break (0);
+               GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+               return;
+       }
 
     /* Extracting and converting private key */
     GNUNET_CRYPTO_ecc_key_get_public (&rp_msg->private_key,
@@ -640,6 +639,14 @@
                (unsigned int) rd_count,
                conv_name,
                GNUNET_NAMESTORE_z2s (&pubkey));
+
+    if ((rd_count == 0) && (GNUNET_NO == GSN_database->iterate_records 
(GSN_database->cls, &rp_msg->private_key, 0, NULL, 0)))
+    {
+       /* This name does not exist, so cannot be removed */
+       res = GNUNET_NO;
+    }
+    else
+    {
     res = GSN_database->store_records (GSN_database->cls,
                                       &rp_msg->private_key,
                                       conv_name,                               
       
@@ -650,35 +657,34 @@
       struct GNUNET_NAMESTORE_Block *block;
 
       if (0 == rd_count)
-       block = GNUNET_NAMESTORE_block_create (&rp_msg->private_key,
+               block = GNUNET_NAMESTORE_block_create (&rp_msg->private_key,
                                               GNUNET_TIME_UNIT_ZERO_ABS,
                                               conv_name,
                                               rd, rd_count);
       else
-       block = GNUNET_NAMESTORE_block_create (&rp_msg->private_key,
+               block = GNUNET_NAMESTORE_block_create (&rp_msg->private_key,
                                               GNUNET_TIME_UNIT_FOREVER_ABS,
                                               conv_name,
                                               rd, rd_count);
       if (GNUNET_OK !=
-         GSN_database->cache_block (GSN_database->cls,
+               GSN_database->cache_block (GSN_database->cls,
                                     block))
       {
-       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                   _("Failed to cache encrypted block of my own zone!\n"));
-       res = GNUNET_SYSERR;
+       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                       _("Failed to cache encrypted block of my own zone!\n"));
+       res = GNUNET_SYSERR;
       }
       GNUNET_free (block);
       
       for (zm = monitor_head; NULL != zm; zm = zm->next)    
-       if (0 == memcmp (&rp_msg->private_key,
-                        &zm->zone, 
-                        sizeof (struct GNUNET_CRYPTO_EccPrivateKey)))
-         send_lookup_response (monitor_nc,
-                               zm->nc->client,
-                               zm->request_id,
-                               &rp_msg->private_key,
-                               conv_name,
-                               rd_count, rd);      
+               if (0 == memcmp (&rp_msg->private_key, &zm->zone,
+                               sizeof (struct GNUNET_CRYPTO_EccPrivateKey)))
+                       send_lookup_response (monitor_nc,
+                                                               zm->nc->client,
+                                                               zm->request_id,
+                                                               
&rp_msg->private_key,
+                                                               conv_name,
+                                                               rd_count, rd);
     }    
     GNUNET_free (conv_name);
   }

Modified: gnunet/src/namestore/plugin_namestore_sqlite.c
===================================================================
--- gnunet/src/namestore/plugin_namestore_sqlite.c      2013-09-11 12:20:03 UTC 
(rev 29198)
+++ gnunet/src/namestore/plugin_namestore_sqlite.c      2013-09-11 12:22:57 UTC 
(rev 29199)
@@ -751,8 +751,8 @@
       }
       else if (NULL != zone_key)
       {
-       iter (iter_cls, zone_key, label, 
-             record_count, rd);
+       if (NULL != iter)
+               iter (iter_cls, zone_key, label, record_count, rd);
        ret = GNUNET_YES;
       }
     }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]