GNUnet 0.28.0-dev.3-7-g31e20e2e6
 
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_BlindablePrivateKey *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_BlindablePrivateKey *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_BlindablePrivateKey *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_BlindablePrivateKey *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
149
153 struct GNUNET_GNSRECORD_Block *block_pub;
154
158 struct GNUNET_GNSRECORD_Block *block_priv;
159
163 unsigned char *rdata_pub;
164
169 unsigned char *rdata_priv;
170
174 size_t rdata_pub_len;
175
179 size_t rdata_priv_len;
180
184 struct GNUNET_TIME_Absolute expire_pub;
185
189 struct GNUNET_TIME_Absolute expire_priv;
190
194 char *label;
195
199 struct GNUNET_DHT_PutHandle *ph;
200
204 struct GNUNET_TIME_Absolute start_date;
205
210
214 int have_public_records;
215};
216
217
223
228
233
238
239
244
249
250
254struct CacheOperation
255{
259 struct CacheOperation *prev;
260
264 struct CacheOperation *next;
265
270
271};
272
273
278
282static struct GNUNET_DHT_Handle *dht_handle;
283
288
293
298
303static int disable_namecache;
304
309
313static unsigned int job_queue_length;
314
318static unsigned long long num_public_records;
319
323static unsigned long long last_num_public_records;
324
329static unsigned long long put_cnt;
330
339
345
351
356
362
368
375static struct GNUNET_TIME_Relative sub_delta;
376
381
386static unsigned int ns_iteration_left;
387
391static int first_zone_iteration;
392
397static int cache_keys;
398
402static struct CacheOperation *cop_head;
403
407static struct CacheOperation *cop_tail;
408
409
410static void
412{
413 if (job->rdata_pub != job->rdata_priv)
414 GNUNET_free (job->rdata_priv);
415 GNUNET_free (job->rdata_pub);
416 if (job->block_pub != job->block_priv)
417 GNUNET_free (job->block_priv);
418 GNUNET_free (job->block_pub);
419 if (NULL != job->label)
420 GNUNET_free (job->label);
421 if (NULL != job->ec)
422 {
424 job->ec = NULL;
425 }
427}
428
429
436static void
437shutdown_task (void *cls)
438{
439 struct CacheOperation *cop;
441
442 (void) cls;
445 "Shutting down!\n");
446 if (NULL != notification_pipe)
448 if (NULL != pipe_read_task)
450 while (NULL != (cop = cop_head))
451 {
453 "Aborting incomplete namecache operation\n");
456 GNUNET_free (cop);
457 }
458 GNUNET_assert (0 == pthread_mutex_lock (&sign_jobs_lock));
459 while (NULL != (job = sign_jobs_head))
460 {
462 "Removing incomplete jobs\n");
465 free_job (job);
466 }
467 GNUNET_assert (0 == pthread_mutex_unlock (&sign_jobs_lock));
468 GNUNET_assert (0 == pthread_mutex_lock (&sign_results_lock));
469 while (NULL != (job = sign_results_head))
470 {
472 "Removing incomplete jobs\n");
474 free_job (job);
475 }
476 GNUNET_assert (0 == pthread_mutex_unlock (&sign_results_lock));
477 while (NULL != (job = dht_jobs_head))
478 {
480 "Removing incomplete jobs\n");
482 if (NULL != job->ph)
484 free_job (job);
485 }
486 if (NULL != statistics)
487 {
489 GNUNET_NO);
490 statistics = NULL;
491 }
492 if (NULL != zone_publish_task)
493 {
495 zone_publish_task = NULL;
496 }
497 if (NULL != namestore_iter)
498 {
500 namestore_iter = NULL;
501 }
502 if (NULL != zmon)
503 {
505 zmon = NULL;
506 }
507 if (NULL != namestore_handle)
508 {
510 namestore_handle = NULL;
511 }
512 if (NULL != namecache)
513 {
515 namecache = NULL;
516 }
517 if (NULL != dht_handle)
518 {
520 dht_handle = NULL;
521 }
522}
523
524
532static void
533finish_cache_operation (void *cls, int32_t success, const char *emsg)
534{
535 struct CacheOperation *cop = cls;
536
537 if (NULL != emsg)
539 _ ("Failed to replicate block in namecache: %s\n"),
540 emsg);
541 else
542 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "CACHE operation completed\n");
544 GNUNET_free (cop);
545}
546
547
556static void
557refresh_block (const struct GNUNET_GNSRECORD_Block *block)
558{
559 struct CacheOperation *cop;
560
562 {
564 "Namecache updates skipped (NC disabled)",
565 1,
566 GNUNET_NO);
567 return;
568 }
569 GNUNET_assert (NULL != block);
570 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Caching block in namecache\n");
572 "Namecache updates pushed",
573 1,
574 GNUNET_NO);
575 cop = GNUNET_new (struct CacheOperation);
578 block,
580 cop);
581}
582
583
589static void
591{
592 (void) cls;
593 zone_publish_task = NULL;
599}
600
601
607static void
608publish_zone_dht_start (void *cls);
609
610
614static void
616{
617 if (0 == num_public_records)
618 {
target_iteration_velocity_per_record = zone_publish_time_window;
625 "No records in namestore database.\n");
626 }
627 else
628 {
640 }
645 "Minimum relative record expiration (in μs)",
647 GNUNET_NO);
649 "Zone publication time window (in μs)",
651 GNUNET_NO);
653 "Target zone iteration velocity (μs)",
655 GNUNET_NO);
656}
657
658
666static void
667update_velocity (unsigned int cnt)
668{
670 unsigned long long pct = 0;
671
672 if (0 == cnt)
673 return;
674 /* How fast were we really? */
676 delta.rel_value_us /= cnt;
678
679 /* calculate expected frequency */
682 {
684 "Last record count was lower than current record count. Reducing interval.\n");
688 }
690 "Desired global zone iteration interval is %s/record!\n",
693 GNUNET_YES));
694
695 /* Tell statistics actual vs. desired speed */
697 "Current zone iteration velocity (μs/record)",
699 GNUNET_NO);
700 /* update "sub_delta" based on difference, taking
701 previous sub_delta into account! */
703 {
704 /* We were too fast, reduce sub_delta! */
705 struct GNUNET_TIME_Relative corr;
706
708 delta);
710 {
711 /* Reduce sub_delta by corr */
713 corr);
714 }
715 else
716 {
717 /* We're doing fine with waiting the full time, this
718 should theoretically only happen if we run at
719 infinite speed. */
721 }
722 }
725 {
726 /* We were too slow, increase sub_delta! */
727 struct GNUNET_TIME_Relative corr;
728
732 corr);
735 {
736 /* CPU overload detected, we cannot go at desired speed,
737 as this would mean using a negative delay. */
738 /* compute how much faster we would want to be for
739 the desired velocity */
741 pct = UINT64_MAX; /* desired speed is infinity ... */
742 else
747 }
748 }
750 "# dispatched jobs",
752 GNUNET_NO);
754 "% speed increase needed for target velocity",
755 pct,
756 GNUNET_NO);
758 "# records processed in current iteration",
760 GNUNET_NO);
761}
762
763
768static void
770{
771 struct GNUNET_TIME_Relative delay;
772
773 if (0 != ns_iteration_left)
774 return; /* current NAMESTORE iteration not yet done */
776 {
778 "Job queue length exceeded (%u/%u). Pausing namestore iteration.\n",
781 return;
782 }
784 put_cnt = 0;
786 sub_delta);
787 /* We delay *once* per #NS_BLOCK_SIZE, so we need to multiply the
788 per-record delay calculated so far with the #NS_BLOCK_SIZE */
790 "Current artificial NAMESTORE delay (μs/record)",
791 delay.rel_value_us,
792 GNUNET_NO);
793 delay = GNUNET_TIME_relative_multiply (delay,
795 /* make sure we do not overshoot because of the #NS_BLOCK_SIZE factor */
797 delay);
798 /* no delays on first iteration */
800 delay = GNUNET_TIME_UNIT_ZERO;
804 ,
805 NULL);
806}
807
808
809static void
811{
812
813 if (NULL == zone_publish_task)
816 {
818 {
820 "Job queue emptied (%u/%u). Resuming monitor.\n",
825 }
826 }
828 free_job (job);
829}
830
831
836static void
837dht_put_continuation (void *cls)
838{
839 struct RecordPublicationJob *job = cls;
840
842 "PUT complete; Pending jobs: %u\n", job_queue_length - 1);
843 /* When we just fall under the limit, trigger monitor/iterator again
844 * if halted. We can only safely trigger one, prefer iterator. */
847 job);
849}
850
851
862static void
864 const char *label,
865 const struct GNUNET_GNSRECORD_Data *rd,
866 unsigned int rd_count,
867 const struct GNUNET_TIME_Absolute expire)
868{
869 struct GNUNET_GNSRECORD_Data rd_public[rd_count];
870 struct GNUNET_TIME_Absolute expire_pub;
872 unsigned char *rdata_public;
873 unsigned char *rdata_priv;
874 size_t rdata_public_len;
875 size_t rdata_private_len;
876 unsigned int rd_public_count = 0;
877 char *emsg;
878
879 if (GNUNET_OK !=
881 rd,
882 rd_count,
883 rd_public,
884 &rd_public_count,
885 &expire_pub,
887 &emsg))
888 {
890 "%s\n", emsg);
891 GNUNET_free (emsg);
892 }
893
894 rdata_public_len = GNUNET_GNSRECORD_records_get_size (rd_public_count,
895 rd_public);
896
897 rdata_private_len = GNUNET_GNSRECORD_records_get_size (rd_count,
898 rd);
899
900 rdata_public = GNUNET_malloc (rdata_public_len);
902 rd_public_count,
903 rd_public,
904 rdata_public,
905 rdata_public_len));
906 if (rd_count != rd_public_count)
907 {
908 rdata_priv = GNUNET_malloc (rdata_private_len);
910 rd_count,
911 rd,
913 rdata_private_len));
914 }
915 else
916 {
917 rdata_priv = rdata_public;
918 }
919 GNUNET_assert (0 == pthread_mutex_lock (&sign_jobs_lock));
921 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Public record count: %d\n",
922 rd_public_count);
923 job->have_public_records = (rd_public_count > 0);
924 job->rdata_pub = rdata_public;
925 job->rdata_pub_len = rdata_public_len;
926 job->rdata_priv = rdata_priv;
927 job->rdata_priv_len = rdata_private_len;
928 job->zone = *key;
929 job->label = GNUNET_strdup (label);
930 job->expire_pub = expire_pub;
931 job->expire_priv = expire;
934 GNUNET_assert (0 == pthread_cond_signal (&sign_jobs_cond));
935 GNUNET_assert (0 == pthread_mutex_unlock (&sign_jobs_lock));
937 "Creating job with %u record(s) for label `%s', expiration `%s'\n",
938 rd_public_count,
939 label,
942 return;
943}
944
945
946static void
947notification_pipe_cb (void *cls);
948
949static void
951{
952 struct GNUNET_HashCode query;
954 const struct GNUNET_DISK_FileHandle *np_fh;
955 char buf[100];
956 ssize_t nf_count;
957
958 pipe_read_task = NULL;
964 np_fh,
966 NULL);
967 /* empty queue */
968 nf_count = GNUNET_DISK_file_read (np_fh, buf, sizeof (buf));
969 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Read %lld notifications from pipe\n",
970 (long long) nf_count);
971 while (true)
972 {
973 GNUNET_assert (0 == pthread_mutex_lock (&sign_results_lock));
974 if (NULL == sign_results_head)
975 {
977 "No more results. Back to sleep.\n");
978 GNUNET_assert (0 == pthread_mutex_unlock (&sign_results_lock));
979 return;
980 }
983 GNUNET_assert (0 == pthread_mutex_unlock (&sign_results_lock));
985 job->label,
986 &query);
987 // It is possible that the public block size is 0 (no public blocks)
988 // Do not bother with the DHT in that case
989 if (job->have_public_records)
990 {
991 size_t block_size = GNUNET_GNSRECORD_block_get_size (job->block_pub);
993 &query,
997 block_size,
998 job->block_pub,
999 job->expire_pub,
1001 job);
1002 if (NULL == job->ph)
1003 {
1005 "Could not perform DHT PUT, is the DHT running?\n");
1006 free_job (job);
1007 return;
1008 }
1010 "DHT put operations initiated",
1011 1,
1012 GNUNET_NO);
1014 "Storing record(s) for label `%s' in DHT under key %s\n",
1015 job->label,
1016 GNUNET_h2s (&query));
1017 refresh_block (job->block_priv);
1019 }
1020 else
1021 {
1022 // Private blocks may still be available and must be updated
1023 // in the cache
1024 refresh_block (job->block_priv);
1025 cleanup_job (job);
1026 }
1027 }
1028}
1029
1030
1036static void
1037zone_iteration_error (void *cls)
1038{
1039 (void) cls;
1041 "Got disconnected from namestore database, retrying.\n");
1042 namestore_iter = NULL;
1043 /* We end up here on error/disconnect/shutdown, so potentially
1044 while a zone publish task or a DHT put is still running; hence
1045 we need to cancel those. */
1046 if (NULL != zone_publish_task)
1047 {
1049 zone_publish_task = NULL;
1050 }
1052 NULL);
1053}
1054
1055
1061static void
1062zone_iteration_finished (void *cls)
1063{
1064 (void) cls;
1065 /* we're done with one iteration, calculate when to do the next one */
1066 namestore_iter = NULL;
1071 /* reset for next iteration */
1075 "Zone iteration finished. Adjusted zone iteration interval to %s\n",
1078 GNUNET_YES));
1080 "Target zone iteration velocity (μs)",
1082 GNUNET_NO);
1084 "Number of public records in DHT",
1086 GNUNET_NO);
1088 if (0 == last_num_public_records)
1089 {
1093 NULL);
1094 }
1095 else
1096 {
1098 NULL);
1099 }
1100}
1101
1102
1112static void
1113handle_record (void *cls,
1115 const char *label,
1116 unsigned int rd_count,
1117 const struct GNUNET_GNSRECORD_Data *rd,
1119{
1120 (void) cls;
1122 if (0 == rd_count)
1123 {
1125 "Record set empty, moving to next record set\n");
1127 return;
1128 }
1129 for (unsigned int i = 0; i < rd_count; i++)
1130 {
1131 if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
1132 {
1133 /* GNUNET_GNSRECORD_block_create will convert to absolute time;
1134 we just need to adjust our iteration frequency */
1136 GNUNET_MIN (rd[i].expiration_time,
1138 }
1139 }
1140
1141
1142 /* We got a set of records to publish */
1144 "Starting DHT PUT\n");
1145 put_cnt++;
1146 if (0 == put_cnt % DELTA_INTERVAL)
1149 label,
1150 rd,
1151 rd_count,
1152 expire);
1155}
1156
1157
1163static void
1164publish_zone_dht_start (void *cls)
1165{
1166 (void) cls;
1167 zone_publish_task = NULL;
1169 "Full zone iterations launched",
1170 1,
1171 GNUNET_NO);
1173 "Starting DHT zone update!\n");
1174 /* start counting again */
1176 GNUNET_assert (NULL == namestore_iter);
1180 NULL, /* All zones */
1182 NULL,
1184 NULL,
1186 NULL,
1188 GNUNET_assert (NULL != namestore_iter);
1189}
1190
1191
1200static void
1202 const char *label,
1203 const struct GNUNET_GNSRECORD_Data *rd,
1204 unsigned int rd_count,
1206{
1207 dispatch_job (key, label, rd, rd_count, expire);
1208}
1209
1210
1222static void
1223handle_monitor_event (void *cls,
1224 const struct GNUNET_CRYPTO_BlindablePrivateKey *zone,
1225 const char *label,
1226 unsigned int rd_count,
1227 const struct GNUNET_GNSRECORD_Data *rd,
1229{
1230 (void) cls;
1232 "Namestore monitor events received",
1233 1,
1234 GNUNET_NO);
1236 "Received %u records for label `%s' via namestore monitor\n",
1237 rd_count,
1238 label);
1239 if (0 == rd_count)
1240 {
1242 1);
1243 return; /* nothing to do */
1244 }
1246 label,
1247 rd,
1248 rd_count,
1249 expire);
1252 {
1254 "Job queue length exceeded (%u/%u). Halting monitor.\n",
1258 return;
1259 }
1261 1);
1262}
1263
1264
1271static void
1272handle_monitor_error (void *cls)
1273{
1274 (void) cls;
1276 "Namestore monitor errors encountered",
1277 1,
1278 GNUNET_NO);
1279}
1280
1281
1282static void*
1283sign_worker (void *cls)
1284{
1285 struct RecordPublicationJob *job;
1286 const struct GNUNET_DISK_FileHandle *fh;
1287
1289 while (GNUNET_YES != in_shutdown)
1290 {
1291 GNUNET_assert (0 == pthread_mutex_lock (&sign_jobs_lock));
1292 while (NULL == sign_jobs_head)
1293 GNUNET_assert (0 == pthread_cond_wait (&sign_jobs_cond, &sign_jobs_lock));
1294 if (GNUNET_YES == in_shutdown)
1295 {
1296 GNUNET_assert (0 == pthread_mutex_unlock (&sign_jobs_lock));
1297 return NULL;
1298 }
1300 "Taking on Job for %s\n", sign_jobs_head->label);
1303 GNUNET_assert (0 == pthread_mutex_unlock (&sign_jobs_lock));
1304 job->ec->seal (job->ec->cls,
1305 job->label,
1306 job->expire_pub,
1307 job->rdata_pub,
1308 job->rdata_pub_len,
1309 &job->block_pub);
1310 if (job->rdata_pub != job->rdata_priv)
1311 job->ec->seal (job->ec->cls,
1312 job->label,
1313 job->expire_priv,
1314 job->rdata_priv,
1315 job->rdata_priv_len,
1316 &job->block_priv);
1317 else
1318 job->block_priv = job->block_pub;
1319 GNUNET_assert (0 == pthread_mutex_lock (&sign_results_lock));
1321 GNUNET_assert (0 == pthread_mutex_unlock (&sign_results_lock));
1323 "Done, notifying main thread through pipe!\n");
1324 GNUNET_DISK_file_write (fh, "!", 1);
1325 }
1326 return NULL;
1327}
1328
1329
1330static void
1331notification_pipe_cb (void *cls)
1332{
1334 "Received wake up notification through pipe, checking results\n");
1336}
1337
1338
1346static void
1347run (void *cls,
1348 const struct GNUNET_CONFIGURATION_Handle *c,
1350{
1351 unsigned long long max_parallel_bg_queries = 128;
1352 const struct GNUNET_DISK_FileHandle *np_fh;
1353
1354 (void) cls;
1355 (void) service;
1356 pthread_mutex_init (&sign_jobs_lock, NULL);
1357 pthread_mutex_init (&sign_results_lock, NULL);
1358 pthread_cond_init (&sign_jobs_cond, NULL);
1359 last_put_100 = GNUNET_TIME_absolute_get (); /* first time! */
1364 if (NULL == namestore_handle)
1365 {
1367 _ ("Failed to connect to the namestore!\n"));
1369 return;
1370 }
1372 "namecache",
1373 "DISABLE");
1375 {
1377 if (NULL == namecache)
1378 {
1380 _ ("Failed to connect to the namecache!\n"));
1382 return;
1383 }
1384 }
1386 "namestore",
1387 "CACHE_KEYS");
1389 if (GNUNET_OK ==
1391 "zonemaster",
1392 "ZONE_PUBLISH_TIME_WINDOW",
1394 {
1396 "Time window for zone iteration: %s\n",
1399 GNUNET_YES));
1400 }
1402 if (GNUNET_OK ==
1404 "zonemaster",
1405 "MAX_PARALLEL_BACKGROUND_QUERIES",
1406 &max_parallel_bg_queries))
1407 {
1409 "Number of allowed parallel background queries: %llu\n",
1410 max_parallel_bg_queries);
1411 }
1412 if (0 == max_parallel_bg_queries)
1413 max_parallel_bg_queries = 1;
1415 (unsigned int) max_parallel_bg_queries);
1416 if (NULL == dht_handle)
1417 {
1419 _ ("Could not connect to DHT!\n"));
1421 NULL);
1422 return;
1423 }
1424
1425 /* Schedule periodic put for our records. */
1427 statistics = GNUNET_STATISTICS_create ("zonemaster",
1428 c);
1430 "Target zone iteration velocity (μs)",
1432 GNUNET_NO);
1434 NULL);
1436 NULL,
1437 GNUNET_NO,
1439 NULL,
1441 NULL,
1442 NULL /* sync_cb */,
1443 NULL,
1447 GNUNET_break (NULL != zmon);
1448
1450 NULL);
1451
1453 np_fh = GNUNET_DISK_pipe_handle (
1457 np_fh,
1458 notification_pipe_cb, NULL);
1459
1460 {
1461 long long unsigned int worker_count = 1;
1462 if (GNUNET_OK !=
1464 "zonemaster",
1465 "WORKER_COUNT",
1466 &worker_count))
1467 {
1469 "Number of workers not defined falling back to 1\n");
1470 }
1471 worker = GNUNET_malloc (sizeof (pthread_t) * worker_count);
1473 for (int i = 0; i < worker_count; i++)
1474 {
1475 if (0 !=
1476 pthread_create (&worker[i],
1477 NULL,
1478 &sign_worker,
1479 NULL))
1480 {
1482 "pthread_create");
1484 }
1486 "Workers running",
1487 1,
1488 GNUNET_NO);
1489 }
1490 }
1491}
1492
1493
1499 "zonemaster",
1501 &run,
1502 NULL,
1503 NULL,
1504 NULL,
1506
1507
1508/* 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 handle_record(void *cls, const struct GNUNET_CRYPTO_BlindablePrivateKey *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 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 void dispatch_job_monitor(const struct GNUNET_CRYPTO_BlindablePrivateKey *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 unsigned int job_queue_length
Number of entries in the job queue #jobs_head.
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 dispatch_job(const struct GNUNET_CRYPTO_BlindablePrivateKey *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 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 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.
static void handle_monitor_event(void *cls, const struct GNUNET_CRYPTO_BlindablePrivateKey *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).
#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 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.
#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:1149
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:1086
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:1036
#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:1058
@ 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:1703
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:745
struct GNUNET_DISK_PipeHandle * GNUNET_DISK_pipe(enum GNUNET_DISK_PipeFlags pf)
Creates an interprocess channel.
Definition disk.c:1524
enum GNUNET_GenericReturnValue GNUNET_DISK_pipe_close(struct GNUNET_DISK_PipeHandle *p)
Closes an interprocess channel.
Definition disk.c:1671
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:704
@ 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.
void GNUNET_GNSRECORD_query_from_private_key(const struct GNUNET_CRYPTO_BlindablePrivateKey *zone, const char *label, struct GNUNET_HashCode *query)
Calculate the DHT query for a given label in a given zone.
void GNUNET_GNSRECORD_encryption_context_destroy(struct GNUNET_GNSRECORD_EncryptionContext *ec)
Cleanup and free the encryption context.
size_t GNUNET_GNSRECORD_block_get_size(const struct GNUNET_GNSRECORD_Block *block)
Returns the length of this block in bytes.
ssize_t GNUNET_GNSRECORD_records_get_size(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Calculate how many bytes we will need to serialize the given records.
struct GNUNET_GNSRECORD_EncryptionContext * GNUNET_GNSRECORD_encryption_context_setup_owner(const struct GNUNET_CRYPTO_BlindablePrivateKey *sk)
Create a new encryption context for the zone owner.
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_record_data_to_rdata(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data rd[rd_count], unsigned char *rdata, size_t rdata_len)
Serialize the record set into an RFC9498-compliant RDATA octet string.
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_ZoneMonitor * GNUNET_NAMESTORE_zone_monitor_start2(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_CRYPTO_BlindablePrivateKey *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_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_ZoneIterator * GNUNET_NAMESTORE_zone_iteration_start2(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_BlindablePrivateKey *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_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:572
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:1667
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:1345
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition scheduler.c:986
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:1310
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:1283
#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:610
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:601
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:583
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:548
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition strings.c:671
#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).
The GNSRECORD encryption context.
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:141
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.
unsigned char * rdata_priv
The private RDATA to sign, may point to block in case the public and private blocks are the same.
struct RecordPublicationJob * prev
DLL.
char * label
The label of the block needed for signing.
struct GNUNET_TIME_Absolute expire_pub
The expiration time of the public RDATA for the DHT put.

◆ 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 412 of file gnunet-service-zonemaster.c.

413{
414 if (job->rdata_pub != job->rdata_priv)
415 GNUNET_free (job->rdata_priv);
416 GNUNET_free (job->rdata_pub);
417 if (job->block_pub != job->block_priv)
418 GNUNET_free (job->block_priv);
419 GNUNET_free (job->block_pub);
420 if (NULL != job->label)
421 GNUNET_free (job->label);
422 if (NULL != job->ec)
423 {
425 job->ec = NULL;
426 }
428}

References GNUNET_free, GNUNET_GNSRECORD_encryption_context_destroy(), and job.

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

Here is the call graph for this function:
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 438 of file gnunet-service-zonemaster.c.

439{
440 struct CacheOperation *cop;
442
443 (void) cls;
446 "Shutting down!\n");
447 if (NULL != notification_pipe)
449 if (NULL != pipe_read_task)
451 while (NULL != (cop = cop_head))
452 {
454 "Aborting incomplete namecache operation\n");
457 GNUNET_free (cop);
458 }
459 GNUNET_assert (0 == pthread_mutex_lock (&sign_jobs_lock));
460 while (NULL != (job = sign_jobs_head))
461 {
463 "Removing incomplete jobs\n");
466 free_job (job);
467 }
468 GNUNET_assert (0 == pthread_mutex_unlock (&sign_jobs_lock));
469 GNUNET_assert (0 == pthread_mutex_lock (&sign_results_lock));
470 while (NULL != (job = sign_results_head))
471 {
473 "Removing incomplete jobs\n");
475 free_job (job);
476 }
477 GNUNET_assert (0 == pthread_mutex_unlock (&sign_results_lock));
478 while (NULL != (job = dht_jobs_head))
479 {
481 "Removing incomplete jobs\n");
483 if (NULL != job->ph)
485 free_job (job);
486 }
487 if (NULL != statistics)
488 {
490 GNUNET_NO);
491 statistics = NULL;
492 }
493 if (NULL != zone_publish_task)
494 {
496 zone_publish_task = NULL;
497 }
498 if (NULL != namestore_iter)
499 {
501 namestore_iter = NULL;
502 }
503 if (NULL != zmon)
504 {
506 zmon = NULL;
507 }
508 if (NULL != namestore_handle)
509 {
511 namestore_handle = NULL;
512 }
513 if (NULL != namecache)
514 {
516 namecache = NULL;
517 }
518 if (NULL != dht_handle)
519 {
521 dht_handle = NULL;
522 }
523}

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 534 of file gnunet-service-zonemaster.c.

535{
536 struct CacheOperation *cop = cls;
537
538 if (NULL != emsg)
540 _ ("Failed to replicate block in namecache: %s\n"),
541 emsg);
542 else
543 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "CACHE operation completed\n");
545 GNUNET_free (cop);
546}

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 558 of file gnunet-service-zonemaster.c.

559{
560 struct CacheOperation *cop;
561
563 {
565 "Namecache updates skipped (NC disabled)",
566 1,
567 GNUNET_NO);
568 return;
569 }
570 GNUNET_assert (NULL != block);
571 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Caching block in namecache\n");
573 "Namecache updates pushed",
574 1,
575 GNUNET_NO);
576 cop = GNUNET_new (struct CacheOperation);
579 block,
581 cop);
582}

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 591 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 1165 of file gnunet-service-zonemaster.c.

1166{
1167 (void) cls;
1168 zone_publish_task = NULL;
1170 "Full zone iterations launched",
1171 1,
1172 GNUNET_NO);
1174 "Starting DHT zone update!\n");
1175 /* start counting again */
1177 GNUNET_assert (NULL == namestore_iter);
1181 NULL, /* All zones */
1183 NULL,
1185 NULL,
1187 NULL,
1189 GNUNET_assert (NULL != namestore_iter);
1190}

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 616 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 668 of file gnunet-service-zonemaster.c.

