summaryrefslogtreecommitdiff
path: root/src/namestore/gnunet-service-namestore.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-10-20 17:58:46 +0000
committerChristian Grothoff <christian@grothoff.org>2013-10-20 17:58:46 +0000
commitc1ff578c693e4e45125ead915dc515bb141883ec (patch)
treee4573d2a5cc18aca5bcf3942a3fc267ef13fbc28 /src/namestore/gnunet-service-namestore.c
parent379bca7ce074b828fc09f592fcae2e94945da6cd (diff)
downloadgnunet-c1ff578c693e4e45125ead915dc515bb141883ec.tar.gz
gnunet-c1ff578c693e4e45125ead915dc515bb141883ec.zip
-allow namestore to monitor ALL zones, and to optionally only monitor changes
Diffstat (limited to 'src/namestore/gnunet-service-namestore.c')
-rw-r--r--src/namestore/gnunet-service-namestore.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c
index 53a685c63..b0704d7bd 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -144,11 +144,6 @@ struct ZoneMonitor
144 struct GNUNET_CRYPTO_EcdsaPrivateKey zone; 144 struct GNUNET_CRYPTO_EcdsaPrivateKey zone;
145 145
146 /** 146 /**
147 * The operation id fot the zone iteration in the response for the client
148 */
149 uint32_t request_id;
150
151 /**
152 * Task active during initial iteration. 147 * Task active during initial iteration.
153 */ 148 */
154 GNUNET_SCHEDULER_TaskIdentifier task; 149 GNUNET_SCHEDULER_TaskIdentifier task;
@@ -679,17 +674,36 @@ handle_record_store (void *cls,
679 if (GNUNET_OK == res) 674 if (GNUNET_OK == res)
680 { 675 {
681 for (zm = monitor_head; NULL != zm; zm = zm->next) 676 for (zm = monitor_head; NULL != zm; zm = zm->next)
677 {
682 if ( (0 == memcmp (&rp_msg->private_key, &zm->zone, 678 if ( (0 == memcmp (&rp_msg->private_key, &zm->zone,
683 sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) || 679 sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) ||
684 (0 == memcmp (&zm->zone, 680 (0 == memcmp (&zm->zone,
685 &zero, 681 &zero,
686 sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) ) 682 sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) )
683 {
684 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
685 "Notifying monitor about changes under label `%s'\n",
686 conv_name);
687 send_lookup_response (monitor_nc, 687 send_lookup_response (monitor_nc,
688 zm->nc->client, 688 zm->nc->client,
689 zm->request_id, 689 0,
690 &rp_msg->private_key, 690 &rp_msg->private_key,
691 conv_name, 691 conv_name,
692 rd_count, rd); 692 rd_count, rd);
693 }
694 else
695 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
696 "Monitor is for another zone\n");
697 }
698 if (NULL == monitor_head)
699 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
700 "No monitors active\n");
701 }
702 else
703 {
704 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
705 "Error storing record: %d\n",
706 res);
693 } 707 }
694 } 708 }
695 if (GNUNET_OK == res) 709 if (GNUNET_OK == res)
@@ -1186,7 +1200,7 @@ monitor_iterate_cb (void *cls,
1186 } 1200 }
1187 send_lookup_response (monitor_nc, 1201 send_lookup_response (monitor_nc,
1188 zm->nc->client, 1202 zm->nc->client,
1189 zm->request_id, 1203 0,
1190 zone_key, 1204 zone_key,
1191 name, 1205 name,
1192 rd_count, 1206 rd_count,
@@ -1215,7 +1229,6 @@ handle_monitor_start (void *cls,
1215 "ZONE_MONITOR_START"); 1229 "ZONE_MONITOR_START");
1216 zis_msg = (const struct ZoneMonitorStartMessage *) message; 1230 zis_msg = (const struct ZoneMonitorStartMessage *) message;
1217 zm = GNUNET_new (struct ZoneMonitor); 1231 zm = GNUNET_new (struct ZoneMonitor);
1218 zm->request_id = ntohl (zis_msg->gns_header.r_id);
1219 zm->offset = 0; 1232 zm->offset = 0;
1220 zm->nc = client_lookup (client); 1233 zm->nc = client_lookup (client);
1221 zm->zone = zis_msg->zone; 1234 zm->zone = zis_msg->zone;
@@ -1224,7 +1237,10 @@ handle_monitor_start (void *cls,
1224 GNUNET_SERVER_disable_receive_done_warning (client); 1237 GNUNET_SERVER_disable_receive_done_warning (client);
1225 GNUNET_SERVER_notification_context_add (monitor_nc, 1238 GNUNET_SERVER_notification_context_add (monitor_nc,
1226 client); 1239 client);
1227 zm->task = GNUNET_SCHEDULER_add_now (&monitor_next, zm); 1240 if (GNUNET_YES == ntohs (zis_msg->iterate_first))
1241 zm->task = GNUNET_SCHEDULER_add_now (&monitor_next, zm);
1242 else
1243 monitor_sync (zm);
1228} 1244}
1229 1245
1230 1246