GNUnet debian-0.24.3-29-g453fda2cf
 
Loading...
Searching...
No Matches
gnunet-service-zonemaster.c File Reference

publish records from namestore to GNUnet name system More...

#include "platform.h"
#include <pthread.h>
#include "gnunet_util_lib.h"
#include "gnunet_dht_service.h"
#include "gnunet_namestore_service.h"
#include "gnunet_namecache_service.h"
#include "gnunet_statistics_service.h"
Include dependency graph for gnunet-service-zonemaster.c:

Go to the source code of this file.

Data Structures

struct  RecordPublicationJob
 
struct  CacheOperation
 Pending operation on the namecache. More...
 

Macros

#define LOG_STRERROR_FILE(kind, syscall, filename)
 
#define PUBLISH_OPS_PER_EXPIRATION   4
 How often should we (re)publish each record before it expires?
 
#define DELTA_INTERVAL   100
 How often do we measure the delta between desired zone iteration speed and actual speed, and tell statistics service about it?
 
#define NS_BLOCK_SIZE   1000
 How many records do we fetch in one shot from the namestore?
 
#define JOB_QUEUE_LIMIT   5000
 How many open jobs (and with it maximum amount of pending DHT operations) do we allow at most.
 
#define NAMESTORE_MONITOR_QUEUE_LIMIT   5
 How many events may the namestore give us before it has to wait for us to keep up?
 
#define INITIAL_ZONE_ITERATION_INTERVAL   GNUNET_TIME_UNIT_MILLISECONDS
 The initial interval in milliseconds btween puts in a zone iteration.
 
#define MAXIMUM_ZONE_ITERATION_INTERVAL
 The upper bound for the zone iteration interval (per record).
 
#define LATE_ITERATION_SPEEDUP_FACTOR   2
 The factor the current zone iteration interval is divided by for each additional new record.
 
#define DHT_GNS_REPLICATION_LEVEL   5
 What replication level do we use for DHT PUT operations?
 

Functions

static void free_job (struct RecordPublicationJob *job)
 
static void shutdown_task (void *cls)
 Task run during shutdown.
 
static void finish_cache_operation (void *cls, int32_t success, const char *emsg)
 Cache operation complete, clean up.
 
static void refresh_block (const struct GNUNET_GNSRECORD_Block *block)
 Refresh the (encrypted) block in the namecache.
 
static void publish_zone_namestore_next (void *cls)
 Method called periodically that triggers iteration over authoritative records.
 
static void publish_zone_dht_start (void *cls)
 Periodically iterate over our zone and store everything in dht.
 
static void calculate_put_interval ()
 Calculate target_iteration_velocity_per_record.
 
static void update_velocity (unsigned int cnt)
 Re-calculate our velocity and the desired velocity.
 
static void check_zone_namestore_next ()
 Check if the current zone iteration needs to be continued by calling publish_zone_namestore_next(), and if so with what delay.
 
static void cleanup_job (struct RecordPublicationJob *job)
 
static void dht_put_continuation (void *cls)
 Continuation called from DHT once the PUT operation is done.
 
static void dispatch_job (const struct GNUNET_CRYPTO_PrivateKey *key, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count, const struct GNUNET_TIME_Absolute expire)
 Store GNS records in the DHT.
 
static void notification_pipe_cb (void *cls)
 
static void initiate_put_from_pipe_trigger (void *cls)
 
static void zone_iteration_error (void *cls)
 We encountered an error in our zone iteration.
 
static void zone_iteration_finished (void *cls)
 Zone iteration is completed.
 
static void handle_record (void *cls, const struct GNUNET_CRYPTO_PrivateKey *key, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, struct GNUNET_TIME_Absolute expire)
 Function used to put all records successively into the DHT.
 
static void dispatch_job_monitor (const struct GNUNET_CRYPTO_PrivateKey *key, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count, struct GNUNET_TIME_Absolute expire)
 Store GNS records in the DHT.
 
static void handle_monitor_event (void *cls, const struct GNUNET_CRYPTO_PrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, struct GNUNET_TIME_Absolute expire)
 Process a record that was stored in the namestore (invoked by the monitor).
 
static void handle_monitor_error (void *cls)
 The zone monitor encountered an IPC error trying to to get in sync.
 
static void * sign_worker (void *cls)
 
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service)
 Perform zonemaster duties: watch namestore, publish records.
 
 GNUNET_SERVICE_MAIN (GNUNET_OS_project_data_gnunet(), "zonemaster", GNUNET_SERVICE_OPTION_NONE, &run, NULL, NULL, NULL, GNUNET_MQ_handler_end())
 Define "main" method using service macro.
 

Variables

static pthread_t * worker
 Our workers.
 
static pthread_mutex_t sign_jobs_lock
 Lock for the sign jobs queue.
 
static pthread_mutex_t sign_results_lock
 Lock for the DHT put jobs queue.
 
static pthread_cond_t sign_jobs_cond
 Wait condition on new sign jobs.
 
static int in_shutdown = GNUNET_NO
 For threads to know we are shutting down.
 
static int monitor_halted = GNUNET_NO
 Monitor halted?
 
static struct GNUNET_DISK_PipeHandlenotification_pipe
 Our notification pipe.
 
static struct GNUNET_SCHEDULER_Taskpipe_read_task
 Pipe read task.
 
static struct RecordPublicationJobsign_jobs_head
 The DLL for workers to retrieve open jobs that require signing of blocks.
 
static struct RecordPublicationJobsign_jobs_tail
 See above.
 
static struct RecordPublicationJobsign_results_head
 The DLL for workers to place jobs that are signed.
 
static struct RecordPublicationJobsign_results_tail
 See above.
 
static struct RecordPublicationJobdht_jobs_head
 The DLL for jobs currently in the process of being dispatched into the DHT.
 
static struct RecordPublicationJobdht_jobs_tail
 See above.
 
static struct GNUNET_STATISTICS_Handlestatistics
 Handle to the statistics service.
 
static struct GNUNET_DHT_Handledht_handle
 Our handle to the DHT.
 
static struct GNUNET_NAMESTORE_Handlenamestore_handle
 Our handle to the namestore service.
 
static struct GNUNET_NAMESTORE_ZoneMonitorzmon
 Handle to monitor namestore changes to instant propagation.
 
static struct GNUNET_NAMECACHE_Handlenamecache
 Our handle to the namecache service.
 
static int disable_namecache
 Use the namecache? Doing so creates additional cryptographic operations whenever we touch a record.
 
static struct GNUNET_NAMESTORE_ZoneIteratornamestore_iter
 Handle to iterate over our authoritative zone in namestore.
 
static unsigned int job_queue_length
 Number of entries in the job queue #jobs_head.
 
static unsigned long long num_public_records
 Useful for zone update for DHT put.
 
static unsigned long long last_num_public_records
 Last seen record count.
 
static unsigned long long put_cnt
 Number of successful put operations performed in the current measurement cycle (as measured in check_zone_namestore_next()).
 
static struct GNUNET_TIME_Relative target_iteration_velocity_per_record
 What is the frequency at which we currently would like to perform DHT puts (per record)? Calculated in update_velocity() from the zone_publish_time_window() and the total number of record sets we have (so far) observed in the zone.
 
static struct GNUNET_TIME_Relative min_relative_record_time
 Minimum relative expiration time of records seem during the current zone iteration.
 
static struct GNUNET_TIME_Relative last_min_relative_record_time
 Minimum relative expiration time of records seem during the last zone iteration.
 
static struct GNUNET_TIME_Relative zone_publish_time_window_default
 Default time window for zone iteration.
 
static struct GNUNET_TIME_Relative zone_publish_time_window
 Time window for zone iteration, adjusted based on relative record expiration times in our zone.
 
static struct GNUNET_TIME_Absolute last_put_100
 When did we last start measuring the DELTA_INTERVAL successful DHT puts? Used for velocity calculations.
 
static struct GNUNET_TIME_Relative sub_delta
 By how much should we try to increase our per-record iteration speed (over the desired speed calculated directly from the #put_interval)? Basically this value corresponds to the per-record CPU time overhead we have.
 
static struct GNUNET_SCHEDULER_Taskzone_publish_task
 zone publish task
 
static unsigned int ns_iteration_left
 How many more values are left for the current query before we need to explicitly ask the namestore for more?
 
static int first_zone_iteration
 GNUNET_YES if zone has never been published before
 
static int cache_keys
 Optimize block insertion by caching map of private keys to public keys in memory?
 
static struct CacheOperationcop_head
 Head of cop DLL.
 
static struct CacheOperationcop_tail
 Tail of cop DLL.
 

Detailed Description

publish records from namestore to GNUnet name system

Author
Christian Grothoff

Definition in file gnunet-service-zonemaster.c.

Macro Definition Documentation

◆ LOG_STRERROR_FILE

#define LOG_STRERROR_FILE (   kind,
  syscall,
  filename 
)
Value:
syscall, \
static char * filename
#define GNUNET_log_from_strerror_file(level, component, cmd, filename)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...

Definition at line 34 of file gnunet-service-zonemaster.c.

