diff options
Diffstat (limited to 'src/namestore/gnunet-service-namestore.c')
-rw-r--r-- | src/namestore/gnunet-service-namestore.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index 3f679cacd..5d43488a1 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c | |||
@@ -1407,6 +1407,20 @@ check_record_lookup (void *cls, const struct LabelLookupMessage *ll_msg) | |||
1407 | return GNUNET_OK; | 1407 | return GNUNET_OK; |
1408 | } | 1408 | } |
1409 | 1409 | ||
1410 | static void | ||
1411 | calculate_lock_hash (const char *label, | ||
1412 | const struct GNUNET_IDENTITY_PrivateKey *zone, | ||
1413 | struct GNUNET_HashCode *result) | ||
1414 | { | ||
1415 | struct GNUNET_HashContext *hctx; | ||
1416 | |||
1417 | hctx = GNUNET_CRYPTO_hash_context_start (); | ||
1418 | GNUNET_CRYPTO_hash_context_read (hctx, label, strlen (label)); | ||
1419 | GNUNET_CRYPTO_hash_context_read (hctx, zone, | ||
1420 | sizeof (*zone)); | ||
1421 | GNUNET_CRYPTO_hash_context_finish (hctx, result); | ||
1422 | } | ||
1423 | |||
1410 | 1424 | ||
1411 | /** | 1425 | /** |
1412 | * Handles a #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP message | 1426 | * Handles a #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP message |
@@ -1447,7 +1461,7 @@ handle_record_lookup (void *cls, const struct LabelLookupMessage *ll_msg) | |||
1447 | name_len = strlen (conv_name) + 1; | 1461 | name_len = strlen (conv_name) + 1; |
1448 | if (GNUNET_YES == ntohl (ll_msg->locking)) | 1462 | if (GNUNET_YES == ntohl (ll_msg->locking)) |
1449 | { | 1463 | { |
1450 | GNUNET_CRYPTO_hash (conv_name, strlen (conv_name), &label_hash); | 1464 | calculate_lock_hash (conv_name, &ll_msg->zone, &label_hash); |
1451 | for (lock = locks_head; NULL != lock; lock = lock->next) | 1465 | for (lock = locks_head; NULL != lock; lock = lock->next) |
1452 | if (0 == memcmp (&label_hash, &lock->label_hash, sizeof (label_hash))) | 1466 | if (0 == memcmp (&label_hash, &lock->label_hash, sizeof (label_hash))) |
1453 | break; | 1467 | break; |
@@ -1482,9 +1496,9 @@ handle_record_lookup (void *cls, const struct LabelLookupMessage *ll_msg) | |||
1482 | { | 1496 | { |
1483 | lock = GNUNET_new (struct RecordsLock); | 1497 | lock = GNUNET_new (struct RecordsLock); |
1484 | lock->client = nc; | 1498 | lock->client = nc; |
1485 | GNUNET_CRYPTO_hash (conv_name, | 1499 | memcpy (&lock->label_hash, &label_hash, sizeof (label_hash)); |
1486 | strlen (conv_name), | 1500 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1487 | &lock->label_hash); | 1501 | "Locking %s\n", GNUNET_h2s (&label_hash)); |
1488 | GNUNET_CONTAINER_DLL_insert (locks_head, | 1502 | GNUNET_CONTAINER_DLL_insert (locks_head, |
1489 | locks_tail, | 1503 | locks_tail, |
1490 | lock); | 1504 | lock); |
@@ -1679,7 +1693,7 @@ handle_record_store (void *cls, const struct RecordStoreMessage *rp_msg) | |||
1679 | } | 1693 | } |
1680 | if (GNUNET_YES == ntohl (rp_msg->locking)) | 1694 | if (GNUNET_YES == ntohl (rp_msg->locking)) |
1681 | { | 1695 | { |
1682 | GNUNET_CRYPTO_hash (conv_name, strlen (conv_name), &label_hash); | 1696 | calculate_lock_hash (conv_name, &rp_msg->private_key, &label_hash); |
1683 | for (lock = locks_head; NULL != lock; lock = lock->next) | 1697 | for (lock = locks_head; NULL != lock; lock = lock->next) |
1684 | if (0 == memcmp (&label_hash, &lock->label_hash, sizeof (label_hash))) | 1698 | if (0 == memcmp (&label_hash, &lock->label_hash, sizeof (label_hash))) |
1685 | break; | 1699 | break; |