669{
671 unsigned long long pct = 0;
672
673 if (0 == cnt)
674 return;
675 /* How fast were we really? */
677 delta.rel_value_us /= cnt;
679
680 /* calculate expected frequency */
683 {
685 "Last record count was lower than current record count. Reducing interval.\n");
689 }
691 "Desired global zone iteration interval is %s/record!\n",
694 GNUNET_YES));
695
696 /* Tell statistics actual vs. desired speed */
698 "Current zone iteration velocity (μs/record)",
700 GNUNET_NO);
701 /* update "sub_delta" based on difference, taking
702 previous sub_delta into account! */
704 {
705 /* We were too fast, reduce sub_delta! */
706 struct GNUNET_TIME_Relative corr;
707
709 delta);
711 {
712 /* Reduce sub_delta by corr */
714 corr);
715 }
716 else
717 {
718 /* We're doing fine with waiting the full time, this
719 should theoretically only happen if we run at
720 infinite speed. */
722 }
723 }
726 {
727 /* We were too slow, increase sub_delta! */
728 struct GNUNET_TIME_Relative corr;
729
733 corr);
736 {
737 /* CPU overload detected, we cannot go at desired speed,
738 as this would mean using a negative delay. */
739 /* compute how much faster we would want to be for
740 the desired velocity */
742 pct = UINT64_MAX; /* desired speed is infinity ... */
743 else
748 }
749 }
751 "# dispatched jobs",
753 GNUNET_NO);
755 "% speed increase needed for target velocity",
756 pct,
757 GNUNET_NO);
759 "# records processed in current iteration",
761 GNUNET_NO);
762}

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 770 of file gnunet-service-zonemaster.c.