133{
134
139
144
148 struct GNUNET_CRYPTO_PrivateKey zone;
149
153 struct GNUNET_GNSRECORD_Block *block;
154
159 struct GNUNET_GNSRECORD_Block *block_priv;
160
164 size_t block_size;
165
169 struct GNUNET_TIME_Absolute expire_pub;
170
174 char *label;
175
179 struct GNUNET_DHT_PutHandle *ph;
180
184 struct GNUNET_TIME_Absolute start_date;
185
189 int have_public_records;
190};
191
192
198
203
208
213
214
219
224
225
229struct CacheOperation
230{
234 struct CacheOperation *prev;
235
239 struct CacheOperation *next;
240
245
246};
247
248
253
257static struct GNUNET_DHT_Handle *dht_handle;
258
263
268
273
278static int disable_namecache;
279
284
288static unsigned int job_queue_length;
289
293static unsigned long long num_public_records;
294
298static unsigned long long last_num_public_records;
299
304static unsigned long long put_cnt;
305
314
320
326
331
337
343
350static struct GNUNET_TIME_Relative sub_delta;
351
356
361static unsigned int ns_iteration_left;
362
366static int first_zone_iteration;
367
372static int cache_keys;
373
377static struct CacheOperation *cop_head;
378
382static struct CacheOperation *cop_tail;
383
384
385static void
387{
388 if (job->block != job->block_priv)
389 GNUNET_free (job->block_priv);
390 GNUNET_free (job->block);
391 if (NULL != job->label)
392 GNUNET_free (job->label);
394}
395
396
403static void
404shutdown_task (void *cls)
405{
406 struct CacheOperation *cop;
408
409 (void) cls;
412 "Shutting down!\n");
413 if (NULL != notification_pipe)
415 if (NULL != pipe_read_task)
417 while (NULL != (cop = cop_head))
418 {
420 "Aborting incomplete namecache operation\n");
423 GNUNET_free (cop);
424 }
425 GNUNET_assert (0 == pthread_mutex_lock (&sign_jobs_lock));
426 while (NULL != (job = sign_jobs_head))
427 {
429 "Removing incomplete jobs\n");
432 free_job (job);
433 }
434 GNUNET_assert (0 == pthread_mutex_unlock (&sign_jobs_lock));
435 GNUNET_assert (0 == pthread_mutex_lock (&sign_results_lock));
436 while (NULL != (job = sign_results_head))
437 {
439 "Removing incomplete jobs\n");
441 free_job (job);
442 }
443 GNUNET_assert (0 == pthread_mutex_unlock (&sign_results_lock));
444 while (NULL != (job = dht_jobs_head))
445 {
447 "Removing incomplete jobs\n");
449 if (NULL != job->ph)
451 free_job (job);
452 }
453 if (NULL != statistics)
454 {
456 GNUNET_NO);
457 statistics = NULL;
458 }
459 if (NULL != zone_publish_task)
460 {
462 zone_publish_task = NULL;
463 }
464 if (NULL != namestore_iter)
465 {
467 namestore_iter = NULL;
468 }
469 if (NULL != zmon)
470 {
472 zmon = NULL;
473 }
474 if (NULL != namestore_handle)
475 {
477 namestore_handle = NULL;
478 }
479 if (NULL != namecache)
480 {
482 namecache = NULL;
483 }
484 if (NULL != dht_handle)
485 {
487 dht_handle = NULL;
488 }
489}
490
491
499static void
500finish_cache_operation (void *cls, int32_t success, const char *emsg)
501{
502 struct CacheOperation *cop = cls;
503
504 if (NULL != emsg)
506 _ ("Failed to replicate block in namecache: %s\n"),
507 emsg);
508 else
509 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "CACHE operation completed\n");
511 GNUNET_free (cop);
512}
513
514
523static void
524refresh_block (const struct GNUNET_GNSRECORD_Block *block)
525{
526 struct CacheOperation *cop;
527
529 {
531 "Namecache updates skipped (NC disabled)",
532 1,
533 GNUNET_NO);
534 return;
535 }
536 GNUNET_assert (NULL != block);
537 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Caching block in namecache\n");
539 "Namecache updates pushed",
540 1,
541 GNUNET_NO);
542 cop = GNUNET_new (struct CacheOperation);
545 block,
547 cop);
548}
549
550
556static void
558{
559 (void) cls;
560 zone_publish_task = NULL;
566}
567
568
574static void
575publish_zone_dht_start (void *cls);
576
577
581static void
583{
584 if (0 == num_public_records)
585 {
target_iteration_velocity_per_record = zone_publish_time_window;
592 "No records in namestore database.\n");
593 }
594 else
595 {
607 }
612 "Minimum relative record expiration (in μs)",
614 GNUNET_NO);
616 "Zone publication time window (in μs)",
618 GNUNET_NO);
620 "Target zone iteration velocity (μs)",
622 GNUNET_NO);
623}
624
625
633static void
634update_velocity (unsigned int cnt)
635{
637 unsigned long long pct = 0;
638
639 if (0 == cnt)
640 return;
641 /* How fast were we really? */
643 delta.rel_value_us /= cnt;
645
646 /* calculate expected frequency */
649 {
651 "Last record count was lower than current record count. Reducing interval.\n");
655 }
657 "Desired global zone iteration interval is %s/record!\n",
660 GNUNET_YES));
661
662 /* Tell statistics actual vs. desired speed */
664 "Current zone iteration velocity (μs/record)",
666 GNUNET_NO);
667 /* update "sub_delta" based on difference, taking
668 previous sub_delta into account! */
670 {
671 /* We were too fast, reduce sub_delta! */
672 struct GNUNET_TIME_Relative corr;
673
675 delta);
677 {
678 /* Reduce sub_delta by corr */
680 corr);
681 }
682 else
683 {
684 /* We're doing fine with waiting the full time, this
685 should theoretically only happen if we run at
686 infinite speed. */
688 }
689 }
692 {
693 /* We were too slow, increase sub_delta! */
694 struct GNUNET_TIME_Relative corr;
695
699 corr);
702 {
703 /* CPU overload detected, we cannot go at desired speed,
704 as this would mean using a negative delay. */
705 /* compute how much faster we would want to be for
706 the desired velocity */
708 pct = UINT64_MAX; /* desired speed is infinity ... */
709 else
714 }
715 }
717 "# dispatched jobs",
719 GNUNET_NO);
721 "% speed increase needed for target velocity",
722 pct,
723 GNUNET_NO);
725 "# records processed in current iteration",
727 GNUNET_NO);
728}
729
730
735static void
737{
738 struct GNUNET_TIME_Relative delay;
739
740 if (0 != ns_iteration_left)
741 return; /* current NAMESTORE iteration not yet done */
743 {
745 "Job queue length exceeded (%u/%u). Pausing namestore iteration.\n",
748 return;
749 }
751 put_cnt = 0;
753 sub_delta);
754 /* We delay *once* per #NS_BLOCK_SIZE, so we need to multiply the
755 per-record delay calculated so far with the #NS_BLOCK_SIZE */
757 "Current artificial NAMESTORE delay (μs/record)",
758 delay.rel_value_us,
759 GNUNET_NO);
760 delay = GNUNET_TIME_relative_multiply (delay,
762 /* make sure we do not overshoot because of the #NS_BLOCK_SIZE factor */
764 delay);
765 /* no delays on first iteration */
767 delay = GNUNET_TIME_UNIT_ZERO;
771 ,
772 NULL);
773}
774
775
776static void
778{
779
780 if (NULL == zone_publish_task)
783 {
785 {
787 "Job queue emptied (%u/%u). Resuming monitor.\n",
792 }
793 }
795 free_job (job);
796}
797
798
803static void
804dht_put_continuation (void *cls)
805{
806 struct RecordPublicationJob *job = cls;
807
809 "PUT complete; Pending jobs: %u\n", job_queue_length - 1);
810 /* When we just fall under the limit, trigger monitor/iterator again
811 * if halted. We can only safely trigger one, prefer iterator. */
814 job);
816}
817
818
829static void
831 const char *label,
832 const struct GNUNET_GNSRECORD_Data *rd,
833 unsigned int rd_count,
834 const struct GNUNET_TIME_Absolute expire)
835{
836 struct GNUNET_GNSRECORD_Data rd_public[rd_count];
837 struct GNUNET_GNSRECORD_Block *block;
838 struct GNUNET_GNSRECORD_Block *block_priv;
839 struct GNUNET_TIME_Absolute expire_pub;
841 size_t block_size;
842 unsigned int rd_public_count = 0;
843 char *emsg;
844
845 if (GNUNET_OK !=
847 rd,
848 rd_count,
849 rd_public,
850 &rd_public_count,
851 &expire_pub,
853 &emsg))
854 {
856 "%s\n", emsg);
857 GNUNET_free (emsg);
858 }
859
862 label,
863 rd_public,
864 rd_public_count,
865 &block));
866 if (NULL == block)
867 {
868 GNUNET_break (0);
869 return; /* whoops */
870 }
871 if (rd_count != rd_public_count)
873 expire,
874 label,
875 rd,
876 rd_count,
877 &
878 block_priv));
879 else
882 GNUNET_assert (0 == pthread_mutex_lock (&sign_jobs_lock));
884 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Public record count: %d\n",
885 rd_public_count);
886 job->have_public_records = (rd_public_count > 0);
887 job->block = block;
888 job->block_size = block_size;
889 job->block_priv = block_priv;
890 job->zone = *key;
891 job->label = GNUNET_strdup (label);
892 job->expire_pub = expire_pub;
894 GNUNET_assert (0 == pthread_cond_signal (&sign_jobs_cond));
895 GNUNET_assert (0 == pthread_mutex_unlock (&sign_jobs_lock));
897 "Creating job with %u record(s) for label `%s', expiration `%s'\n",
898 rd_public_count,
899 label,
902 return;
903}
904
905
906static void
907notification_pipe_cb (void *cls);
908
909static void
911{
912 struct GNUNET_HashCode query;
914 const struct GNUNET_DISK_FileHandle *np_fh;
915 char buf[100];
916 ssize_t nf_count;
917
918 pipe_read_task = NULL;
924 np_fh,
926 NULL);
927 /* empty queue */
928 nf_count = GNUNET_DISK_file_read (np_fh, buf, sizeof (buf));
929 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Read %lld notifications from pipe\n",
930 (long long) nf_count);
931 while (true)
932 {
933 GNUNET_assert (0 == pthread_mutex_lock (&sign_results_lock));
934 if (NULL == sign_results_head)
935 {
937 "No more results. Back to sleep.\n");
938 GNUNET_assert (0 == pthread_mutex_unlock (&sign_results_lock));
939 return;
940 }
943 GNUNET_assert (0 == pthread_mutex_unlock (&sign_results_lock));
945 job->label,
946 &query);
947 // It is possible that the public block size is 0 (no public blocks)
948 // Do not bother with the DHT in that case
949 if (job->have_public_records)
950 {
952 &query,
956 job->block_size,
957 job->block,
958 job->expire_pub,
960 job);
961 if (NULL == job->ph)
962 {
964 "Could not perform DHT PUT, is the DHT running?\n");
965 free_job (job);
966 return;
967 }
969 "DHT put operations initiated",
970 1,
971 GNUNET_NO);
973 "Storing record(s) for label `%s' in DHT under key %s\n",
974 job->label,
975 GNUNET_h2s (&query));
976 refresh_block (job->block_priv);
978 }
979 else
980 {
981 // Private blocks may still be available and must be updated
982 // in the cache
983 refresh_block (job->block_priv);
985 }
986 }
987}
988
989
995static void
996zone_iteration_error (void *cls)
997{
998 (void) cls;
1000 "Got disconnected from namestore database, retrying.\n");
1001 namestore_iter = NULL;
1002 /* We end up here on error/disconnect/shutdown, so potentially
1003 while a zone publish task or a DHT put is still running; hence
1004 we need to cancel those. */
1005 if (NULL != zone_publish_task)
1006 {
1008 zone_publish_task = NULL;
1009 }
1011 NULL);
1012}
1013
1014
1020static void
1021zone_iteration_finished (void *cls)
1022{
1023 (void) cls;
1024 /* we're done with one iteration, calculate when to do the next one */
1025 namestore_iter = NULL;
1030 /* reset for next iteration */
1034 "Zone iteration finished. Adjusted zone iteration interval to %s\n",
1037 GNUNET_YES));
1039 "Target zone iteration velocity (μs)",
1041 GNUNET_NO);
1043 "Number of public records in DHT",
1045 GNUNET_NO);
1047 if (0 == last_num_public_records)
1048 {
1052 NULL);
1053 }
1054 else
1055 {
1057 NULL);
1058 }
1059}
1060
1061
1071static void
1072handle_record (void *cls,
1073 const struct GNUNET_CRYPTO_PrivateKey *key,
1074 const char *label,
1075 unsigned int rd_count,
1076 const struct GNUNET_GNSRECORD_Data *rd,
1078{
1079 (void) cls;
1081 if (0 == rd_count)
1082 {
1084 "Record set empty, moving to next record set\n");
1086 return;
1087 }
1088 for (unsigned int i = 0; i < rd_count; i++)
1089 {
1090 if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
1091 {
1092 /* GNUNET_GNSRECORD_block_create will convert to absolute time;
1093 we just need to adjust our iteration frequency */
1095 GNUNET_MIN (rd[i].expiration_time,
1097 }
1098 }
1099
1100
1101 /* We got a set of records to publish */
1103 "Starting DHT PUT\n");
1104 put_cnt++;
1105 if (0 == put_cnt % DELTA_INTERVAL)
1108 label,
1109 rd,
1110 rd_count,
1111 expire);
1114}
1115
1116
1122static void
1123publish_zone_dht_start (void *cls)
1124{
1125 (void) cls;
1126 zone_publish_task = NULL;
1128 "Full zone iterations launched",
1129 1,
1130 GNUNET_NO);
1132 "Starting DHT zone update!\n");
1133 /* start counting again */
1135 GNUNET_assert (NULL == namestore_iter);
1139 NULL, /* All zones */
1141 NULL,
1143 NULL,
1145 NULL,
1147 GNUNET_assert (NULL != namestore_iter);
1148}
1149
1150
1159static void
1161 const char *label,
1162 const struct GNUNET_GNSRECORD_Data *rd,
1163 unsigned int rd_count,
1165{
1166 struct GNUNET_GNSRECORD_Data rd_public[rd_count];
1167 struct GNUNET_GNSRECORD_Block *block;
1168 struct GNUNET_GNSRECORD_Block *block_priv;
1169 struct GNUNET_TIME_Absolute expire_pub;
1170 struct RecordPublicationJob *job;
1171 size_t block_size;
1172 unsigned int rd_public_count = 0;
1173 char *emsg;
1174
1175 if (GNUNET_OK !=
1177 rd,
1178 rd_count,
1179 rd_public,
1180 &rd_public_count,
1181 &expire_pub,
1183 &emsg))
1184 {
1186 "%s\n", emsg);
1187 GNUNET_free (emsg);
1188 }
1189
1191 expire_pub,
1192 label,
1193 rd_public,
1194 rd_public_count,
1195 &block));
1196 if (NULL == block)
1197 {
1198 GNUNET_break (0);
1199 return; /* whoops */
1200 }
1201 if (rd_count != rd_public_count)
1203 expire,
1204 label,
1205 rd,
1206 rd_count,
1207 &
1208 block_priv));
1209 else
1210 block_priv = block;
1212 GNUNET_assert (0 == pthread_mutex_lock (&sign_jobs_lock));
1214 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Public record count: %d\n",
1215 rd_public_count);
1216 job->have_public_records = (rd_public_count > 0);
1217 job->block = block;
1218 job->block_size = block_size;
1219 job->block_priv = block_priv;
1220 job->zone = *key;
1221 job->label = GNUNET_strdup (label);
1222 job->expire_pub = expire_pub;
1224 GNUNET_assert (0 == pthread_cond_signal (&sign_jobs_cond));
1225 GNUNET_assert (0 == pthread_mutex_unlock (&sign_jobs_lock));
1226}
1227
1228
1240static void
1241handle_monitor_event (void *cls,
1242 const struct GNUNET_CRYPTO_PrivateKey *zone,
1243 const char *label,
1244 unsigned int rd_count,
1245 const struct GNUNET_GNSRECORD_Data *rd,
1247{
1248 (void) cls;
1250 "Namestore monitor events received",
1251 1,
1252 GNUNET_NO);
1254 "Received %u records for label `%s' via namestore monitor\n",
1255 rd_count,
1256 label);
1257 if (0 == rd_count)
1258 {
1260 1);
1261 return; /* nothing to do */
1262 }
1264 label,
1265 rd,
1266 rd_count,
1267 expire);
1270 {
1272 "Job queue length exceeded (%u/%u). Halting monitor.\n",
1276 return;
1277 }
1279 1);
1280}
1281
1282
1289static void
1290handle_monitor_error (void *cls)
1291{
1292 (void) cls;
1294 "Namestore monitor errors encountered",
1295 1,
1296 GNUNET_NO);
1297}
1298
1299
1300static void*
1301sign_worker (void *cls)
1302{
1303 struct RecordPublicationJob *job;
1304 const struct GNUNET_DISK_FileHandle *fh;
1305
1307 while (GNUNET_YES != in_shutdown)
1308 {
1309 GNUNET_assert (0 == pthread_mutex_lock (&sign_jobs_lock));
1310 while (NULL == sign_jobs_head)
1311 GNUNET_assert (0 == pthread_cond_wait (&sign_jobs_cond, &sign_jobs_lock));
1312 if (GNUNET_YES == in_shutdown)
1313 {
1314 GNUNET_assert (0 == pthread_mutex_unlock (&sign_jobs_lock));
1315 return NULL;
1316 }
1318 "Taking on Job for %s\n", sign_jobs_head->label);
1321 GNUNET_assert (0 == pthread_mutex_unlock (&sign_jobs_lock));
1322 GNUNET_GNSRECORD_block_sign (&job->zone, job->label, job->block);
1323 if (job->block != job->block_priv)
1324 GNUNET_GNSRECORD_block_sign (&job->zone, job->label, job->block_priv);
1325 GNUNET_assert (0 == pthread_mutex_lock (&sign_results_lock));
1327 GNUNET_assert (0 == pthread_mutex_unlock (&sign_results_lock));
1329 "Done, notifying main thread through pipe!\n");
1330 GNUNET_DISK_file_write (fh, "!", 1);
1331 }
1332 return NULL;
1333}
1334
1335
1336static void
1337notification_pipe_cb (void *cls)
1338{
1340 "Received wake up notification through pipe, checking results\n");
1342}
1343
1344
1352static void
1353run (void *cls,
1354 const struct GNUNET_CONFIGURATION_Handle *c,
1356{
1357 unsigned long long max_parallel_bg_queries = 128;
1358 const struct GNUNET_DISK_FileHandle *np_fh;
1359
1360 (void) cls;
1361 (void) service;
1362 pthread_mutex_init (&sign_jobs_lock, NULL);
1363 pthread_mutex_init (&sign_results_lock, NULL);
1364 pthread_cond_init (&sign_jobs_cond, NULL);
1365 last_put_100 = GNUNET_TIME_absolute_get (); /* first time! */
1370 if (NULL == namestore_handle)
1371 {
1373 _ ("Failed to connect to the namestore!\n"));
1375 return;
1376 }
1378 "namecache",
1379 "DISABLE");
1381 {
1383 if (NULL == namecache)
1384 {
1386 _ ("Failed to connect to the namecache!\n"));
1388 return;
1389 }
1390 }
1392 "namestore",
1393 "CACHE_KEYS");
1395 if (GNUNET_OK ==
1397 "zonemaster",
1398 "ZONE_PUBLISH_TIME_WINDOW",
1400 {
1402 "Time window for zone iteration: %s\n",
1405 GNUNET_YES));
1406 }
1408 if (GNUNET_OK ==
1410 "zonemaster",
1411 "MAX_PARALLEL_BACKGROUND_QUERIES",
1412 &max_parallel_bg_queries))
1413 {
1415 "Number of allowed parallel background queries: %llu\n",
1416 max_parallel_bg_queries);
1417 }
1418 if (0 == max_parallel_bg_queries)
1419 max_parallel_bg_queries = 1;
1421 (unsigned int) max_parallel_bg_queries);
1422 if (NULL == dht_handle)
1423 {
1425 _ ("Could not connect to DHT!\n"));
1427 NULL);
1428 return;
1429 }
1430
1431 /* Schedule periodic put for our records. */
1433 statistics = GNUNET_STATISTICS_create ("zonemaster",
1434 c);
1436 "Target zone iteration velocity (μs)",
1438 GNUNET_NO);
1440 NULL);
1442 NULL,
1443 GNUNET_NO,
1445 NULL,
1447 NULL,
1448 NULL /* sync_cb */,
1449 NULL,
1453 GNUNET_break (NULL != zmon);
1454
1456 NULL);
1457
1459 np_fh = GNUNET_DISK_pipe_handle (
1463 np_fh,
1464 notification_pipe_cb, NULL);
1465
1466 {
1467 long long unsigned int worker_count = 1;
1468 if (GNUNET_OK !=
1470 "zonemaster",
1471 "WORKER_COUNT",
1472 &worker_count))
1473 {
1475 "Number of workers not defined falling back to 1\n");
1476 }
1477 worker = GNUNET_malloc (sizeof (pthread_t) * worker_count);
1479 for (int i = 0; i < worker_count; i++)
1480 {
1481 if (0 !=
1482 pthread_create (&worker[i],
1483 NULL,
1484 &sign_worker,
1485 NULL))
1486 {
1488 "pthread_create");
1490 }
1492 "Workers running",
1493 1,
1494 GNUNET_NO);
1495 }
1496 }
1497}
1498
1499
1505 "zonemaster",
1507 &run,
1508 NULL,
1509 NULL,
1510 NULL,
1512
1513
1514/* end of gnunet-service-zonemaster.c */
static struct GNUNET_SCHEDULER_Task * job
Task for main job.
struct GNUNET_HashCode key
The key used in the DHT.
static char * expire
DID Document expiration Date Attribute String.
Definition gnunet-did.c:98
struct GNUNET_SCHEDULER_Task * shutdown_task
static unsigned int rd_count
Number of records for currently parsed set.
static struct GNUNET_GNSRECORD_Data rd[50]
The record data under a single label.
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
static pthread_mutex_t sign_results_lock
Lock for the DHT put jobs queue.
#define PUBLISH_OPS_PER_EXPIRATION
How often should we (re)publish each record before it expires?
static int disable_namecache
Use the namecache? Doing so creates additional cryptographic operations whenever we touch a record.
static struct CacheOperation * cop_head
Head of cop DLL.
static struct RecordPublicationJob * sign_results_tail
See above.
static void zone_iteration_finished(void *cls)
Zone iteration is completed.
static unsigned int ns_iteration_left
How many more values are left for the current query before we need to explicitly ask the namestore fo...
static void notification_pipe_cb(void *cls)
static void refresh_block(const struct GNUNET_GNSRECORD_Block *block)
Refresh the (encrypted) block in the namecache.
static struct GNUNET_TIME_Relative target_iteration_velocity_per_record
What is the frequency at which we currently would like to perform DHT puts (per record)?...
static void cleanup_job(struct RecordPublicationJob *job)
static unsigned long long put_cnt
Number of successful put operations performed in the current measurement cycle (as measured in check_...
static struct GNUNET_NAMECACHE_Handle * namecache
Our handle to the namecache service.
static unsigned long long last_num_public_records
Last seen record count.
static unsigned int job_queue_length
Number of entries in the job queue #jobs_head.
static void handle_monitor_event(void *cls, const struct GNUNET_CRYPTO_PrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, struct GNUNET_TIME_Absolute expire)
Process a record that was stored in the namestore (invoked by the monitor).
static void check_zone_namestore_next()
Check if the current zone iteration needs to be continued by calling publish_zone_namestore_next(),...
static struct RecordPublicationJob * sign_results_head
The DLL for workers to place jobs that are signed.
static struct GNUNET_TIME_Relative sub_delta
By how much should we try to increase our per-record iteration speed (over the desired speed calculat...
static struct GNUNET_TIME_Relative zone_publish_time_window
Time window for zone iteration, adjusted based on relative record expiration times in our zone.
#define DELTA_INTERVAL
How often do we measure the delta between desired zone iteration speed and actual speed,...
static void initiate_put_from_pipe_trigger(void *cls)
static struct RecordPublicationJob * dht_jobs_tail
See above.
static void handle_monitor_error(void *cls)
The zone monitor encountered an IPC error trying to to get in sync.
static void calculate_put_interval()
Calculate target_iteration_velocity_per_record.
#define NAMESTORE_MONITOR_QUEUE_LIMIT
How many events may the namestore give us before it has to wait for us to keep up?
static void publish_zone_namestore_next(void *cls)
Method called periodically that triggers iteration over authoritative records.
static struct CacheOperation * cop_tail
Tail of cop DLL.
static void finish_cache_operation(void *cls, int32_t success, const char *emsg)
Cache operation complete, clean up.
static void handle_record(void *cls, const struct GNUNET_CRYPTO_PrivateKey *key, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, struct GNUNET_TIME_Absolute expire)
Function used to put all records successively into the DHT.
static struct GNUNET_NAMESTORE_Handle * namestore_handle
Our handle to the namestore service.
static int in_shutdown
For threads to know we are shutting down.
#define NS_BLOCK_SIZE
How many records do we fetch in one shot from the namestore?
static struct GNUNET_TIME_Relative min_relative_record_time
Minimum relative expiration time of records seem during the current zone iteration.
static struct GNUNET_STATISTICS_Handle * statistics
Handle to the statistics service.
static struct GNUNET_DISK_PipeHandle * notification_pipe
Our notification pipe.
static struct GNUNET_DHT_Handle * dht_handle
Our handle to the DHT.
#define LATE_ITERATION_SPEEDUP_FACTOR
The factor the current zone iteration interval is divided by for each additional new record.
static int monitor_halted
Monitor halted?
static void publish_zone_dht_start(void *cls)
Periodically iterate over our zone and store everything in dht.
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service)
Perform zonemaster duties: watch namestore, publish records.
#define JOB_QUEUE_LIMIT
How many open jobs (and with it maximum amount of pending DHT operations) do we allow at most.
static unsigned long long num_public_records
Useful for zone update for DHT put.
static struct RecordPublicationJob * dht_jobs_head
The DLL for jobs currently in the process of being dispatched into the DHT.
#define INITIAL_ZONE_ITERATION_INTERVAL
The initial interval in milliseconds btween puts in a zone iteration.
static void dispatch_job_monitor(const struct GNUNET_CRYPTO_PrivateKey *key, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count, struct GNUNET_TIME_Absolute expire)
Store GNS records in the DHT.
static int first_zone_iteration
GNUNET_YES if zone has never been published before
static int cache_keys
Optimize block insertion by caching map of private keys to public keys in memory?
static struct GNUNET_TIME_Absolute last_put_100
When did we last start measuring the DELTA_INTERVAL successful DHT puts? Used for velocity calculatio...
static struct GNUNET_SCHEDULER_Task * zone_publish_task
zone publish task
static void * sign_worker(void *cls)
static struct GNUNET_SCHEDULER_Task * pipe_read_task
Pipe read task.
static struct GNUNET_NAMESTORE_ZoneIterator * namestore_iter
Handle to iterate over our authoritative zone in namestore.
static void free_job(struct RecordPublicationJob *job)
static struct GNUNET_TIME_Relative zone_publish_time_window_default
Default time window for zone iteration.
#define DHT_GNS_REPLICATION_LEVEL
What replication level do we use for DHT PUT operations?
static pthread_t * worker
Our workers.
static struct RecordPublicationJob * sign_jobs_head
The DLL for workers to retrieve open jobs that require signing of blocks.
static struct GNUNET_TIME_Relative last_min_relative_record_time
Minimum relative expiration time of records seem during the last zone iteration.
static void update_velocity(unsigned int cnt)
Re-calculate our velocity and the desired velocity.
static pthread_cond_t sign_jobs_cond
Wait condition on new sign jobs.
static void dht_put_continuation(void *cls)
Continuation called from DHT once the PUT operation is done.
static struct GNUNET_NAMESTORE_ZoneMonitor * zmon
Handle to monitor namestore changes to instant propagation.
static struct RecordPublicationJob * sign_jobs_tail
See above.
static void dispatch_job(const struct GNUNET_CRYPTO_PrivateKey *key, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count, const struct GNUNET_TIME_Absolute expire)
Store GNS records in the DHT.
#define MAXIMUM_ZONE_ITERATION_INTERVAL
The upper bound for the zone iteration interval (per record).
static pthread_mutex_t sign_jobs_lock
Lock for the sign jobs queue.
static void zone_iteration_error(void *cls)
We encountered an error in our zone iteration.
@ GNUNET_BLOCK_TYPE_GNS_NAMERECORD
Block for storing GNS record data.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
void GNUNET_DHT_put_cancel(struct GNUNET_DHT_PutHandle *ph)
Cancels a DHT PUT operation.
Definition dht_api.c:1144
struct GNUNET_DHT_PutHandle * GNUNET_DHT_put(struct GNUNET_DHT_Handle *handle, const struct GNUNET_HashCode *key, uint32_t desired_replication_level, enum GNUNET_DHT_RouteOption options, enum GNUNET_BLOCK_Type type, size_t size, const void *data, struct GNUNET_TIME_Absolute exp, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls)
Perform a PUT operation storing data in the DHT.
Definition dht_api.c:1081
struct GNUNET_DHT_Handle * GNUNET_DHT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int ht_len)
Initialize the connection with the DHT service.
Definition dht_api.c:1030
#define GNUNET_DHT_DEFAULT_REPUBLISH_FREQUENCY
Default republication frequency for stored data in the DHT.
void GNUNET_DHT_disconnect(struct GNUNET_DHT_Handle *handle)
Shutdown connection with the DHT service.
Definition dht_api.c:1053
@ GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE
Each peer along the way should process the request (otherwise only peers locally closest to the key w...
const struct GNUNET_DISK_FileHandle * GNUNET_DISK_pipe_handle(const struct GNUNET_DISK_PipeHandle *p, enum GNUNET_DISK_PipeEnd n)
Get the handle to a particular pipe end.
Definition disk.c:1645
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
Definition disk.c:710
struct GNUNET_DISK_PipeHandle * GNUNET_DISK_pipe(enum GNUNET_DISK_PipeFlags pf)
Creates an interprocess channel.
Definition disk.c:1468
enum GNUNET_GenericReturnValue GNUNET_DISK_pipe_close(struct GNUNET_DISK_PipeHandle *p)
Closes an interprocess channel.
Definition disk.c:1615
ssize_t GNUNET_DISK_file_read(const struct GNUNET_DISK_FileHandle *h, void *result, size_t len)
Read the contents of a binary file into a buffer.
Definition disk.c:673
@ GNUNET_DISK_PF_NONE
No special options, use non-blocking read/write operations.
@ GNUNET_DISK_PIPE_END_WRITE
The writing-end of a pipe.
@ GNUNET_DISK_PIPE_END_READ
The reading-end of a pipe.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_block_create_unsigned(const struct GNUNET_CRYPTO_PrivateKey *key, struct GNUNET_TIME_Absolute expire, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count, struct GNUNET_GNSRECORD_Block **result)
Create name and records but do not sign! Sign later with GNUNET_GNSRECORD_block_sign().
void GNUNET_GNSRECORD_query_from_private_key(const struct GNUNET_CRYPTO_PrivateKey *zone, const char *label, struct GNUNET_HashCode *query)
Calculate the DHT query for a given label in a given zone.
size_t GNUNET_GNSRECORD_block_get_size(const struct GNUNET_GNSRECORD_Block *block)
Returns the length of this block in bytes.
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_block_sign(const struct GNUNET_CRYPTO_PrivateKey *key, const char *label, struct GNUNET_GNSRECORD_Block *block)
Sign a block create with GNUNET_GNSRECORD_block_create_unsigned.
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_normalize_record_set(const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count, struct GNUNET_GNSRECORD_Data *rd_public, unsigned int *rd_count_public, struct GNUNET_TIME_Absolute *min_expiry, enum GNUNET_GNSRECORD_Filter filter, char **emsg)
Normalize namestore records: Check for consistency and expirations.
@ GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION
This expiration time of the record is a relative time (not an absolute time).
@ GNUNET_GNSRECORD_FILTER_NONE
No filter flags set.
@ GNUNET_GNSRECORD_FILTER_OMIT_PRIVATE
Filter private records.
#define GNUNET_log(kind,...)
#define GNUNET_MIN(a, b)
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_BULK
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
struct GNUNET_NAMECACHE_Handle * GNUNET_NAMECACHE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namecache service.
void GNUNET_NAMECACHE_disconnect(struct GNUNET_NAMECACHE_Handle *h)
Disconnect from the namecache service (and free associated resources).
void GNUNET_NAMECACHE_cancel(struct GNUNET_NAMECACHE_QueueEntry *qe)
Cancel a namecache operation.
struct GNUNET_NAMECACHE_QueueEntry * GNUNET_NAMECACHE_block_cache(struct GNUNET_NAMECACHE_Handle *h, const struct GNUNET_GNSRECORD_Block *block, GNUNET_NAMECACHE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the namecache.
struct GNUNET_NAMESTORE_ZoneIterator * GNUNET_NAMESTORE_zone_iteration_start2(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_PrivateKey *zone, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordSetMonitor proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls, enum GNUNET_GNSRECORD_Filter filter)
Starts a new zone iteration (used to periodically PUT all of our records into our DHT).
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).
void GNUNET_NAMESTORE_zone_iterator_next(struct GNUNET_NAMESTORE_ZoneIterator *it, uint64_t limit)
Calls the record processor specified in GNUNET_NAMESTORE_zone_iteration_start for the next record.
void GNUNET_NAMESTORE_zone_monitor_stop(struct GNUNET_NAMESTORE_ZoneMonitor *zm)
Stop monitoring a zone for changes.
struct GNUNET_NAMESTORE_ZoneMonitor * GNUNET_NAMESTORE_zone_monitor_start2(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_CRYPTO_PrivateKey *zone, int iterate_first, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordSetMonitor monitor, void *monitor_cls, GNUNET_SCHEDULER_TaskCallback sync_cb, void *sync_cb_cls, enum GNUNET_GNSRECORD_Filter filter)
Begin monitoring a zone for changes.
void GNUNET_NAMESTORE_zone_monitor_next(struct GNUNET_NAMESTORE_ZoneMonitor *zm, uint64_t limit)
Calls the monitor processor specified in GNUNET_NAMESTORE_zone_monitor_start for the next record(s).
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namestore service.
void GNUNET_NAMESTORE_zone_iteration_stop(struct GNUNET_NAMESTORE_ZoneIterator *it)
Stops iteration and releases the namestore handle for further calls.
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition scheduler.c:567
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_read_file(struct GNUNET_TIME_Relative delay, const struct GNUNET_DISK_FileHandle *rfd, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay or when the specified file descriptor is ready f...
Definition scheduler.c:1661
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
Definition scheduler.c:1339
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition scheduler.c:980
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition scheduler.c:1304
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition scheduler.c:1277
#define GNUNET_SERVICE_MAIN(pd, service_name, service_options, init_cb, connect_cb, disconnect_cb, cls,...)
Creates the "main" function for a GNUnet service.
@ GNUNET_SERVICE_OPTION_NONE
Use defaults.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
struct GNUNET_TIME_Relative GNUNET_TIME_relative_min(struct GNUNET_TIME_Relative t1, struct GNUNET_TIME_Relative t2)
Return the minimum of two relative time values.
Definition time.c:344
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition time.c:438
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition strings.c:599
struct GNUNET_TIME_Relative GNUNET_TIME_relative_subtract(struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2)
Subtract relative timestamp from the other.
Definition time.c:605
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition time.c:111
struct GNUNET_TIME_Relative GNUNET_TIME_relative_add(struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2)
Add relative times together.
Definition time.c:587
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition time.c:486
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_divide(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Divide relative time by a given factor.
Definition time.c:552
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition strings.c:660
#define _(String)
GNU gettext support macro.
Definition platform.h:179
static struct GNUNET_TIME_Relative delta
Definition speedup.c:36
Pending operation on the namecache.
struct CacheOperation * next
Kept in a DLL.
struct GNUNET_NAMECACHE_QueueEntry * qe
Handle to namecache queue.
struct CacheOperation * prev
Kept in a DLL.
A private key for an identity as per LSD0001.
Connection to the DHT service.
Definition dht_api.c:235
Handle to a PUT request.
Definition dht_api.c:43
Handle used to access files (and pipes).
A 512-bit hashcode.
Connection to the NAMECACHE service.
An QueueEntry used to store information for a pending NAMECACHE record operation.
Connection to the NAMESTORE service.
Handle for a zone iterator operation.
Handle for a monitoring activity.
Entry in list of pending tasks.
Definition scheduler.c:136
Handle to a service.
Definition service.c:116
Handle for the service.
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
struct RecordPublicationJob * next
DLL.
struct GNUNET_CRYPTO_PrivateKey zone
The zone key to sign the block with.
struct RecordPublicationJob * prev
DLL.
struct GNUNET_GNSRECORD_Block * block
The block to sign.
char * label
The label of the block needed for signing.
size_t block_size
The size of the public block for the DHT put.
struct GNUNET_TIME_Absolute expire_pub
The expiration time of the public block for the DHT put.
struct GNUNET_GNSRECORD_Block * block_priv
The private block to sign, may point to block in case the public and private blocks are the same.

◆ PUBLISH_OPS_PER_EXPIRATION

#define PUBLISH_OPS_PER_EXPIRATION   4

How often should we (re)publish each record before it expires?

Definition at line 44 of file gnunet-service-zonemaster.c.

◆ DELTA_INTERVAL

#define DELTA_INTERVAL   100

How often do we measure the delta between desired zone iteration speed and actual speed, and tell statistics service about it?

Definition at line 51 of file gnunet-service-zonemaster.c.

◆ NS_BLOCK_SIZE

#define NS_BLOCK_SIZE   1000

How many records do we fetch in one shot from the namestore?

Definition at line 56 of file gnunet-service-zonemaster.c.

◆ JOB_QUEUE_LIMIT

#define JOB_QUEUE_LIMIT   5000

How many open jobs (and with it maximum amount of pending DHT operations) do we allow at most.

Definition at line 61 of file gnunet-service-zonemaster.c.

◆ NAMESTORE_MONITOR_QUEUE_LIMIT

#define NAMESTORE_MONITOR_QUEUE_LIMIT   5

How many events may the namestore give us before it has to wait for us to keep up?

Definition at line 67 of file gnunet-service-zonemaster.c.

◆ INITIAL_ZONE_ITERATION_INTERVAL

#define INITIAL_ZONE_ITERATION_INTERVAL   GNUNET_TIME_UNIT_MILLISECONDS

The initial interval in milliseconds btween puts in a zone iteration.

Definition at line 73 of file gnunet-service-zonemaster.c.

◆ MAXIMUM_ZONE_ITERATION_INTERVAL

#define MAXIMUM_ZONE_ITERATION_INTERVAL
Value:
#define GNUNET_TIME_UNIT_MINUTES
One minute.

The upper bound for the zone iteration interval (per record).

Definition at line 79 of file gnunet-service-zonemaster.c.

◆ LATE_ITERATION_SPEEDUP_FACTOR

#define LATE_ITERATION_SPEEDUP_FACTOR   2

The factor the current zone iteration interval is divided by for each additional new record.

Definition at line 86 of file gnunet-service-zonemaster.c.

◆ DHT_GNS_REPLICATION_LEVEL

#define DHT_GNS_REPLICATION_LEVEL   5

What replication level do we use for DHT PUT operations?

Definition at line 91 of file gnunet-service-zonemaster.c.

Function Documentation

◆ free_job()

static void free_job ( struct RecordPublicationJob job)
static

Definition at line 387 of file gnunet-service-zonemaster.c.

388{
389 if (job->block != job->block_priv)
390 GNUNET_free (job->block_priv);
391 GNUNET_free (job->block);
392 if (NULL != job->label)
393 GNUNET_free (job->label);
395}

References GNUNET_free, and job.

Referenced by cleanup_job(), initiate_put_from_pipe_trigger(), and shutdown_task().

Here is the caller graph for this function:

◆ shutdown_task()

static void shutdown_task ( void *  cls)
static

Task run during shutdown.

Parameters
clsunused
tcunused

Definition at line 405 of file gnunet-service-zonemaster.c.

406{
407 struct CacheOperation *cop;
409
410 (void) cls;
413 "Shutting down!\n");
414 if (NULL != notification_pipe)
416 if (NULL != pipe_read_task)
418 while (NULL != (cop = cop_head))
419 {
421 "Aborting incomplete namecache operation\n");
424 GNUNET_free (cop);
425 }
426 GNUNET_assert (0 == pthread_mutex_lock (&sign_jobs_lock));
427 while (NULL != (job = sign_jobs_head))
428 {
430 "Removing incomplete jobs\n");
433 free_job (job);
434 }
435 GNUNET_assert (0 == pthread_mutex_unlock (&sign_jobs_lock));
436 GNUNET_assert (0 == pthread_mutex_lock (&sign_results_lock));
437 while (NULL != (job = sign_results_head))
438 {
440 "Removing incomplete jobs\n");
442 free_job (job);
443 }
444 GNUNET_assert (0 == pthread_mutex_unlock (&sign_results_lock));
445 while (NULL != (job = dht_jobs_head))
446 {
448 "Removing incomplete jobs\n");
450 if (NULL != job->ph)
452 free_job (job);
453 }
454 if (NULL != statistics)
455 {
457 GNUNET_NO);
458 statistics = NULL;
459 }
460 if (NULL != zone_publish_task)
461 {
463 zone_publish_task = NULL;
464 }
465 if (NULL != namestore_iter)
466 {
468 namestore_iter = NULL;
469 }
470 if (NULL != zmon)
471 {
473 zmon = NULL;
474 }
475 if (NULL != namestore_handle)
476 {
478 namestore_handle = NULL;
479 }
480 if (NULL != namecache)
481 {
483 namecache = NULL;
484 }
485 if (NULL != dht_handle)
486 {
488 dht_handle = NULL;
489 }
490}

