aboutsummaryrefslogtreecommitdiff
path: root/src/namestore
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-07-03 19:15:15 +0000
committerChristian Grothoff <christian@grothoff.org>2012-07-03 19:15:15 +0000
commitb2bf074b07c7c18795e4b2fabb7cb9780960ab1c (patch)
treec4287e4f093e68bd621b21fbe26f92a4de9c259e /src/namestore
parent07ae13323403cc6646dbdde0be3f41a676d626f8 (diff)
downloadgnunet-b2bf074b07c7c18795e4b2fabb7cb9780960ab1c.tar.gz
gnunet-b2bf074b07c7c18795e4b2fabb7cb9780960ab1c.zip
-fix gns record deletion
Diffstat (limited to 'src/namestore')
-rw-r--r--src/namestore/gnunet-service-namestore.c29
-rw-r--r--src/namestore/namestore_common.c4
2 files changed, 21 insertions, 12 deletions
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c
index 95ee989d1..7609c73a3 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -1280,15 +1280,13 @@ handle_record_remove_it (void *cls,
1280 rrc->op_res = RECORD_REMOVE_RESULT_NO_RECORDS; 1280 rrc->op_res = RECORD_REMOVE_RESULT_NO_RECORDS;
1281 return; 1281 return;
1282 } 1282 }
1283
1284 /* Find record to remove */ 1283 /* Find record to remove */
1285 found = -1; 1284 found = -1;
1286 for (c = 0; c < rd_count; c++) 1285 for (c = 0; c < rd_count; c++)
1287 { 1286 {
1288 if ( (rd[c].flags != rrc->rd->flags) || 1287 if (GNUNET_YES !=
1289 (rd[c].record_type != rrc->rd->record_type) || 1288 GNUNET_NAMESTORE_records_cmp (&rd[c],
1290 (rd[c].data_size != rrc->rd->data_size) || 1289 rrc->rd))
1291 (0 != memcmp (rd[c].data, rrc->rd->data, rrc->rd->data_size)) )
1292 continue; 1290 continue;
1293 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found record to remove!\n", rd_count); 1291 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found record to remove!\n", rd_count);
1294 found = c; 1292 found = c;
@@ -1379,6 +1377,7 @@ handle_record_remove (void *cls,
1379 uint32_t rid; 1377 uint32_t rid;
1380 struct RemoveRecordContext rrc; 1378 struct RemoveRecordContext rrc;
1381 int res; 1379 int res;
1380 uint64_t off;
1382 1381
1383 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1382 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1384 "Received `%s' message\n", 1383 "Received `%s' message\n",
@@ -1465,18 +1464,28 @@ handle_record_remove (void *cls,
1465 "Removing record for name `%s' in zone `%s'\n", name_tmp, 1464 "Removing record for name `%s' in zone `%s'\n", name_tmp,
1466 GNUNET_short_h2s (&pubkey_hash)); 1465 GNUNET_short_h2s (&pubkey_hash));
1467 rrc.rd = &rd; 1466 rrc.rd = &rd;
1468 res = GSN_database->iterate_records (GSN_database->cls, 1467 rrc.op_res = RECORD_REMOVE_RESULT_RECORD_NOT_FOUND;
1469 &pubkey_hash, 1468 off = 0;
1470 name_tmp, 1469 res = GNUNET_OK;
1471 0, 1470 while ( (RECORD_REMOVE_RESULT_RECORD_NOT_FOUND == rrc.op_res) &&
1472 handle_record_remove_it, &rrc); 1471 (GNUNET_OK == res) )
1472 {
1473 res = GSN_database->iterate_records (GSN_database->cls,
1474 &pubkey_hash,
1475 name_tmp,
1476 off++,
1477 &handle_record_remove_it, &rrc);
1478 }
1473 switch (res) 1479 switch (res)
1474 { 1480 {
1475 case GNUNET_OK: 1481 case GNUNET_OK:
1476 res = rrc.op_res; 1482 res = rrc.op_res;
1477 break; 1483 break;
1478 case GNUNET_NO: 1484 case GNUNET_NO:
1485 GNUNET_break (RECORD_REMOVE_RESULT_NO_RECORDS == rrc.op_res);
1479 res = RECORD_REMOVE_RESULT_NO_RECORDS; 1486 res = RECORD_REMOVE_RESULT_NO_RECORDS;
1487 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1488 _("Failed to find record to remove\n"));
1480 break; 1489 break;
1481 case GNUNET_SYSERR: 1490 case GNUNET_SYSERR:
1482 res = RECORD_REMOVE_RESULT_FAILED_ACCESS_DATABASE; 1491 res = RECORD_REMOVE_RESULT_FAILED_ACCESS_DATABASE;
diff --git a/src/namestore/namestore_common.c b/src/namestore/namestore_common.c
index 8a2e15e2a..eead6e492 100644
--- a/src/namestore/namestore_common.c
+++ b/src/namestore/namestore_common.c
@@ -172,8 +172,8 @@ GNUNET_NAMESTORE_records_cmp (const struct GNUNET_NAMESTORE_RecordData *a,
172{ 172{
173 if ((a->record_type == b->record_type) && 173 if ((a->record_type == b->record_type) &&
174 (a->expiration_time == b->expiration_time) && 174 (a->expiration_time == b->expiration_time) &&
175 ((a->flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION) 175 ((a->flags & GNUNET_NAMESTORE_RF_RCMP_FLAGS)
176 == (b->flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION) ) && 176 == (b->flags & GNUNET_NAMESTORE_RF_RCMP_FLAGS) ) &&
177 (a->data_size == b->data_size) && 177 (a->data_size == b->data_size) &&
178 (0 == memcmp (a->data, b->data, a->data_size))) 178 (0 == memcmp (a->data, b->data, a->data_size)))
179 return GNUNET_YES; 179 return GNUNET_YES;