771{
772 struct GNUNET_TIME_Relative delay;
773
774 if (0 != ns_iteration_left)
775 return; /* current NAMESTORE iteration not yet done */
777 {
779 "Job queue length exceeded (%u/%u). Pausing namestore iteration.\n",
782 return;
783 }
785 put_cnt = 0;
787 sub_delta);
788 /* We delay *once* per #NS_BLOCK_SIZE, so we need to multiply the
789 per-record delay calculated so far with the #NS_BLOCK_SIZE */
791 "Current artificial NAMESTORE delay (μs/record)",
792 delay.rel_value_us,
793 GNUNET_NO);
794 delay = GNUNET_TIME_relative_multiply (delay,
796 /* make sure we do not overshoot because of the #NS_BLOCK_SIZE factor */
798 delay);
799 /* no delays on first iteration */
801 delay = GNUNET_TIME_UNIT_ZERO;
805 ,
806 NULL);
807}

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 811 of file gnunet-service-zonemaster.c.

812{
813
814 if (NULL == zone_publish_task)
817 {
819 {
821 "Job queue emptied (%u/%u). Resuming monitor.\n",
826 }
827 }
829 free_job (job);
830}

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 838 of file gnunet-service-zonemaster.c.

839{
840 struct RecordPublicationJob *job = cls;
841
843 "PUT complete; Pending jobs: %u\n", job_queue_length - 1);
844 /* When we just fall under the limit, trigger monitor/iterator again
845 * if halted. We can only safely trigger one, prefer iterator. */
848 job);
850}

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_BlindablePrivateKey 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 864 of file gnunet-service-zonemaster.c.

