GNUnet  0.11.x
Data Structures | Macros | Functions | Variables
gnunet-service-zonemaster-monitor.c File Reference

monitor namestore changes and publish them immediately to GNUnet name system More...

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

Go to the source code of this file.

Data Structures

struct  DhtPutActivity
 Handle for DHT PUT activity triggered from the namestore monitor. 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? More...
 
#define DHT_QUEUE_LIMIT   2000
 How many pending DHT operations do we allow at most? More...
 
#define NAMESTORE_QUEUE_LIMIT   5
 How many events may the namestore give us before it has to wait for us to keep up? More...
 
#define DHT_GNS_REPLICATION_LEVEL   5
 What replication level do we use for DHT PUT operations? More...
 

Functions

static void shutdown_task (void *cls)
 Task run during shutdown. More...
 
static void dht_put_monitor_continuation (void *cls)
 Continuation called from DHT once the PUT operation triggered by a monitor is done. More...
 
static unsigned int convert_records_for_export (const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count, struct GNUNET_GNSRECORD_Data *rd_public)
 Convert namestore records from the internal format to that suitable for publication (removes private records, converts to absolute expiration time). More...
 
static struct GNUNET_DHT_PutHandleperform_dht_put (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, const char *label, const struct GNUNET_GNSRECORD_Data *rd_public, unsigned int rd_public_count, struct DhtPutActivity *ma)
 Store GNS records in the DHT. More...
 
static void handle_monitor_event (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 Process a record that was stored in the namestore (invoked by the monitor). More...
 
static void handle_monitor_error (void *cls)
 The zone monitor encountered an IPC error trying to to get in sync. More...
 
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service)
 Performe zonemaster duties: watch namestore, publish records. More...
 
 GNUNET_SERVICE_MAIN ("zonemaster-monitor", GNUNET_SERVICE_OPTION_NONE, &run, NULL, NULL, NULL, GNUNET_MQ_handler_end())
 Define "main" method using service macro. More...
 

Variables

static struct GNUNET_STATISTICS_Handlestatistics
 Handle to the statistics service. More...
 
static struct GNUNET_DHT_Handledht_handle
 Our handle to the DHT. More...
 
static struct GNUNET_NAMESTORE_Handlenamestore_handle
 Our handle to the namestore service. More...
 
static struct GNUNET_NAMESTORE_ZoneMonitorzmon
 Handle to monitor namestore changes to instant propagation. More...
 
static struct DhtPutActivityma_head
 Head of monitor activities; kept in a DLL. More...
 
static struct DhtPutActivityma_tail
 Tail of monitor activities; kept in a DLL. More...
 
static unsigned int ma_queue_length
 Number of entries in the DHT queue ma_head. More...
 
static int cache_keys
 Optimize block insertion by caching map of private keys to public keys in memory? More...
 

Detailed Description

monitor namestore changes and publish them immediately to GNUnet name system

Author
Christian Grothoff

Definition in file gnunet-service-zonemaster-monitor.c.

Macro Definition Documentation

◆ LOG_STRERROR_FILE

#define LOG_STRERROR_FILE (   kind,
  syscall,
  filename 
)
Value:
syscall, \
#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...
static char * filename

Definition at line 33 of file gnunet-service-zonemaster-monitor.c.

◆ PUBLISH_OPS_PER_EXPIRATION

#define PUBLISH_OPS_PER_EXPIRATION   4

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

Definition at line 43 of file gnunet-service-zonemaster-monitor.c.

◆ DHT_QUEUE_LIMIT

#define DHT_QUEUE_LIMIT   2000

How many pending DHT operations do we allow at most?

Definition at line 48 of file gnunet-service-zonemaster-monitor.c.

Referenced by handle_monitor_event().

◆ NAMESTORE_QUEUE_LIMIT

#define NAMESTORE_QUEUE_LIMIT   5

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

Definition at line 54 of file gnunet-service-zonemaster-monitor.c.

Referenced by run().

◆ DHT_GNS_REPLICATION_LEVEL

#define DHT_GNS_REPLICATION_LEVEL   5

What replication level do we use for DHT PUT operations?

Definition at line 59 of file gnunet-service-zonemaster-monitor.c.

Referenced by perform_dht_put().

Function Documentation

◆ shutdown_task()

static void shutdown_task ( void *  cls)
static

Task run during shutdown.

Parameters
clsunused
tcunused

Definition at line 138 of file gnunet-service-zonemaster-monitor.c.