References cop_head, cop_tail, dht_handle, dht_jobs_head, dht_jobs_tail, free_job(), GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_DHT_disconnect(), GNUNET_DHT_put_cancel(), GNUNET_DISK_pipe_close(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_NAMECACHE_cancel(), GNUNET_NAMECACHE_disconnect(), GNUNET_NAMESTORE_disconnect(), GNUNET_NAMESTORE_zone_iteration_stop(), GNUNET_NAMESTORE_zone_monitor_stop(), GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_destroy(), GNUNET_YES, in_shutdown, job, job_queue_length, namecache, namestore_handle, namestore_iter, notification_pipe, pipe_read_task, CacheOperation::qe, sign_jobs_head, sign_jobs_lock, sign_jobs_tail, sign_results_head, sign_results_lock, sign_results_tail, statistics, zmon, and zone_publish_task.

Here is the call graph for this function:

◆ finish_cache_operation()

static void finish_cache_operation ( void *  cls,
int32_t  success,
const char *  emsg 
)
static

Cache operation complete, clean up.

Parameters
clsthe struct CacheOperation
successsuccess
emsgerror messages

Definition at line 501 of file gnunet-service-zonemaster.c.

502{
503 struct CacheOperation *cop = cls;
504
505 if (NULL != emsg)
507 _ ("Failed to replicate block in namecache: %s\n"),
508 emsg);
509 else
510 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "CACHE operation completed\n");
512 GNUNET_free (cop);
513}