869{
870 struct GNUNET_GNSRECORD_Data rd_public[rd_count];
871 struct GNUNET_TIME_Absolute expire_pub;
873 unsigned char *rdata_public;
874 unsigned char *rdata_priv;
875 size_t rdata_public_len;
876 size_t rdata_private_len;
877 unsigned int rd_public_count = 0;
878 char *emsg;
879
880 if (GNUNET_OK !=
882 rd,
883 rd_count,
884 rd_public,
885 &rd_public_count,
886 &expire_pub,
888 &emsg))
889 {
891 "%s\n", emsg);
892 GNUNET_free (emsg);
893 }
894
895 rdata_public_len = GNUNET_GNSRECORD_records_get_size (rd_public_count,
896 rd_public);
897
898 rdata_private_len = GNUNET_GNSRECORD_records_get_size (rd_count,
899 rd);
900
901 rdata_public = GNUNET_malloc (rdata_public_len);
903 rd_public_count,
904 rd_public,
905 rdata_public,
906 rdata_public_len));
907 if (rd_count != rd_public_count)
908 {
909 rdata_priv = GNUNET_malloc (rdata_private_len);
911 rd_count,
912 rd,
914 rdata_private_len));
915 }
916 else
917 {
918 rdata_priv = rdata_public;
919 }
920 GNUNET_assert (0 == pthread_mutex_lock (&sign_jobs_lock));
922 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Public record count: %d\n",
923 rd_public_count);
924 job->have_public_records = (rd_public_count > 0);
925 job->rdata_pub = rdata_public;
926 job->rdata_pub_len = rdata_public_len;
927 job->rdata_priv = rdata_priv;
928 job->rdata_priv_len = rdata_private_len;
929 job->zone = *key;
930 job->label = GNUNET_strdup (label);
931 job->expire_pub = expire_pub;
932 job->expire_priv = expire;
935 GNUNET_assert (0 == pthread_cond_signal (&sign_jobs_cond));
936 GNUNET_assert (0 == pthread_mutex_unlock (&sign_jobs_lock));
938 "Creating job with %u record(s) for label `%s', expiration `%s'\n",
939 rd_public_count,
940 label,
943 return;
944}