References GNUNET_CONTAINER_DLL_remove, GNUNET_DHT_disconnect(), GNUNET_DHT_put_cancel(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_NAMESTORE_disconnect(), GNUNET_NAMESTORE_zone_monitor_stop(), GNUNET_NO, GNUNET_STATISTICS_destroy(), ma_queue_length, and DhtPutActivity::ph.

Referenced by run().

139 {
140  struct DhtPutActivity *ma;
141 
142  (void) cls;
144  "Shutting down!\n");
145  while (NULL != (ma = ma_head))
146  {
148  ma_queue_length--;
150  ma_tail,
151  ma);
152  GNUNET_free (ma);
153  }
154  if (NULL != statistics)
155  {
157  GNUNET_NO);
158  statistics = NULL;
159  }
160  if (NULL != zmon)
161  {
163  zmon = NULL;
164  }
165  if (NULL != namestore_handle)
166  {
168  namestore_handle = NULL;
169  }
170  if (NULL != dht_handle)
171  {
173  dht_handle = NULL;
174  }
175 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_DHT_PutHandle * ph
Handle for the DHT PUT operation.
void GNUNET_DHT_put_cancel(struct GNUNET_DHT_PutHandle *ph)
Cancels a DHT PUT operation.
Definition: dht_api.c:1035
static struct GNUNET_STATISTICS_Handle * statistics
Handle to the statistics service.
static struct GNUNET_NAMESTORE_ZoneMonitor * zmon
Handle to monitor namestore changes to instant propagation.
void GNUNET_NAMESTORE_zone_monitor_stop(struct GNUNET_NAMESTORE_ZoneMonitor *zm)
Stop monitoring a zone for changes.
#define GNUNET_NO
Definition: gnunet_common.h:78
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
Handle for DHT PUT activity triggered from the namestore monitor.
static struct GNUNET_NAMESTORE_Handle * namestore_handle
Our handle to the namestore service.
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).
void GNUNET_DHT_disconnect(struct GNUNET_DHT_Handle *handle)
Shutdown connection with the DHT service.
Definition: dht_api.c:918
static struct DhtPutActivity * ma_head
Head of monitor activities; kept in a DLL.
static struct DhtPutActivity * ma_tail
Tail of monitor activities; kept in a DLL.
#define GNUNET_log(kind,...)
static struct GNUNET_DHT_Handle * dht_handle
Our handle to the DHT.
static unsigned int ma_queue_length
Number of entries in the DHT queue ma_head.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dht_put_monitor_continuation()

static void dht_put_monitor_continuation ( void *  cls)
static

Continuation called from DHT once the PUT operation triggered by a monitor is done.

Parameters
clsa struct DhtPutActivity

Definition at line 185 of file gnunet-service-zonemaster-monitor.c.

References GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_NAMESTORE_zone_monitor_next(), and ma_queue_length.

Referenced by perform_dht_put().

186 {
187  struct DhtPutActivity *ma = cls;
188 
190  1);
191  ma_queue_length--;
193  ma_tail,
194  ma);
195  GNUNET_free (ma);
196 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct GNUNET_NAMESTORE_ZoneMonitor * zmon
Handle to monitor namestore changes to instant propagation.
Handle for DHT PUT activity triggered from the namestore monitor.
static struct DhtPutActivity * ma_head
Head of monitor activities; kept in a DLL.
static struct DhtPutActivity * ma_tail
Tail of monitor activities; kept in a DLL.
static unsigned int ma_queue_length
Number of entries in the DHT queue ma_head.
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)...
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ convert_records_for_export()

static unsigned int convert_records_for_export ( const struct GNUNET_GNSRECORD_Data rd,
unsigned int  rd_count,
struct GNUNET_GNSRECORD_Data rd_public 
)
static

Convert namestore records from the internal format to that suitable for publication (removes private records, converts to absolute expiration time).

Parameters
rdinput records
rd_countsize of the rd and rd_public arrays
rd_publicwhere to write the converted records
Returns
number of records written to rd_public

Definition at line 210 of file gnunet-service-zonemaster-monitor.c.

References GNUNET_TIME_Absolute::abs_value_us, GNUNET_GNSRECORD_RF_PRIVATE, GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, and GNUNET_TIME_absolute_get().

Referenced by handle_monitor_event().

213 {
214  struct GNUNET_TIME_Absolute now;
215  unsigned int rd_public_count;
216 
217  rd_public_count = 0;
218  now = GNUNET_TIME_absolute_get ();
219  for (unsigned int i = 0; i < rd_count; i++)
220  {
221  if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE))
222  continue;
223  if ((0 == (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)) &&
224  (rd[i].expiration_time < now.abs_value_us))
225  continue; /* record already expired, skip it */
226  rd_public[rd_public_count++] = rd[i];
227  }
228  return rd_public_count;
229 }
This is a private record of this peer and it should thus not be handed out to other peers...
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
Time for absolute times used by GNUnet, in microseconds.
This flag is currently unused; former RF_PENDING flag.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ perform_dht_put()