References _, cop_head, cop_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, and GNUNET_log.

Referenced by refresh_block().

Here is the caller graph for this function:

◆ refresh_block()

static void refresh_block ( const struct GNUNET_GNSRECORD_Block block)
static

Refresh the (encrypted) block in the namecache.

Parameters
zone_keyprivate key of the zone
namelabel for the records
rd_countnumber of records
rdrecords stored under the given name

Definition at line 525 of file gnunet-service-zonemaster.c.

526{
527 struct CacheOperation *cop;
528
530 {
532 "Namecache updates skipped (NC disabled)",
533 1,
534 GNUNET_NO);
535 return;
536 }
537 GNUNET_assert (NULL != block);
538 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Caching block in namecache\n");
540 "Namecache updates pushed",
541 1,
542 GNUNET_NO);
543 cop = GNUNET_new (struct CacheOperation);
546 block,
548 cop);
549}

References cop_head, cop_tail, disable_namecache, finish_cache_operation(), GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NAMECACHE_block_cache(), GNUNET_new, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_YES, namecache, CacheOperation::qe, and statistics.

Referenced by initiate_put_from_pipe_trigger().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ publish_zone_namestore_next()

static void publish_zone_namestore_next ( void *  cls)
static

Method called periodically that triggers iteration over authoritative records.