References expire, RecordPublicationJob::expire_pub, GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_GNSRECORD_encryption_context_setup_owner(), GNUNET_GNSRECORD_FILTER_OMIT_PRIVATE, GNUNET_GNSRECORD_normalize_record_set(), GNUNET_GNSRECORD_record_data_to_rdata(), GNUNET_GNSRECORD_records_get_size(), GNUNET_log, GNUNET_malloc, GNUNET_new, GNUNET_OK, GNUNET_strdup, GNUNET_STRINGS_absolute_time_to_string(), job, key, RecordPublicationJob::label, num_public_records, rd, rd_count, RecordPublicationJob::rdata_priv, sign_jobs_cond, sign_jobs_head, sign_jobs_lock, and sign_jobs_tail.

Referenced by dispatch_job_monitor(), and 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 1332 of file gnunet-service-zonemaster.c.

1333{
1335 "Received wake up notification through pipe, checking results\n");
1337}

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 951 of file gnunet-service-zonemaster.c.

952{
953 struct GNUNET_HashCode query;
955 const struct GNUNET_DISK_FileHandle *np_fh;
956 char buf[100];
957 ssize_t nf_count;
958
959 pipe_read_task = NULL;
965 np_fh,
967 NULL);
968 /* empty queue */
969 nf_count = GNUNET_DISK_file_read (np_fh, buf, sizeof (buf));
970 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Read %lld notifications from pipe\n",
971 (long long) nf_count);
972 while (true)
973 {
974 GNUNET_assert (0 == pthread_mutex_lock (&sign_results_lock));
975 if (NULL == sign_results_head)
976 {
978 "No more results. Back to sleep.\n");
979 GNUNET_assert (0 == pthread_mutex_unlock (&sign_results_lock));
980 return;
981 }
984 GNUNET_assert (0 == pthread_mutex_unlock (&sign_results_lock));
986 job->label,
987 &query);
988 // It is possible that the public block size is 0 (no public blocks)
989 // Do not bother with the DHT in that case
990 if (job->have_public_records)
991 {
992 size_t block_size = GNUNET_GNSRECORD_block_get_size (job->block_pub);
994 &query,
998 block_size,
999 job->block_pub,
1000 job->expire_pub,
1002 job);
1003 if (NULL == job->ph)
1004 {
1006 "Could not perform DHT PUT, is the DHT running?\n");
1007 free_job (job);
1008 return;
1009 }
1011 "DHT put operations initiated",
1012 1,
1013 GNUNET_NO);
1015 "Storing record(s) for label `%s' in DHT under key %s\n",
1016 job->label,
1017 GNUNET_h2s (&query));
1018 refresh_block (job->block_priv);
1020 }
1021 else
1022 {
1023 // Private blocks may still be available and must be updated
1024 // in the cache
1025 refresh_block (job->block_priv);
1026 cleanup_job (job);
1027 }
1028 }
1029}

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_block_get_size(), 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 1038 of file gnunet-service-zonemaster.c.