static struct GNUNET_DHT_PutHandle* perform_dht_put ( const struct GNUNET_CRYPTO_EcdsaPrivateKey key,
const char *  label,
const struct GNUNET_GNSRECORD_Data rd_public,
unsigned int  rd_public_count,
struct DhtPutActivity ma 
)
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 243 of file gnunet-service-zonemaster-monitor.c.

References cache_keys, DHT_GNS_REPLICATION_LEVEL, dht_put_monitor_continuation(), GNUNET_BLOCK_TYPE_GNS_NAMERECORD, GNUNET_break, GNUNET_DHT_put(), GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_GNSRECORD_block_create(), GNUNET_GNSRECORD_block_create2(), GNUNET_GNSRECORD_query_from_private_key(), GNUNET_GNSRECORD_record_get_expiration_time(), GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_STRINGS_absolute_time_to_string(), GNUNET_GNSRECORD_Block::purpose, ret, and GNUNET_CRYPTO_EccSignaturePurpose::size.

Referenced by handle_monitor_event().

248 {
249  struct GNUNET_GNSRECORD_Block *block;
250  struct GNUNET_HashCode query;
252  size_t block_size;
253  struct GNUNET_DHT_PutHandle *ret;
254 
256  rd_public);
257  if (cache_keys)
258  block = GNUNET_GNSRECORD_block_create2 (key,
259  expire,
260  label,
261  rd_public,
262  rd_public_count);
263  else
264  block = GNUNET_GNSRECORD_block_create (key,
265  expire,
266  label,
267  rd_public,
268  rd_public_count);
269  if (NULL == block)
270  {
271  GNUNET_break (0);
272  return NULL; /* whoops */
273  }
274  block_size = ntohl (block->purpose.size)
275  + sizeof(struct GNUNET_CRYPTO_EcdsaSignature)
276  + sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey);
278  label,
279  &query);
281  "DHT put operations initiated",
282  1,
283  GNUNET_NO);
285  "Storing %u record(s) for label `%s' in DHT with expiration `%s' under key %s\n",
286  rd_public_count,
287  label,
289  GNUNET_h2s (&query));
290  ret = GNUNET_DHT_put (dht_handle,
291  &query,
295  block_size,
296  block,
297  expire,
299  ma);
300  GNUNET_free (block);
301  return ret;
302 }
static int cache_keys
Optimize block insertion by caching map of private keys to public keys in memory? ...
static struct GNUNET_STATISTICS_Handle * statistics
Handle to the statistics service.
struct GNUNET_GNSRECORD_Block * GNUNET_GNSRECORD_block_create(const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, struct GNUNET_TIME_Absolute expire, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count)
Sign name and records.
static void expire(void *cls)
Expire a PooledConnection object.
struct GNUNET_GNSRECORD_Block * GNUNET_GNSRECORD_block_create2(const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, struct GNUNET_TIME_Absolute expire, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count)
Sign name and records, cache derived public key (also keeps the private key in static memory...
#define DHT_GNS_REPLICATION_LEVEL
What replication level do we use for DHT PUT operations?
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
#define GNUNET_NO
Definition: gnunet_common.h:78
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
Information we have in an encrypted block with record data (i.e.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
void GNUNET_GNSRECORD_query_from_private_key(const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, struct GNUNET_HashCode *query)
Calculate the DHT query for a given label in a given zone.
an ECC signature using ECDSA
uint32_t size
How many bytes does this signature sign? (including this purpose header); in network byte order (!)...
Block for storing record data.
A 512-bit hashcode.
struct GNUNET_TIME_Absolute GNUNET_GNSRECORD_record_get_expiration_time(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Returns the expiration time of the given block of records.
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:966
Handle to a PUT request.
Definition: dht_api.c:43
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
#define GNUNET_log(kind,...)
static struct GNUNET_DHT_Handle * dht_handle
Our handle to the DHT.
Time for absolute times used by GNUnet, in microseconds.
static void dht_put_monitor_continuation(void *cls)
Continuation called from DHT once the PUT operation triggered by a monitor is done.
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition: strings.c:742
struct GNUNET_CRYPTO_EccSignaturePurpose purpose
Number of bytes signed; also specifies the number of bytes of encrypted data that follow...
Each peer along the way should look at &#39;enc&#39; (otherwise only the k-peers closest to the key should lo...
#define GNUNET_free(ptr)
Wrapper around free.
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_EcdsaPrivateKey zone,
const char *  label,
unsigned int  rd_count,
const struct GNUNET_GNSRECORD_Data rd 
)
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

Definition at line 316 of file gnunet-service-zonemaster-monitor.c.

References convert_records_for_export(), DHT_QUEUE_LIMIT, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_DHT_put_cancel(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_NAMESTORE_zone_monitor_next(), GNUNET_new, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_duration(), GNUNET_YES, ma_head, ma_queue_length, perform_dht_put(), DhtPutActivity::ph, and DhtPutActivity::start_date.

Referenced by run().

321 {
322  struct GNUNET_GNSRECORD_Data rd_public[rd_count];
323  unsigned int rd_public_count;
324  struct DhtPutActivity *ma;
325 
326  (void) cls;
328  "Namestore monitor events received",
329  1,
330  GNUNET_NO);
332  "Received %u records for label `%s' via namestore monitor\n",
333  rd_count,
334  label);
335  /* filter out records that are not public, and convert to
336  absolute expiration time. */
337  rd_public_count = convert_records_for_export (rd,
338  rd_count,
339  rd_public);
340  if (0 == rd_public_count)
341  {
343  1);
344  return; /* nothing to do */
345  }
346  ma = GNUNET_new (struct DhtPutActivity);
348  ma->ph = perform_dht_put (zone,
349  label,
350  rd,
351  rd_count,
352  ma);
353  if (NULL == ma->ph)
354  {
355  /* PUT failed, do not remember operation */
356  GNUNET_free (ma);
358  1);
359  return;
360  }
362  ma_tail,
363  ma);
364  ma_queue_length++;
366  {
367  ma = ma_head;
369  ma_tail,
370  ma);
372  ma_queue_length--;
374  "DHT PUT unconfirmed after %s, aborting PUT\n",
377  GNUNET_YES));
378  GNUNET_free (ma);
379  }
380 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_DHT_PutHandle * ph
Handle for the DHT PUT operation.
void GNUNET_DHT_put_cancel(struct GNUNET_DHT_PutHandle *ph)
Cancels a DHT PUT operation.
Definition: dht_api.c:1035
static struct GNUNET_STATISTICS_Handle * statistics
Handle to the statistics service.
static struct GNUNET_NAMESTORE_ZoneMonitor * zmon
Handle to monitor namestore changes to instant propagation.
struct GNUNET_TIME_Absolute start_date
When was this PUT initiated?
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
Handle for DHT PUT activity triggered from the namestore monitor.
#define DHT_QUEUE_LIMIT
How many pending DHT operations do we allow at most?
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:687
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
static struct DhtPutActivity * ma_head
Head of monitor activities; kept in a DLL.
static struct DhtPutActivity * ma_tail
Tail of monitor activities; kept in a DLL.
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:375
#define GNUNET_log(kind,...)
static unsigned int ma_queue_length
Number of entries in the DHT queue ma_head.
static struct GNUNET_DHT_PutHandle * perform_dht_put(const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, const char *label, const struct GNUNET_GNSRECORD_Data *rd_public, unsigned int rd_public_count, struct DhtPutActivity *ma)
Store GNS records in the DHT.
static unsigned int convert_records_for_export(const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count, struct GNUNET_GNSRECORD_Data *rd_public)
Convert namestore records from the internal format to that suitable for publication (removes private ...
#define GNUNET_YES
Definition: gnunet_common.h:77
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)...
#define GNUNET_free(ptr)
Wrapper around free.
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 390 of file gnunet-service-zonemaster-monitor.c.