Parameters
clsNULL

Definition at line 558 of file gnunet-service-zonemaster.c.

References GNUNET_assert, GNUNET_NAMESTORE_zone_iterator_next(), namestore_iter, NS_BLOCK_SIZE, ns_iteration_left, and zone_publish_task.

Referenced by check_zone_namestore_next().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ publish_zone_dht_start()

static void publish_zone_dht_start ( void *  cls)
static

Periodically iterate over our zone and store everything in dht.

Periodically iterate over all zones and store everything in DHT.

Parameters
clsNULL

Definition at line 1124 of file gnunet-service-zonemaster.c.

1125{
1126 (void) cls;
1127 zone_publish_task = NULL;
1129 "Full zone iterations launched",
1130 1,
1131 GNUNET_NO);
1133 "Starting DHT zone update!\n");
1134 /* start counting again */
1136 GNUNET_assert (NULL == namestore_iter);
1140 NULL, /* All zones */
1142 NULL,
1144 NULL,
1146 NULL,
1148 GNUNET_assert (NULL != namestore_iter);
1149}

References GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNSRECORD_FILTER_NONE, GNUNET_log, GNUNET_NAMESTORE_zone_iteration_start2(), GNUNET_NO, GNUNET_STATISTICS_update(), handle_record(), namestore_handle, namestore_iter, ns_iteration_left, num_public_records, statistics, zone_iteration_error(), zone_iteration_finished(), and zone_publish_task.

Referenced by run(), zone_iteration_error(), and zone_iteration_finished().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculate_put_interval()

static void calculate_put_interval ( )
static

Calculate target_iteration_velocity_per_record.

If no records are known (startup) or none present we can safely set the interval to the value for a single record

Definition at line 583 of file gnunet-service-zonemaster.c.

References GNUNET_ERROR_TYPE_BULK, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_set(), GNUNET_TIME_relative_divide(), GNUNET_TIME_relative_min(), last_min_relative_record_time, last_num_public_records, MAXIMUM_ZONE_ITERATION_INTERVAL, min_relative_record_time, num_public_records, PUBLISH_OPS_PER_EXPIRATION, GNUNET_TIME_Relative::rel_value_us, statistics, target_iteration_velocity_per_record, zone_publish_time_window, and zone_publish_time_window_default.

Referenced by update_velocity(), and zone_iteration_finished().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_velocity()

static void update_velocity ( unsigned int  cnt)
static

Re-calculate our velocity and the desired velocity.

We have succeeded in making DELTA_INTERVAL puts, so now calculate the new desired delay between puts.

Parameters
cnthow many records were processed since the last call?

Definition at line 635 of file gnunet-service-zonemaster.c.

636{
638 unsigned long long pct = 0;
639
640 if (0 == cnt)
641 return;
642 /* How fast were we really? */
644 delta.rel_value_us /= cnt;
646
647 /* calculate expected frequency */
650 {
652 "Last record count was lower than current record count. Reducing interval.\n");
656 }
658 "Desired global zone iteration interval is %s/record!\n",
661 GNUNET_YES));
662
663 /* Tell statistics actual vs. desired speed */
665 "Current zone iteration velocity (μs/record)",
667 GNUNET_NO);
668 /* update "sub_delta" based on difference, taking
669 previous sub_delta into account! */
671 {
672 /* We were too fast, reduce sub_delta! */
673 struct GNUNET_TIME_Relative corr;
674
676 delta);
678 {
679 /* Reduce sub_delta by corr */
681 corr);
682 }
683 else
684 {
685 /* We're doing fine with waiting the full time, this
686 should theoretically only happen if we run at
687 infinite speed. */
689 }
690 }
693 {
694 /* We were too slow, increase sub_delta! */
695 struct GNUNET_TIME_Relative corr;
696
700 corr);
703 {
704 /* CPU overload detected, we cannot go at desired speed,
705 as this would mean using a negative delay. */
706 /* compute how much faster we would want to be for
707 the desired velocity */
709 pct = UINT64_MAX; /* desired speed is infinity ... */
710 else
715 }
716 }
718 "# dispatched jobs",
720 GNUNET_NO);
722 "% speed increase needed for target velocity",
723 pct,
724 GNUNET_NO);
726 "# records processed in current iteration",
728 GNUNET_NO);
729}