1039{
1040 (void) cls;
1042 "Got disconnected from namestore database, retrying.\n");
1043 namestore_iter = NULL;
1044 /* We end up here on error/disconnect/shutdown, so potentially
1045 while a zone publish task or a DHT put is still running; hence
1046 we need to cancel those. */
1047 if (NULL != zone_publish_task)
1048 {
1050 zone_publish_task = NULL;
1051 }
1053 NULL);
1054}

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 1063 of file gnunet-service-zonemaster.c.

1064{
1065 (void) cls;
1066 /* we're done with one iteration, calculate when to do the next one */
1067 namestore_iter = NULL;
1072 /* reset for next iteration */
1076 "Zone iteration finished. Adjusted zone iteration interval to %s\n",
1079 GNUNET_YES));
1081 "Target zone iteration velocity (μs)",
1083 GNUNET_NO);
1085 "Number of public records in DHT",
1087 GNUNET_NO);
1089 if (0 == last_num_public_records)
1090 {
1094 NULL);
1095 }
1096 else
1097 {
1099 NULL);
1100 }
1101}

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_BlindablePrivateKey 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 1114 of file gnunet-service-zonemaster.c.

1120{
1121 (void) cls;
1123 if (0 == rd_count)
1124 {
1126 "Record set empty, moving to next record set\n");
1128 return;
1129 }
1130 for (unsigned int i = 0; i < rd_count; i++)
1131 {
1132 if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
1133 {
1134 /* GNUNET_GNSRECORD_block_create will convert to absolute time;
1135 we just need to adjust our iteration frequency */
1137 GNUNET_MIN (rd[i].expiration_time,
1139 }
1140 }
1141
1142
1143 /* We got a set of records to publish */
1145 "Starting DHT PUT\n");
1146 put_cnt++;
1147 if (0 == put_cnt % DELTA_INTERVAL)
1150 label,
1151 rd,
1152 rd_count,
1153 expire);
1156}

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_BlindablePrivateKey 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 1202 of file gnunet-service-zonemaster.c.

