aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-03-20 13:26:00 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-03-20 13:26:00 +0000
commitd13c9621a9c369a65a1aa1263dfe6bca56b48ede (patch)
tree3deb3ba92f0313f6a0a6644d2a142be3e201c543 /src
parent7c15ab5a54637eae041c3a42b88071395ff983bd (diff)
downloadgnunet-d13c9621a9c369a65a1aa1263dfe6bca56b48ede.tar.gz
gnunet-d13c9621a9c369a65a1aa1263dfe6bca56b48ede.zip
- fixed record update for unique records
Diffstat (limited to 'src')
-rw-r--r--src/namestore/gnunet-service-namestore.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c
index 519814e77..6efe1d475 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -732,11 +732,23 @@ handle_create_record_it (void *cls,
732 int rd_count_new = 0; 732 int rd_count_new = 0;
733 733
734 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found %u existing records for `%s'\n", rd_count, crc->name); 734 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found %u existing records for `%s'\n", rd_count, crc->name);
735
736 for (c = 0; c < rd_count; c++) 735 for (c = 0; c < rd_count; c++)
737 { 736 {
738 737 if ((crc->rd->record_type == GNUNET_NAMESTORE_TYPE_PKEY) && (rd[c].record_type == GNUNET_NAMESTORE_TYPE_PKEY))
739 if ((crc->rd->record_type == rd[c].record_type) && 738 {
739 /* Update unique PKEY */
740 exist = c;
741 update = GNUNET_YES;
742 break;
743 }
744 else if ((crc->rd->record_type == GNUNET_NAMESTORE_TYPE_PSEU) && (rd[c].record_type == GNUNET_NAMESTORE_TYPE_PSEU))
745 {
746 /* Update unique PSEU */
747 exist = c;
748 update = GNUNET_YES;
749 break;
750 }
751 else if ((crc->rd->record_type == rd[c].record_type) &&
740 (crc->rd->data_size == rd[c].data_size) && 752 (crc->rd->data_size == rd[c].data_size) &&
741 (0 == memcmp (crc->rd->data, rd[c].data, rd[c].data_size))) 753 (0 == memcmp (crc->rd->data, rd[c].data, rd[c].data_size)))
742 { 754 {
@@ -773,7 +785,7 @@ handle_create_record_it (void *cls,
773 memcpy (rd_new, rd, rd_count * sizeof (struct GNUNET_NAMESTORE_RecordData)); 785 memcpy (rd_new, rd, rd_count * sizeof (struct GNUNET_NAMESTORE_RecordData));
774 rd_count_new = rd_count; 786 rd_count_new = rd_count;
775 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating expiration from %llu to %llu!\n", rd_new[exist].expiration.abs_value, crc->rd->expiration.abs_value); 787 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating expiration from %llu to %llu!\n", rd_new[exist].expiration.abs_value, crc->rd->expiration.abs_value);
776 rd_new[exist].expiration = crc->rd->expiration; 788 rd_new[exist] = *(crc->rd);
777 } 789 }
778 790
779 block_expiration = GNUNET_TIME_absolute_max(crc->expire, expire); 791 block_expiration = GNUNET_TIME_absolute_max(crc->expire, expire);
@@ -808,14 +820,19 @@ end:
808 case GNUNET_YES: 820 case GNUNET_YES:
809 /* database operations OK */ 821 /* database operations OK */
810 if (GNUNET_YES == update) 822 if (GNUNET_YES == update)
823 {
811 /* we updated an existing record */ 824 /* we updated an existing record */
812 crc->res = GNUNET_NO; 825 crc->res = GNUNET_NO;
826 }
813 else 827 else
828 {
814 /* we created a new record */ 829 /* we created a new record */
815 crc->res = GNUNET_YES; 830 crc->res = GNUNET_YES;
831 }
816 break; 832 break;
817 case GNUNET_NO: 833 case GNUNET_NO:
818 /* identical entry existed, so we did nothing */ 834 /* identical entry existed, so we did nothing */
835 GNUNET_break(0);
819 crc->res = GNUNET_NO; 836 crc->res = GNUNET_NO;
820 break; 837 break;
821 default: 838 default:
@@ -911,7 +928,6 @@ static void handle_record_create (void *cls,
911 GNUNET_break_op (0); 928 GNUNET_break_op (0);
912 goto send; 929 goto send;
913 } 930 }
914
915 /* Extracting and converting private key */ 931 /* Extracting and converting private key */
916 pkey = GNUNET_CRYPTO_rsa_decode_key((char *) pkey_tmp, key_len); 932 pkey = GNUNET_CRYPTO_rsa_decode_key((char *) pkey_tmp, key_len);
917 GNUNET_assert (pkey != NULL); 933 GNUNET_assert (pkey != NULL);