References calculate_put_interval(), delta, first_zone_iteration, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_set(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_relative_add(), GNUNET_TIME_relative_subtract(), GNUNET_TIME_UNIT_ZERO, GNUNET_YES, job_queue_length, last_num_public_records, last_put_100, LATE_ITERATION_SPEEDUP_FACTOR, num_public_records, GNUNET_TIME_Relative::rel_value_us, statistics, sub_delta, and target_iteration_velocity_per_record.

Referenced by check_zone_namestore_next(), and handle_record().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_zone_namestore_next()

static void check_zone_namestore_next ( )
static

Check if the current zone iteration needs to be continued by calling publish_zone_namestore_next(), and if so with what delay.

Definition at line 737 of file gnunet-service-zonemaster.c.

738{
739 struct GNUNET_TIME_Relative delay;
740
741 if (0 != ns_iteration_left)
742 return; /* current NAMESTORE iteration not yet done */
744 {
746 "Job queue length exceeded (%u/%u). Pausing namestore iteration.\n",
749 return;
750 }
752 put_cnt = 0;
754 sub_delta);
755 /* We delay *once* per #NS_BLOCK_SIZE, so we need to multiply the
756 per-record delay calculated so far with the #NS_BLOCK_SIZE */
758 "Current artificial NAMESTORE delay (μs/record)",
759 delay.rel_value_us,
760 GNUNET_NO);
761 delay = GNUNET_TIME_relative_multiply (delay,
763 /* make sure we do not overshoot because of the #NS_BLOCK_SIZE factor */
765 delay);
766 /* no delays on first iteration */
768 delay = GNUNET_TIME_UNIT_ZERO;
772 ,
773 NULL);
774}

References first_zone_iteration, GNUNET_assert, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_STATISTICS_set(), GNUNET_TIME_relative_min(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_relative_subtract(), GNUNET_TIME_UNIT_ZERO, GNUNET_YES, job_queue_length, JOB_QUEUE_LIMIT, MAXIMUM_ZONE_ITERATION_INTERVAL, NS_BLOCK_SIZE, ns_iteration_left, publish_zone_namestore_next(), put_cnt, GNUNET_TIME_Relative::rel_value_us, statistics, sub_delta, target_iteration_velocity_per_record, update_velocity(), and zone_publish_task.

Referenced by cleanup_job(), and handle_record().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanup_job()

static void cleanup_job ( struct RecordPublicationJob job)
static

Definition at line 778 of file gnunet-service-zonemaster.c.

779{
780
781 if (NULL == zone_publish_task)
784 {
786 {
788 "Job queue emptied (%u/%u). Resuming monitor.\n",
793 }
794 }
796 free_job (job);
797}

References check_zone_namestore_next(), free_job(), GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_NAMESTORE_zone_monitor_next(), GNUNET_NO, GNUNET_YES, job, job_queue_length, JOB_QUEUE_LIMIT, monitor_halted, zmon, and zone_publish_task.

Referenced by dht_put_continuation(), and initiate_put_from_pipe_trigger().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dht_put_continuation()

static void dht_put_continuation ( void *  cls)
static

Continuation called from DHT once the PUT operation is done.

Definition at line 805 of file gnunet-service-zonemaster.c.

806{
807 struct RecordPublicationJob *job = cls;
808
810 "PUT complete; Pending jobs: %u\n", job_queue_length - 1);
811 /* When we just fall under the limit, trigger monitor/iterator again
812 * if halted. We can only safely trigger one, prefer iterator. */
815 job);
817}

References cleanup_job(), dht_jobs_head, dht_jobs_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, job, and job_queue_length.

Referenced by initiate_put_from_pipe_trigger().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dispatch_job()

static void dispatch_job ( const struct GNUNET_CRYPTO_PrivateKey key,
const char *  label,
const struct GNUNET_GNSRECORD_Data rd,
unsigned int  rd_count,
const struct GNUNET_TIME_Absolute  expire 
)
static

Store GNS records in the DHT.

Parameters
keykey of the zone
labellabel to store under
rd_publicpublic record data
rd_public_countnumber of records in rd_public
mahandle for the put operation
Returns
DHT PUT handle, NULL on error

Definition at line 831 of file gnunet-service-zonemaster.c.

836{
837 struct GNUNET_GNSRECORD_Data rd_public[rd_count];
838 struct GNUNET_GNSRECORD_Block *block;
839 struct GNUNET_GNSRECORD_Block *block_priv;
840 struct GNUNET_TIME_Absolute expire_pub;
842 size_t block_size;
843 unsigned int rd_public_count = 0;
844 char *emsg;
845
846 if (GNUNET_OK !=
848 rd,
849 rd_count,
850 rd_public,
851 &rd_public_count,
852 &expire_pub,
854 &emsg))
855 {
857 "%s\n", emsg);
858 GNUNET_free (emsg);
859 }
860
863 label,
864 rd_public,
865 rd_public_count,
866 &block));
867 if (NULL == block)
868 {
869 GNUNET_break (0);
870 return; /* whoops */
871 }
872 if (rd_count != rd_public_count)
874 expire,
875 label,
876 rd,
877 rd_count,
878 &
879 block_priv));
880 else
883 GNUNET_assert (0 == pthread_mutex_lock (&sign_jobs_lock));
885 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Public record count: %d\n",
886 rd_public_count);
887 job->have_public_records = (rd_public_count > 0);
888 job->block = block;
889 job->block_size = block_size;
890 job->block_priv = block_priv;
891 job->zone = *key;
892 job->label = GNUNET_strdup (label);
893 job->expire_pub = expire_pub;
895 GNUNET_assert (0 == pthread_cond_signal (&sign_jobs_cond));
896 GNUNET_assert (0 == pthread_mutex_unlock (&sign_jobs_lock));
898 "Creating job with %u record(s) for label `%s', expiration `%s'\n",
899 rd_public_count,
900 label,
903 return;
904}

References RecordPublicationJob::block, RecordPublicationJob::block_priv, RecordPublicationJob::block_size, expire, RecordPublicationJob::expire_pub, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_GNSRECORD_block_create_unsigned(), GNUNET_GNSRECORD_block_get_size(), GNUNET_GNSRECORD_FILTER_OMIT_PRIVATE, GNUNET_GNSRECORD_normalize_record_set(), GNUNET_log, GNUNET_new, GNUNET_OK, GNUNET_strdup, GNUNET_STRINGS_absolute_time_to_string(), job, key, RecordPublicationJob::label, num_public_records, rd, rd_count, sign_jobs_cond, sign_jobs_head, sign_jobs_lock, and sign_jobs_tail.

Referenced by handle_record().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ notification_pipe_cb()

static void notification_pipe_cb ( void *  cls)
static

Definition at line 1338 of file gnunet-service-zonemaster.c.

1339{
1341 "Received wake up notification through pipe, checking results\n");
1343}

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_SCHEDULER_add_now(), and initiate_put_from_pipe_trigger().

Referenced by initiate_put_from_pipe_trigger(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initiate_put_from_pipe_trigger()

static void initiate_put_from_pipe_trigger ( void *  cls)
static

Definition at line 911 of file gnunet-service-zonemaster.c.

912{
913 struct GNUNET_HashCode query;
915 const struct GNUNET_DISK_FileHandle *np_fh;
916 char buf[100];
917 ssize_t nf_count;
918
919 pipe_read_task = NULL;
925 np_fh,
927 NULL);
928 /* empty queue */
929 nf_count = GNUNET_DISK_file_read (np_fh, buf, sizeof (buf));
930 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Read %lld notifications from pipe\n",
931 (long long) nf_count);
932 while (true)
933 {
934 GNUNET_assert (0 == pthread_mutex_lock (&sign_results_lock));
935 if (NULL == sign_results_head)
936 {
938 "No more results. Back to sleep.\n");
939 GNUNET_assert (0 == pthread_mutex_unlock (&sign_results_lock));
940 return;
941 }
944 GNUNET_assert (0 == pthread_mutex_unlock (&sign_results_lock));
946 job->label,
947 &query);
948 // It is possible that the public block size is 0 (no public blocks)
949 // Do not bother with the DHT in that case
950 if (job->have_public_records)
951 {
953 &query,
957 job->block_size,
958 job->block,
959 job->expire_pub,
961 job);
962 if (NULL == job->ph)
963 {
965 "Could not perform DHT PUT, is the DHT running?\n");
966 free_job (job);
967 return;
968 }
970 "DHT put operations initiated",
971 1,
972 GNUNET_NO);
974 "Storing record(s) for label `%s' in DHT under key %s\n",
975 job->label,
976 GNUNET_h2s (&query));
977 refresh_block (job->block_priv);
979 }
980 else
981 {
982 // Private blocks may still be available and must be updated
983 // in the cache
984 refresh_block (job->block_priv);
986 }
987 }
988}

References cleanup_job(), DHT_GNS_REPLICATION_LEVEL, dht_handle, dht_jobs_head, dht_jobs_tail, dht_put_continuation(), free_job(), GNUNET_assert, GNUNET_BLOCK_TYPE_GNS_NAMERECORD, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_DLL_remove, GNUNET_DHT_put(), GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, GNUNET_DISK_file_read(), GNUNET_DISK_PIPE_END_READ, GNUNET_DISK_pipe_handle(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_GNSRECORD_query_from_private_key(), GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_read_file(), GNUNET_STATISTICS_update(), GNUNET_TIME_UNIT_FOREVER_REL, job, notification_pipe, notification_pipe_cb(), pipe_read_task, refresh_block(), sign_results_head, sign_results_lock, sign_results_tail, and statistics.

Referenced by notification_pipe_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ zone_iteration_error()

static void zone_iteration_error ( void *  cls)
static

We encountered an error in our zone iteration.

Parameters
clsNULL

Definition at line 997 of file gnunet-service-zonemaster.c.

998{
999 (void) cls;
1001 "Got disconnected from namestore database, retrying.\n");
1002 namestore_iter = NULL;
1003 /* We end up here on error/disconnect/shutdown, so potentially
1004 while a zone publish task or a DHT put is still running; hence
1005 we need to cancel those. */
1006 if (NULL != zone_publish_task)
1007 {
1009 zone_publish_task = NULL;
1010 }
1012 NULL);
1013}

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), namestore_iter, publish_zone_dht_start(), and zone_publish_task.

Referenced by publish_zone_dht_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ zone_iteration_finished()

static void zone_iteration_finished ( void *  cls)
static

Zone iteration is completed.

Parameters
clsNULL

Definition at line 1022 of file gnunet-service-zonemaster.c.

1023{
1024 (void) cls;
1025 /* we're done with one iteration, calculate when to do the next one */
1026 namestore_iter = NULL;
1031 /* reset for next iteration */
1035 "Zone iteration finished. Adjusted zone iteration interval to %s\n",
1038 GNUNET_YES));
1040 "Target zone iteration velocity (μs)",
1042 GNUNET_NO);
1044 "Number of public records in DHT",
1046 GNUNET_NO);
1048 if (0 == last_num_public_records)
1049 {
1053 NULL);
1054 }
1055 else
1056 {
1058 NULL);
1059 }
1060}