1207{
1208 dispatch_job (key, label, rd, rd_count, expire);
1209}

References dispatch_job(), expire, key, rd, and rd_count.

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_BlindablePrivateKey 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 1224 of file gnunet-service-zonemaster.c.

1230{
1231 (void) cls;
1233 "Namestore monitor events received",
1234 1,
1235 GNUNET_NO);
1237 "Received %u records for label `%s' via namestore monitor\n",
1238 rd_count,
1239 label);
1240 if (0 == rd_count)
1241 {
1243 1);
1244 return; /* nothing to do */
1245 }
1247 label,
1248 rd,
1249 rd_count,
1250 expire);
1253 {
1255 "Job queue length exceeded (%u/%u). Halting monitor.\n",
1259 return;
1260 }
1262 1);
1263}

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, monitor_halted, rd, rd_count, statistics, and zmon.

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 1273 of file gnunet-service-zonemaster.c.

1274{
1275 (void) cls;
1277 "Namestore monitor errors encountered",
1278 1,
1279 GNUNET_NO);
1280}

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 1284 of file gnunet-service-zonemaster.c.

1285{
1286 struct RecordPublicationJob *job;
1287 const struct GNUNET_DISK_FileHandle *fh;
1288
1290 while (GNUNET_YES != in_shutdown)
1291 {
1292 GNUNET_assert (0 == pthread_mutex_lock (&sign_jobs_lock));
1293 while (NULL == sign_jobs_head)
1294 GNUNET_assert (0 == pthread_cond_wait (&sign_jobs_cond, &sign_jobs_lock));
1295 if (GNUNET_YES == in_shutdown)
1296 {
1297 GNUNET_assert (0 == pthread_mutex_unlock (&sign_jobs_lock));
1298 return NULL;
1299 }
1301 "Taking on Job for %s\n", sign_jobs_head->label);
1304 GNUNET_assert (0 == pthread_mutex_unlock (&sign_jobs_lock));
1305 job->ec->seal (job->ec->cls,
1306 job->label,
1307 job->expire_pub,
1308 job->rdata_pub,
1309 job->rdata_pub_len,
1310 &job->block_pub);
1311 if (job->rdata_pub != job->rdata_priv)
1312 job->ec->seal (job->ec->cls,
1313 job->label,
1314 job->expire_priv,
1315 job->rdata_priv,
1316 job->rdata_priv_len,
1317 &job->block_priv);
1318 else
1319 job->block_priv = job->block_pub;
1320 GNUNET_assert (0 == pthread_mutex_lock (&sign_results_lock));
1322 GNUNET_assert (0 == pthread_mutex_unlock (&sign_results_lock));
1324 "Done, notifying main thread through pipe!\n");
1325 GNUNET_DISK_file_write (fh, "!", 1);
1326 }
1327 return NULL;
1328}

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_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 1348 of file gnunet-service-zonemaster.c.