References GNUNET_NO, and GNUNET_STATISTICS_update().

Referenced by run().

391 {
392  (void) cls;
394  "Namestore monitor errors encountered",
395  1,
396  GNUNET_NO);
397 }
static struct GNUNET_STATISTICS_Handle * statistics
Handle to the statistics service.
#define GNUNET_NO
Definition: gnunet_common.h:78
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
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

Performe zonemaster duties: watch namestore, publish records.

Parameters
clsclosure
serverthe initialized server
cconfiguration to use

Definition at line 408 of file gnunet-service-zonemaster-monitor.c.

References _, cache_keys, GNUNET_break, GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_DHT_connect(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_MQ_handler_end, GNUNET_NAMESTORE_connect(), GNUNET_NAMESTORE_zone_monitor_next(), GNUNET_NAMESTORE_zone_monitor_start(), GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_SERVICE_MAIN(), GNUNET_SERVICE_OPTION_NONE, GNUNET_STATISTICS_create(), handle_monitor_error(), handle_monitor_event(), NAMESTORE_QUEUE_LIMIT, and shutdown_task().

411 {
412  unsigned long long max_parallel_bg_queries = 128;
413 
414  (void) cls;
415  (void) service;
417  if (NULL == namestore_handle)
418  {
420  _ ("Failed to connect to the namestore!\n"));
422  return;
423  }
425  "namestore",
426  "CACHE_KEYS");
427  if (GNUNET_OK ==
429  "zonemaster",
430  "MAX_PARALLEL_BACKGROUND_QUERIES",
431  &max_parallel_bg_queries))
432  {
434  "Number of allowed parallel background queries: %llu\n",
435  max_parallel_bg_queries);
436  }
437  if (0 == max_parallel_bg_queries)
438  max_parallel_bg_queries = 1;
440  (unsigned int) max_parallel_bg_queries);
441  if (NULL == dht_handle)
442  {
444  _ ("Could not connect to DHT!\n"));
446  NULL);
447  return;
448  }
449 
450  /* Schedule periodic put for our records. */
451  statistics = GNUNET_STATISTICS_create ("zonemaster-mon",
452  c);
454  NULL,
455  GNUNET_NO,
457  NULL,
459  NULL,
460  NULL /* sync_cb */,
461  NULL);
464  GNUNET_break (NULL != zmon);
466  NULL);
467 }
int 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.
static int cache_keys
Optimize block insertion by caching map of private keys to public keys in memory? ...
static void shutdown_task(void *cls)
Task run during shutdown.
static struct GNUNET_STATISTICS_Handle * statistics
Handle to the statistics service.
static struct GNUNET_NAMESTORE_ZoneMonitor * zmon
Handle to monitor namestore changes to instant propagation.
struct GNUNET_NAMESTORE_ZoneMonitor * GNUNET_NAMESTORE_zone_monitor_start(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, int iterate_first, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor monitor, void *monitor_cls, GNUNET_SCHEDULER_TaskCallback sync_cb, void *sync_cb_cls)
Begin monitoring a zone for changes.
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, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1300
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:526
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
static struct GNUNET_NAMESTORE_Handle * namestore_handle
Our handle to the namestore service.
static void handle_monitor_error(void *cls)
The zone monitor encountered an IPC error trying to to get in sync.
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:1280
#define NAMESTORE_QUEUE_LIMIT
How many events may the namestore give us before it has to wait for us to keep up?
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:890
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namestore service.
static void handle_monitor_event(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Process a record that was stored in the namestore (invoked by the monitor).
#define GNUNET_log(kind,...)
static struct GNUNET_DHT_Handle * dht_handle
Our handle to the DHT.
int 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".
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)...
Here is the call graph for this function:

◆ GNUNET_SERVICE_MAIN()

GNUNET_SERVICE_MAIN ( "zonemaster-monitor ,
GNUNET_SERVICE_OPTION_NONE  ,
run,
NULL  ,
NULL  ,
NULL  ,
GNUNET_MQ_handler_end()   
)

Define "main" method using service macro.

Referenced by run().

Here is the caller graph for this function:

Variable Documentation

◆ statistics

struct GNUNET_STATISTICS_Handle* statistics
static

Handle to the statistics service.

Definition at line 92 of file gnunet-service-zonemaster-monitor.c.

◆ dht_handle

struct GNUNET_DHT_Handle* dht_handle
static

Our handle to the DHT.

Definition at line 97 of file gnunet-service-zonemaster-monitor.c.

◆ namestore_handle

struct GNUNET_NAMESTORE_Handle* namestore_handle
static

Our handle to the namestore service.

Definition at line 102 of file gnunet-service-zonemaster-monitor.c.

◆ zmon

struct GNUNET_NAMESTORE_ZoneMonitor* zmon
static

Handle to monitor namestore changes to instant propagation.

Definition at line 107 of file gnunet-service-zonemaster-monitor.c.

◆ ma_head

struct DhtPutActivity* ma_head
static

Head of monitor activities; kept in a DLL.

Definition at line 112 of file gnunet-service-zonemaster-monitor.c.

Referenced by handle_monitor_event().

◆ ma_tail

struct DhtPutActivity* ma_tail
static

Tail of monitor activities; kept in a DLL.

Definition at line 117 of file gnunet-service-zonemaster-monitor.c.

◆ ma_queue_length

unsigned int ma_queue_length
static

Number of entries in the DHT queue ma_head.

Definition at line 122 of file gnunet-service-zonemaster-monitor.c.

Referenced by dht_put_monitor_continuation(), handle_monitor_event(), and shutdown_task().

◆ cache_keys

int cache_keys
static

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

Definition at line 128 of file gnunet-service-zonemaster-monitor.c.

Referenced by perform_dht_put(), and run().