References calculate_put_interval(), first_zone_iteration, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_now(), GNUNET_STATISTICS_set(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, last_min_relative_record_time, last_num_public_records, min_relative_record_time, namestore_iter, num_public_records, publish_zone_dht_start(), GNUNET_TIME_Relative::rel_value_us, statistics, target_iteration_velocity_per_record, and zone_publish_task.

Referenced by publish_zone_dht_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_record()

static void handle_record ( void *  cls,
const struct GNUNET_CRYPTO_PrivateKey key,
const char *  label,
unsigned int  rd_count,
const struct GNUNET_GNSRECORD_Data rd,
struct GNUNET_TIME_Absolute  expire 
)
static

Function used to put all records successively into the DHT.

Parameters
clsthe closure (NULL)
keythe private key of the authority (ours)
labelthe name of the records, NULL once the iteration is done
rd_countthe number of records in rd
rdthe record data

Definition at line 1073 of file gnunet-service-zonemaster.c.

1079{
1080 (void) cls;
1082 if (0 == rd_count)
1083 {
1085 "Record set empty, moving to next record set\n");
1087 return;
1088 }
1089 for (unsigned int i = 0; i < rd_count; i++)
1090 {
1091 if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
1092 {
1093 /* GNUNET_GNSRECORD_block_create will convert to absolute time;
1094 we just need to adjust our iteration frequency */
1096 GNUNET_MIN (rd[i].expiration_time,
1098 }
1099 }
1100
1101
1102 /* We got a set of records to publish */
1104 "Starting DHT PUT\n");
1105 put_cnt++;
1106 if (0 == put_cnt % DELTA_INTERVAL)
1109 label,
1110 rd,
1111 rd_count,
1112 expire);
1115}

References check_zone_namestore_next(), DELTA_INTERVAL, dispatch_job(), expire, GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_log, GNUNET_MIN, job_queue_length, key, min_relative_record_time, ns_iteration_left, put_cnt, rd, rd_count, GNUNET_TIME_Relative::rel_value_us, and update_velocity().

Referenced by publish_zone_dht_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dispatch_job_monitor()

static void dispatch_job_monitor ( const struct GNUNET_CRYPTO_PrivateKey key,
const char *  label,
const struct GNUNET_GNSRECORD_Data rd,
unsigned int  rd_count,
struct GNUNET_TIME_Absolute  expire 
)
static

Store GNS records in the DHT.

Parameters
keykey of the zone
labellabel to store under
rd_publicpublic record data
rd_public_countnumber of records in rd_public

Definition at line 1161 of file gnunet-service-zonemaster.c.

1166{
1167 struct GNUNET_GNSRECORD_Data rd_public[rd_count];
1168 struct GNUNET_GNSRECORD_Block *block;
1169 struct GNUNET_GNSRECORD_Block *block_priv;
1170 struct GNUNET_TIME_Absolute expire_pub;
1171 struct RecordPublicationJob *job;
1172 size_t block_size;
1173 unsigned int rd_public_count = 0;
1174 char *emsg;
1175
1176 if (GNUNET_OK !=
1178 rd,
1179 rd_count,
1180 rd_public,
1181 &rd_public_count,
1182 &expire_pub,
1184 &emsg))
1185 {
1187 "%s\n", emsg);
1188 GNUNET_free (emsg);
1189 }
1190
1192 expire_pub,
1193 label,
1194 rd_public,
1195 rd_public_count,
1196 &block));
1197 if (NULL == block)
1198 {
1199 GNUNET_break (0);
1200 return; /* whoops */
1201 }
1202 if (rd_count != rd_public_count)
1204 expire,
1205 label,
1206 rd,
1207 rd_count,
1208 &
1209 block_priv));
1210 else
1211 block_priv = block;
1213 GNUNET_assert (0 == pthread_mutex_lock (&sign_jobs_lock));
1215 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Public record count: %d\n",
1216 rd_public_count);
1217 job->have_public_records = (rd_public_count > 0);
1218 job->block = block;
1219 job->block_size = block_size;
1220 job->block_priv = block_priv;
1221 job->zone = *key;
1222 job->label = GNUNET_strdup (label);
1223 job->expire_pub = expire_pub;
1225 GNUNET_assert (0 == pthread_cond_signal (&sign_jobs_cond));
1226 GNUNET_assert (0 == pthread_mutex_unlock (&sign_jobs_lock));
1227}

References RecordPublicationJob::block, RecordPublicationJob::block_priv, RecordPublicationJob::block_size, expire, RecordPublicationJob::expire_pub, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_GNSRECORD_block_create_unsigned(), GNUNET_GNSRECORD_block_get_size(), GNUNET_GNSRECORD_FILTER_OMIT_PRIVATE, GNUNET_GNSRECORD_normalize_record_set(), GNUNET_log, GNUNET_new, GNUNET_OK, GNUNET_strdup, job, key, RecordPublicationJob::label, rd, rd_count, sign_jobs_cond, sign_jobs_head, sign_jobs_lock, and sign_jobs_tail.

Referenced by handle_monitor_event().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_monitor_event()

static void handle_monitor_event ( void *  cls,
const struct GNUNET_CRYPTO_PrivateKey zone,
const char *  label,
unsigned int  rd_count,
const struct GNUNET_GNSRECORD_Data rd,
struct GNUNET_TIME_Absolute  expire 
)
static

Process a record that was stored in the namestore (invoked by the monitor).

Parameters
clsclosure, NULL
zoneprivate key of the zone; NULL on disconnect
labellabel of the records; NULL on disconnect
rd_countnumber of entries in rd array, 0 if label was deleted
rdarray of records with data to store
expireexpiration of this record set

Definition at line 1242 of file gnunet-service-zonemaster.c.

1248{
1249 (void) cls;
1251 "Namestore monitor events received",
1252 1,
1253 GNUNET_NO);
1255 "Received %u records for label `%s' via namestore monitor\n",
1256 rd_count,
1257 label);
1258 if (0 == rd_count)
1259 {
1261 1);
1262 return; /* nothing to do */
1263 }
1265 label,
1266 rd,
1267 rd_count,
1268 expire);
1271 {
1273 "Job queue length exceeded (%u/%u). Halting monitor.\n",
1277 return;
1278 }
1280 1);
1281}

References dispatch_job_monitor(), expire, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_NAMESTORE_zone_monitor_next(), GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_YES, job_queue_length, JOB_QUEUE_LIMIT, RecordPublicationJob::label, monitor_halted, rd, rd_count, statistics, zmon, and RecordPublicationJob::zone.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_monitor_error()

static void handle_monitor_error ( void *  cls)
static

The zone monitor encountered an IPC error trying to to get in sync.

Restart from the beginning.

Parameters
clsNULL

Definition at line 1291 of file gnunet-service-zonemaster.c.

1292{
1293 (void) cls;
1295 "Namestore monitor errors encountered",
1296 1,
1297 GNUNET_NO);
1298}

References GNUNET_NO, GNUNET_STATISTICS_update(), and statistics.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sign_worker()

static void * sign_worker ( void *  cls)
static

Definition at line 1302 of file gnunet-service-zonemaster.c.

1303{
1304 struct RecordPublicationJob *job;
1305 const struct GNUNET_DISK_FileHandle *fh;
1306
1308 while (GNUNET_YES != in_shutdown)
1309 {
1310 GNUNET_assert (0 == pthread_mutex_lock (&sign_jobs_lock));
1311 while (NULL == sign_jobs_head)
1312 GNUNET_assert (0 == pthread_cond_wait (&sign_jobs_cond, &sign_jobs_lock));
1313 if (GNUNET_YES == in_shutdown)
1314 {
1315 GNUNET_assert (0 == pthread_mutex_unlock (&sign_jobs_lock));
1316 return NULL;
1317 }
1319 "Taking on Job for %s\n", sign_jobs_head->label);
1322 GNUNET_assert (0 == pthread_mutex_unlock (&sign_jobs_lock));
1323 GNUNET_GNSRECORD_block_sign (&job->zone, job->label, job->block);
1324 if (job->block != job->block_priv)
1325 GNUNET_GNSRECORD_block_sign (&job->zone, job->label, job->block_priv);
1326 GNUNET_assert (0 == pthread_mutex_lock (&sign_results_lock));
1328 GNUNET_assert (0 == pthread_mutex_unlock (&sign_results_lock));
1330 "Done, notifying main thread through pipe!\n");
1331 GNUNET_DISK_file_write (fh, "!", 1);
1332 }
1333 return NULL;
1334}

References GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_DLL_remove, GNUNET_DISK_file_write(), GNUNET_DISK_PIPE_END_WRITE, GNUNET_DISK_pipe_handle(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNSRECORD_block_sign(), GNUNET_log, GNUNET_YES, in_shutdown, job, RecordPublicationJob::label, notification_pipe, sign_jobs_cond, sign_jobs_head, sign_jobs_lock, sign_jobs_tail, sign_results_head, sign_results_lock, and sign_results_tail.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

static void run ( void *  cls,
const struct GNUNET_CONFIGURATION_Handle c,
struct GNUNET_SERVICE_Handle service 
)
static

Perform zonemaster duties: watch namestore, publish records.

Parameters
clsclosure
serverthe initialized server
cconfiguration to use

Start worker

Definition at line 1354 of file gnunet-service-zonemaster.c.

1357{
1358 unsigned long long max_parallel_bg_queries = 128;
1359 const struct GNUNET_DISK_FileHandle *np_fh;
1360
1361 (void) cls;
1362 (void) service;
1363 pthread_mutex_init (&sign_jobs_lock, NULL);
1364 pthread_mutex_init (&sign_results_lock, NULL);
1365 pthread_cond_init (&sign_jobs_cond, NULL);
1366 last_put_100 = GNUNET_TIME_absolute_get (); /* first time! */
1371 if (NULL == namestore_handle)
1372 {
1374 _ ("Failed to connect to the namestore!\n"));
1376 return;
1377 }
1379 "namecache",
1380 "DISABLE");
1382 {
1384 if (NULL == namecache)
1385 {
1387 _ ("Failed to connect to the namecache!\n"));
1389 return;
1390 }
1391 }
1393 "namestore",
1394 "CACHE_KEYS");
1396 if (GNUNET_OK ==
1398 "zonemaster",
1399 "ZONE_PUBLISH_TIME_WINDOW",
1401 {
1403 "Time window for zone iteration: %s\n",
1406 GNUNET_YES));
1407 }
1409 if (GNUNET_OK ==
1411 "zonemaster",
1412 "MAX_PARALLEL_BACKGROUND_QUERIES",
1413 &max_parallel_bg_queries))
1414 {
1416 "Number of allowed parallel background queries: %llu\n",
1417 max_parallel_bg_queries);
1418 }
1419 if (0 == max_parallel_bg_queries)
1420 max_parallel_bg_queries = 1;
1422 (unsigned int) max_parallel_bg_queries);
1423 if (NULL == dht_handle)
1424 {
1426 _ ("Could not connect to DHT!\n"));
1428 NULL);
1429 return;
1430 }
1431
1432 /* Schedule periodic put for our records. */
1434 statistics = GNUNET_STATISTICS_create ("zonemaster",
1435 c);
1437 "Target zone iteration velocity (μs)",
1439 GNUNET_NO);
1441 NULL);
1443 NULL,
1444 GNUNET_NO,
1446 NULL,
1448 NULL,
1449 NULL /* sync_cb */,
1450 NULL,
1454 GNUNET_break (NULL != zmon);
1455
1457 NULL);
1458
1460 np_fh = GNUNET_DISK_pipe_handle (
1464 np_fh,
1465 notification_pipe_cb, NULL);
1466
1467 {
1468 long long unsigned int worker_count = 1;
1469 if (GNUNET_OK !=
1471 "zonemaster",
1472 "WORKER_COUNT",
1473 &worker_count))
1474 {
1476 "Number of workers not defined falling back to 1\n");
1477 }
1478 worker = GNUNET_malloc (sizeof (pthread_t) * worker_count);
1480 for (int i = 0; i < worker_count; i++)
1481 {
1482 if (0 !=
1483 pthread_create (&worker[i],
1484 NULL,
1485 &sign_worker,
1486 NULL))
1487 {
1489 "pthread_create");
1491 }
1493 "Workers running",
1494 1,
1495 GNUNET_NO);
1496 }
1497 }
1498}