1351{
1352 unsigned long long max_parallel_bg_queries = 128;
1353 const struct GNUNET_DISK_FileHandle *np_fh;
1354
1355 (void) cls;
1356 (void) service;
1357 pthread_mutex_init (&sign_jobs_lock, NULL);
1358 pthread_mutex_init (&sign_results_lock, NULL);
1359 pthread_cond_init (&sign_jobs_cond, NULL);
1360 last_put_100 = GNUNET_TIME_absolute_get (); /* first time! */
1365 if (NULL == namestore_handle)
1366 {
1368 _ ("Failed to connect to the namestore!\n"));
1370 return;
1371 }
1373 "namecache",
1374 "DISABLE");
1376 {
1378 if (NULL == namecache)
1379 {
1381 _ ("Failed to connect to the namecache!\n"));
1383 return;
1384 }
1385 }
1387 "namestore",
1388 "CACHE_KEYS");
1390 if (GNUNET_OK ==
1392 "zonemaster",
1393 "ZONE_PUBLISH_TIME_WINDOW",
1395 {
1397 "Time window for zone iteration: %s\n",
1400 GNUNET_YES));
1401 }
1403 if (GNUNET_OK ==
1405 "zonemaster",
1406 "MAX_PARALLEL_BACKGROUND_QUERIES",
1407 &max_parallel_bg_queries))
1408 {
1410 "Number of allowed parallel background queries: %llu\n",
1411 max_parallel_bg_queries);
1412 }
1413 if (0 == max_parallel_bg_queries)
1414 max_parallel_bg_queries = 1;
1416 (unsigned int) max_parallel_bg_queries);
1417 if (NULL == dht_handle)
1418 {
1420 _ ("Could not connect to DHT!\n"));
1422 NULL);
1423 return;
1424 }
1425
1426 /* Schedule periodic put for our records. */
1428 statistics = GNUNET_STATISTICS_create ("zonemaster",
1429 c);
1431 "Target zone iteration velocity (μs)",
1433 GNUNET_NO);
1435 NULL);
1437 NULL,
1438 GNUNET_NO,
1440 NULL,
1442 NULL,
1443 NULL /* sync_cb */,
1444 NULL,
1448 GNUNET_break (NULL != zmon);
1449
1451 NULL);
1452
1454 np_fh = GNUNET_DISK_pipe_handle (
1458 np_fh,
1459 notification_pipe_cb, NULL);
1460
1461 {
1462 long long unsigned int worker_count = 1;
1463 if (GNUNET_OK !=
1465 "zonemaster",
1466 "WORKER_COUNT",
1467 &worker_count))
1468 {
1470 "Number of workers not defined falling back to 1\n");
1471 }
1472 worker = GNUNET_malloc (sizeof (pthread_t) * worker_count);
1474 for (int i = 0; i < worker_count; i++)
1475 {
1476 if (0 !=
1477 pthread_create (&worker[i],
1478 NULL,
1479 &sign_worker,
1480 NULL))
1481 {
1483 "pthread_create");
1485 }
1487 "Workers running",
1488 1,
1489 GNUNET_NO);
1490 }
1491 }
1492}

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(), 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(), 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 223 of file gnunet-service-zonemaster.c.

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

◆ sign_jobs_tail

struct RecordPublicationJob* sign_jobs_tail
static

See above.

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

Referenced by dispatch_job(), 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 233 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 238 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 244 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 249 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 283 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 288 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 293 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 298 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 304 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 309 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 314 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 319 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 324 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 330 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 339 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 345 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 351 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 356 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 362 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 368 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 376 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 387 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 392 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 398 of file gnunet-service-zonemaster.c.

Referenced by run().

◆ cop_head

struct CacheOperation* cop_head
static

Head of cop DLL.

Definition at line 403 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 408 of file gnunet-service-zonemaster.c.

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