aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/namestore/gnunet-service-namestore.c147
1 files changed, 63 insertions, 84 deletions
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c
index 1c73e2408..2044010df 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -278,12 +278,6 @@ struct StoreActivity
278 const struct RecordStoreMessage *rsm; 278 const struct RecordStoreMessage *rsm;
279 279
280 /** 280 /**
281 * Array of record data to store (without NICK unless this is about
282 * #GNUNET_GNS_EMPTY_LABEL_AT). Length is in @e rd_count.
283 */
284 struct GNUNET_GNSRECORD_Data *rd;
285
286 /**
287 * Next zone monitor that still needs to be notified about this PUT. 281 * Next zone monitor that still needs to be notified about this PUT.
288 */ 282 */
289 struct ZoneMonitor *zm_pos; 283 struct ZoneMonitor *zm_pos;
@@ -293,11 +287,6 @@ struct StoreActivity
293 */ 287 */
294 char *conv_name; 288 char *conv_name;
295 289
296 /**
297 * How many records do we try to store?
298 */
299 unsigned int rd_count;
300
301}; 290};
302 291
303 292
@@ -436,9 +425,6 @@ free_store_activity (struct StoreActivity *sa)
436 GNUNET_CONTAINER_DLL_remove (sa_head, 425 GNUNET_CONTAINER_DLL_remove (sa_head,
437 sa_tail, 426 sa_tail,
438 sa); 427 sa);
439 GNUNET_array_grow (sa->rd,
440 sa->rd_count,
441 0);
442 GNUNET_free (sa->conv_name); 428 GNUNET_free (sa->conv_name);
443 GNUNET_free (sa); 429 GNUNET_free (sa);
444} 430}
@@ -903,72 +889,70 @@ static void
903continue_store_activity (struct StoreActivity *sa) 889continue_store_activity (struct StoreActivity *sa)
904{ 890{
905 const struct RecordStoreMessage *rp_msg = sa->rsm; 891 const struct RecordStoreMessage *rp_msg = sa->rsm;
892 unsigned int rd_count;
893 size_t name_len;
894 size_t rd_ser_len;
895 uint32_t rid;
896 const char *name_tmp;
897 const char *rd_ser;
906 898
907 for (struct ZoneMonitor *zm = sa->zm_pos; 899 rid = ntohl (rp_msg->gns_header.r_id);
908 NULL != zm; 900 name_len = ntohs (rp_msg->name_len);
909 zm = sa->zm_pos) 901 rd_count = ntohs (rp_msg->rd_count);
910 { 902 rd_ser_len = ntohs (rp_msg->rd_len);
911 if ( (0 != memcmp (&rp_msg->private_key, 903 name_tmp = (const char *) &rp_msg[1];
912 &zm->zone, 904 rd_ser = &name_tmp[name_len];
913 sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) &&
914 (0 != memcmp (&zm->zone,
915 &zero,
916 sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) )
917 sa->zm_pos = zm->next; /* not interesting to this monitor */
918 if (zm->limit == zm->iteration_cnt)
919 {
920 zm->sa_waiting = GNUNET_YES;
921 zm->sa_waiting_start = GNUNET_TIME_absolute_get ();
922 if (NULL != zm->sa_wait_warning)
923 GNUNET_SCHEDULER_cancel (zm->sa_wait_warning);
924 zm->sa_wait_warning = GNUNET_SCHEDULER_add_delayed (MONITOR_STALL_WARN_DELAY,
925 &warn_monitor_slow,
926 zm);
927 return; /* blocked on zone monitor */
928 }
929 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
930 "Notifying monitor about changes under label `%s'\n",
931 sa->conv_name);
932 zm->limit--;
933 send_lookup_response (zm->nc,
934 0,
935 &rp_msg->private_key,
936 sa->conv_name,
937 sa->rd_count,
938 sa->rd);
939 sa->zm_pos = zm->next;
940 }
941 /* great, done with the monitors, unpack (again) for refresh_block operation */
942 { 905 {
943 size_t name_len; 906 struct GNUNET_GNSRECORD_Data rd[GNUNET_NZL(rd_count)];
944 size_t rd_ser_len; 907
945 uint32_t rid; 908 /* We did this before, must succeed again */
946 const char *name_tmp; 909 GNUNET_assert (GNUNET_OK ==
947 const char *rd_ser; 910 GNUNET_GNSRECORD_records_deserialize (rd_ser_len,
948 unsigned int rd_count; 911 rd_ser,
949 912 rd_count,
950 rid = ntohl (rp_msg->gns_header.r_id); 913 rd));
951 name_len = ntohs (rp_msg->name_len); 914
952 rd_count = ntohs (rp_msg->rd_count); 915 for (struct ZoneMonitor *zm = sa->zm_pos;
953 rd_ser_len = ntohs (rp_msg->rd_len); 916 NULL != zm;
954 name_tmp = (const char *) &rp_msg[1]; 917 zm = sa->zm_pos)
955 rd_ser = &name_tmp[name_len];
956 { 918 {
957 struct GNUNET_GNSRECORD_Data rd[rd_count]; 919 if ( (0 != memcmp (&rp_msg->private_key,
958 920 &zm->zone,
959 /* We did this before, must succeed again */ 921 sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) &&
960 GNUNET_assert (GNUNET_OK == 922 (0 != memcmp (&zm->zone,
961 GNUNET_GNSRECORD_records_deserialize (rd_ser_len, 923 &zero,
962 rd_ser, 924 sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) )
963 rd_count, 925 sa->zm_pos = zm->next; /* not interesting to this monitor */
964 rd)); 926 if (zm->limit == zm->iteration_cnt)
965 refresh_block (sa->nc, 927 {
966 rid, 928 zm->sa_waiting = GNUNET_YES;
967 &rp_msg->private_key, 929 zm->sa_waiting_start = GNUNET_TIME_absolute_get ();
968 sa->conv_name, 930 if (NULL != zm->sa_wait_warning)
969 rd_count, 931 GNUNET_SCHEDULER_cancel (zm->sa_wait_warning);
970 rd); 932 zm->sa_wait_warning = GNUNET_SCHEDULER_add_delayed (MONITOR_STALL_WARN_DELAY,
933 &warn_monitor_slow,
934 zm);
935 return; /* blocked on zone monitor */
936 }
937 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
938 "Notifying monitor about changes under label `%s'\n",
939 sa->conv_name);
940 zm->limit--;
941 send_lookup_response (zm->nc,
942 0,
943 &rp_msg->private_key,
944 sa->conv_name,
945 rd_count,
946 rd);
947 sa->zm_pos = zm->next;
971 } 948 }
949 /* great, done with the monitors, unpack (again) for refresh_block operation */
950 refresh_block (sa->nc,
951 rid,
952 &rp_msg->private_key,
953 sa->conv_name,
954 rd_count,
955 rd);
972 } 956 }
973 GNUNET_SERVICE_client_continue (sa->nc->client); 957 GNUNET_SERVICE_client_continue (sa->nc->client);
974 free_store_activity (sa); 958 free_store_activity (sa);
@@ -1403,8 +1387,6 @@ handle_record_store (void *cls,
1403 rd_ser = &name_tmp[name_len]; 1387 rd_ser = &name_tmp[name_len];
1404 { 1388 {
1405 struct GNUNET_GNSRECORD_Data rd[GNUNET_NZL(rd_count)]; 1389 struct GNUNET_GNSRECORD_Data rd[GNUNET_NZL(rd_count)];
1406 struct GNUNET_GNSRECORD_Data rd_clean[GNUNET_NZL(rd_count)];
1407 unsigned int rd_clean_off;
1408 1390
1409 if (GNUNET_OK != 1391 if (GNUNET_OK !=
1410 GNUNET_GNSRECORD_records_deserialize (rd_ser_len, 1392 GNUNET_GNSRECORD_records_deserialize (rd_ser_len,
@@ -1453,6 +1435,9 @@ handle_record_store (void *cls,
1453 { 1435 {
1454 /* remove "NICK" records, unless this is for the 1436 /* remove "NICK" records, unless this is for the
1455 #GNUNET_GNS_EMPTY_LABEL_AT label */ 1437 #GNUNET_GNS_EMPTY_LABEL_AT label */
1438 struct GNUNET_GNSRECORD_Data rd_clean[GNUNET_NZL(rd_count)];
1439 unsigned int rd_clean_off;
1440
1456 rd_clean_off = 0; 1441 rd_clean_off = 0;
1457 for (unsigned int i=0;i<rd_count;i++) 1442 for (unsigned int i=0;i<rd_count;i++)
1458 { 1443 {
@@ -1492,12 +1477,6 @@ handle_record_store (void *cls,
1492 ntohs (rp_msg->gns_header.header.size)); 1477 ntohs (rp_msg->gns_header.header.size));
1493 sa->zm_pos = monitor_head; 1478 sa->zm_pos = monitor_head;
1494 sa->conv_name = conv_name; 1479 sa->conv_name = conv_name;
1495 GNUNET_array_grow (sa->rd,
1496 sa->rd_count,
1497 rd_clean_off);
1498 GNUNET_memcpy (sa->rd,
1499 rd_clean,
1500 sizeof (struct GNUNET_GNSRECORD_Data) * rd_clean_off);
1501 continue_store_activity (sa); 1480 continue_store_activity (sa);
1502 } 1481 }
1503} 1482}