References _, cache_keys, dht_handle, disable_namecache, first_zone_iteration, GNUNET_break, GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_time(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_DHT_connect(), GNUNET_DHT_DEFAULT_REPUBLISH_FREQUENCY, GNUNET_DISK_PF_NONE, GNUNET_DISK_pipe(), GNUNET_DISK_PIPE_END_READ, GNUNET_DISK_pipe_handle(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_GNSRECORD_FILTER_NONE, GNUNET_log, GNUNET_log_strerror, GNUNET_malloc, GNUNET_NAMECACHE_connect(), GNUNET_NAMESTORE_connect(), GNUNET_NAMESTORE_zone_monitor_next(), GNUNET_NAMESTORE_zone_monitor_start2(), GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_read_file(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_STATISTICS_create(), GNUNET_STATISTICS_set(), GNUNET_STATISTICS_update(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, handle_monitor_error(), handle_monitor_event(), INITIAL_ZONE_ITERATION_INTERVAL, last_put_100, min_relative_record_time, namecache, namestore_handle, NAMESTORE_MONITOR_QUEUE_LIMIT, notification_pipe, notification_pipe_cb(), pipe_read_task, publish_zone_dht_start(), GNUNET_TIME_Relative::rel_value_us, service, shutdown_task, sign_jobs_cond, sign_jobs_lock, sign_results_lock, sign_worker(), statistics, target_iteration_velocity_per_record, worker, zmon, zone_publish_task, zone_publish_time_window, and zone_publish_time_window_default.

Here is the call graph for this function:

◆ GNUNET_SERVICE_MAIN()

GNUNET_SERVICE_MAIN ( GNUNET_OS_project_data_gnunet()  ,
"zonemaster"  ,
GNUNET_SERVICE_OPTION_NONE  ,
run,
NULL  ,
NULL  ,
NULL  ,
GNUNET_MQ_handler_end()   
)

Define "main" method using service macro.

Variable Documentation

◆ worker

pthread_t* worker
static

Our workers.

Definition at line 96 of file gnunet-service-zonemaster.c.

Referenced by run().

◆ sign_jobs_lock

pthread_mutex_t sign_jobs_lock
static

Lock for the sign jobs queue.

Definition at line 101 of file gnunet-service-zonemaster.c.

Referenced by dispatch_job(), dispatch_job_monitor(), run(), shutdown_task(), and sign_worker().

◆ sign_results_lock

pthread_mutex_t sign_results_lock
static

Lock for the DHT put jobs queue.

Definition at line 106 of file gnunet-service-zonemaster.c.

Referenced by initiate_put_from_pipe_trigger(), run(), shutdown_task(), and sign_worker().

◆ sign_jobs_cond

pthread_cond_t sign_jobs_cond
static

Wait condition on new sign jobs.

Definition at line 111 of file gnunet-service-zonemaster.c.

Referenced by dispatch_job(), dispatch_job_monitor(), run(), and sign_worker().

◆ in_shutdown

int in_shutdown = GNUNET_NO
static

For threads to know we are shutting down.

Definition at line 116 of file gnunet-service-zonemaster.c.

Referenced by shutdown_task(), and sign_worker().

◆ monitor_halted

int monitor_halted = GNUNET_NO
static

Monitor halted?

Definition at line 121 of file gnunet-service-zonemaster.c.

Referenced by cleanup_job(), and handle_monitor_event().

◆ notification_pipe

struct GNUNET_DISK_PipeHandle* notification_pipe
static

Our notification pipe.

Definition at line 126 of file gnunet-service-zonemaster.c.

Referenced by initiate_put_from_pipe_trigger(), run(), shutdown_task(), and sign_worker().

◆ pipe_read_task

struct GNUNET_SCHEDULER_Task* pipe_read_task
static

Pipe read task.

Definition at line 131 of file gnunet-service-zonemaster.c.

Referenced by initiate_put_from_pipe_trigger(), run(), and shutdown_task().

◆ sign_jobs_head

struct RecordPublicationJob* sign_jobs_head
static

The DLL for workers to retrieve open jobs that require signing of blocks.

Definition at line 198 of file gnunet-service-zonemaster.c.

Referenced by dispatch_job(), dispatch_job_monitor(), shutdown_task(), and sign_worker().

◆ sign_jobs_tail

struct RecordPublicationJob* sign_jobs_tail
static

See above.

Definition at line 203 of file gnunet-service-zonemaster.c.

Referenced by dispatch_job(), dispatch_job_monitor(), shutdown_task(), and sign_worker().

◆ sign_results_head

struct RecordPublicationJob* sign_results_head
static

The DLL for workers to place jobs that are signed.

Definition at line 208 of file gnunet-service-zonemaster.c.

Referenced by initiate_put_from_pipe_trigger(), shutdown_task(), and sign_worker().

◆ sign_results_tail

struct RecordPublicationJob* sign_results_tail
static

See above.

Definition at line 213 of file gnunet-service-zonemaster.c.

Referenced by initiate_put_from_pipe_trigger(), shutdown_task(), and sign_worker().

◆ dht_jobs_head

struct RecordPublicationJob* dht_jobs_head
static

The DLL for jobs currently in the process of being dispatched into the DHT.

Definition at line 219 of file gnunet-service-zonemaster.c.

Referenced by dht_put_continuation(), initiate_put_from_pipe_trigger(), and shutdown_task().

◆ dht_jobs_tail

struct RecordPublicationJob* dht_jobs_tail
static

See above.

Definition at line 224 of file gnunet-service-zonemaster.c.

Referenced by dht_put_continuation(), initiate_put_from_pipe_trigger(), and shutdown_task().

◆ statistics

◆ dht_handle

struct GNUNET_DHT_Handle* dht_handle
static

Our handle to the DHT.

Definition at line 258 of file gnunet-service-zonemaster.c.

Referenced by initiate_put_from_pipe_trigger(), run(), and shutdown_task().

◆ namestore_handle

struct GNUNET_NAMESTORE_Handle* namestore_handle
static

Our handle to the namestore service.

Definition at line 263 of file gnunet-service-zonemaster.c.

Referenced by publish_zone_dht_start(), run(), and shutdown_task().

◆ zmon

struct GNUNET_NAMESTORE_ZoneMonitor* zmon
static

Handle to monitor namestore changes to instant propagation.

Definition at line 268 of file gnunet-service-zonemaster.c.

Referenced by cleanup_job(), handle_monitor_event(), run(), and shutdown_task().

◆ namecache

struct GNUNET_NAMECACHE_Handle* namecache
static

Our handle to the namecache service.

Definition at line 273 of file gnunet-service-zonemaster.c.

Referenced by refresh_block(), run(), and shutdown_task().

◆ disable_namecache

int disable_namecache
static

Use the namecache? Doing so creates additional cryptographic operations whenever we touch a record.

Definition at line 279 of file gnunet-service-zonemaster.c.

Referenced by refresh_block(), and run().

◆ namestore_iter

struct GNUNET_NAMESTORE_ZoneIterator* namestore_iter
static

Handle to iterate over our authoritative zone in namestore.

Definition at line 284 of file gnunet-service-zonemaster.c.

Referenced by publish_zone_dht_start(), publish_zone_namestore_next(), shutdown_task(), zone_iteration_error(), and zone_iteration_finished().

◆ job_queue_length

unsigned int job_queue_length
static

Number of entries in the job queue #jobs_head.

Definition at line 289 of file gnunet-service-zonemaster.c.

Referenced by check_zone_namestore_next(), cleanup_job(), dht_put_continuation(), handle_monitor_event(), handle_record(), shutdown_task(), and update_velocity().

◆ num_public_records

unsigned long long num_public_records
static

Useful for zone update for DHT put.

Definition at line 294 of file gnunet-service-zonemaster.c.

Referenced by calculate_put_interval(), dispatch_job(), publish_zone_dht_start(), update_velocity(), and zone_iteration_finished().

◆ last_num_public_records

unsigned long long last_num_public_records
static

Last seen record count.

Definition at line 299 of file gnunet-service-zonemaster.c.

Referenced by calculate_put_interval(), update_velocity(), and zone_iteration_finished().

◆ put_cnt

unsigned long long put_cnt
static

Number of successful put operations performed in the current measurement cycle (as measured in check_zone_namestore_next()).

Definition at line 305 of file gnunet-service-zonemaster.c.

Referenced by check_zone_namestore_next(), and handle_record().

◆ target_iteration_velocity_per_record

struct GNUNET_TIME_Relative target_iteration_velocity_per_record
static

What is the frequency at which we currently would like to perform DHT puts (per record)? Calculated in update_velocity() from the zone_publish_time_window() and the total number of record sets we have (so far) observed in the zone.

Definition at line 314 of file gnunet-service-zonemaster.c.

Referenced by calculate_put_interval(), check_zone_namestore_next(), run(), update_velocity(), and zone_iteration_finished().

◆ min_relative_record_time

struct GNUNET_TIME_Relative min_relative_record_time
static

Minimum relative expiration time of records seem during the current zone iteration.

Definition at line 320 of file gnunet-service-zonemaster.c.

Referenced by calculate_put_interval(), handle_record(), run(), and zone_iteration_finished().

◆ last_min_relative_record_time

struct GNUNET_TIME_Relative last_min_relative_record_time
static

Minimum relative expiration time of records seem during the last zone iteration.

Definition at line 326 of file gnunet-service-zonemaster.c.

Referenced by calculate_put_interval(), and zone_iteration_finished().

◆ zone_publish_time_window_default

struct GNUNET_TIME_Relative zone_publish_time_window_default
static

Default time window for zone iteration.

Definition at line 331 of file gnunet-service-zonemaster.c.

Referenced by calculate_put_interval(), and run().

◆ zone_publish_time_window

struct GNUNET_TIME_Relative zone_publish_time_window
static

Time window for zone iteration, adjusted based on relative record expiration times in our zone.

Definition at line 337 of file gnunet-service-zonemaster.c.

Referenced by calculate_put_interval(), and run().

◆ last_put_100

struct GNUNET_TIME_Absolute last_put_100
static

When did we last start measuring the DELTA_INTERVAL successful DHT puts? Used for velocity calculations.

Definition at line 343 of file gnunet-service-zonemaster.c.

Referenced by run(), and update_velocity().

◆ sub_delta

struct GNUNET_TIME_Relative sub_delta
static

By how much should we try to increase our per-record iteration speed (over the desired speed calculated directly from the #put_interval)? Basically this value corresponds to the per-record CPU time overhead we have.

Definition at line 351 of file gnunet-service-zonemaster.c.

Referenced by check_zone_namestore_next(), and update_velocity().

◆ zone_publish_task

◆ ns_iteration_left

unsigned int ns_iteration_left
static

How many more values are left for the current query before we need to explicitly ask the namestore for more?

Definition at line 362 of file gnunet-service-zonemaster.c.

Referenced by check_zone_namestore_next(), handle_record(), publish_zone_dht_start(), and publish_zone_namestore_next().

◆ first_zone_iteration

int first_zone_iteration
static

GNUNET_YES if zone has never been published before

Definition at line 367 of file gnunet-service-zonemaster.c.

Referenced by check_zone_namestore_next(), run(), update_velocity(), and zone_iteration_finished().

◆ cache_keys

int cache_keys
static

Optimize block insertion by caching map of private keys to public keys in memory?

Definition at line 373 of file gnunet-service-zonemaster.c.

Referenced by run().

◆ cop_head

struct CacheOperation* cop_head
static

Head of cop DLL.

Definition at line 378 of file gnunet-service-zonemaster.c.

Referenced by finish_cache_operation(), refresh_block(), and shutdown_task().

◆ cop_tail

struct CacheOperation* cop_tail
static

Tail of cop DLL.

Definition at line 383 of file gnunet-service-zonemaster.c.

Referenced by finish_cache_operation(), refresh_block(), and shutdown_task().