GNUnet  0.10.x
Data Structures | Macros | Functions
datastore_api.c File Reference

Management for the datastore for files stored on a GNUnet node. More...

#include "platform.h"
#include "gnunet_arm_service.h"
#include "gnunet_constants.h"
#include "gnunet_datastore_service.h"
#include "gnunet_statistics_service.h"
#include "datastore.h"
Include dependency graph for datastore_api.c:

Go to the source code of this file.

Data Structures

struct  StatusContext
 Context for processing status messages. More...
 
struct  ResultContext
 Context for processing result messages. More...
 
union  QueueContext
 Context for a queue operation. More...
 
struct  GNUNET_DATASTORE_QueueEntry
 Entry in our priority queue. More...
 
struct  GNUNET_DATASTORE_Handle
 Handle to the datastore service. More...
 

Macros

#define LOG(kind, ...)   GNUNET_log_from (kind, "datastore-api",__VA_ARGS__)
 
#define DELAY_WARN_TIMEOUT   GNUNET_TIME_UNIT_MINUTES
 
#define INSANE_STATISTICS   GNUNET_NO
 Collect an instane number of statistics? May cause excessive IPC. More...
 
#define MAX_EXCESS_RESULTS   8
 If a client stopped asking for more results, how many more do we receive from the DB before killing the connection? Trade-off between re-doing TCP handshakes and (needlessly) receiving useless results. More...
 

Functions

static void try_reconnect (void *cls)
 Try reconnecting to the datastore service. More...
 
static void do_disconnect (struct GNUNET_DATASTORE_Handle *h)
 Disconnect from the service and then try reconnecting to the datastore service after some delay. More...
 
static void free_queue_entry (struct GNUNET_DATASTORE_QueueEntry *qe)
 Free a queue entry. More...
 
static void delay_warning (void *cls)
 Task that logs an error after some time. More...
 
static void mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
 Handle error in sending drop request to datastore. More...
 
struct GNUNET_DATASTORE_HandleGNUNET_DATASTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Connect to the datastore service. More...
 
static void disconnect_after_drop (void *cls)
 Task used by to disconnect from the datastore after we send the GNUNET_MESSAGE_TYPE_DATASTORE_DROP message. More...
 
static void disconnect_on_mq_error (void *cls, enum GNUNET_MQ_Error error)
 Handle error in sending drop request to datastore. More...
 
void GNUNET_DATASTORE_disconnect (struct GNUNET_DATASTORE_Handle *h, int drop)
 Disconnect from the datastore service (and free associated resources). More...
 
static struct GNUNET_DATASTORE_QueueEntrymake_queue_entry (struct GNUNET_DATASTORE_Handle *h, struct GNUNET_MQ_Envelope *env, unsigned int queue_priority, unsigned int max_queue_size, uint16_t expected_type, const union QueueContext *qc)
 Create a new entry for our priority queue (and possibly discard other entires if the queue is getting too long). More...
 
static void process_queue (struct GNUNET_DATASTORE_Handle *h)
 Process entries in the queue (or do nothing if we are already doing so). More...
 
static struct GNUNET_DATASTORE_QueueEntryget_queue_head (struct GNUNET_DATASTORE_Handle *h, uint16_t response_type)
 Get the entry at the head of the message queue. More...
 
static int check_status (void *cls, const struct StatusMessage *sm)
 Function called to check status message from the service. More...
 
static void handle_status (void *cls, const struct StatusMessage *sm)
 Function called to handle status message from the service. More...
 
static int check_data (void *cls, const struct DataMessage *dm)
 Check data message we received from the service. More...
 
static void handle_data (void *cls, const struct DataMessage *dm)
 Handle data message we got from the service. More...
 
static void handle_data_end (void *cls, const struct GNUNET_MessageHeader *msg)
 Type of a function to call when we receive a GNUNET_MESSAGE_TYPE_DATASTORE_DATA_END message from the service. More...
 
static void drop_status_cont (void *cls, int32_t result, struct GNUNET_TIME_Absolute min_expiration, const char *emsg)
 Dummy continuation used to do nothing (but be non-zero). More...
 
struct GNUNET_DATASTORE_QueueEntryGNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h, uint32_t rid, const struct GNUNET_HashCode *key, size_t size, const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, uint32_t anonymity, uint32_t replication, struct GNUNET_TIME_Absolute expiration, unsigned int queue_priority, unsigned int max_queue_size, GNUNET_DATASTORE_ContinuationWithStatus cont, void *cont_cls)
 Store an item in the datastore. More...
 
struct GNUNET_DATASTORE_QueueEntryGNUNET_DATASTORE_reserve (struct GNUNET_DATASTORE_Handle *h, uint64_t amount, uint32_t entries, GNUNET_DATASTORE_ContinuationWithStatus cont, void *cont_cls)
 Reserve space in the datastore. More...
 
struct GNUNET_DATASTORE_QueueEntryGNUNET_DATASTORE_release_reserve (struct GNUNET_DATASTORE_Handle *h, uint32_t rid, unsigned int queue_priority, unsigned int max_queue_size, GNUNET_DATASTORE_ContinuationWithStatus cont, void *cont_cls)
 Signal that all of the data for which a reservation was made has been stored and that whatever excess space might have been reserved can now be released. More...
 
struct GNUNET_DATASTORE_QueueEntryGNUNET_DATASTORE_remove (struct GNUNET_DATASTORE_Handle *h, const struct GNUNET_HashCode *key, size_t size, const void *data, unsigned int queue_priority, unsigned int max_queue_size, GNUNET_DATASTORE_ContinuationWithStatus cont, void *cont_cls)
 Explicitly remove some content from the database. More...
 
struct GNUNET_DATASTORE_QueueEntryGNUNET_DATASTORE_get_for_replication (struct GNUNET_DATASTORE_Handle *h, unsigned int queue_priority, unsigned int max_queue_size, GNUNET_DATASTORE_DatumProcessor proc, void *proc_cls)
 Get a random value from the datastore for content replication. More...
 
struct GNUNET_DATASTORE_QueueEntryGNUNET_DATASTORE_get_zero_anonymity (struct GNUNET_DATASTORE_Handle *h, uint64_t next_uid, unsigned int queue_priority, unsigned int max_queue_size, enum GNUNET_BLOCK_Type type, GNUNET_DATASTORE_DatumProcessor proc, void *proc_cls)
 Get a single zero-anonymity value from the datastore. More...
 
struct GNUNET_DATASTORE_QueueEntryGNUNET_DATASTORE_get_key (struct GNUNET_DATASTORE_Handle *h, uint64_t next_uid, bool random, const struct GNUNET_HashCode *key, enum GNUNET_BLOCK_Type type, unsigned int queue_priority, unsigned int max_queue_size, GNUNET_DATASTORE_DatumProcessor proc, void *proc_cls)
 Get a result for a particular key from the datastore. More...
 
void GNUNET_DATASTORE_cancel (struct GNUNET_DATASTORE_QueueEntry *qe)
 Cancel a datastore operation. More...
 

Detailed Description

Management for the datastore for files stored on a GNUnet node.

Implements a priority queue for requests

Author
Christian Grothoff

Definition in file datastore_api.c.

Macro Definition Documentation

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log_from (kind, "datastore-api",__VA_ARGS__)

◆ DELAY_WARN_TIMEOUT

#define DELAY_WARN_TIMEOUT   GNUNET_TIME_UNIT_MINUTES

Definition at line 36 of file datastore_api.c.

Referenced by delay_warning(), and process_queue().

◆ INSANE_STATISTICS

#define INSANE_STATISTICS   GNUNET_NO

Collect an instane number of statistics? May cause excessive IPC.

Definition at line 41 of file datastore_api.c.

◆ MAX_EXCESS_RESULTS

#define MAX_EXCESS_RESULTS   8

If a client stopped asking for more results, how many more do we receive from the DB before killing the connection? Trade-off between re-doing TCP handshakes and (needlessly) receiving useless results.

Definition at line 49 of file datastore_api.c.

Function Documentation

◆ try_reconnect()

static void try_reconnect ( void *  cls)
static

Try reconnecting to the datastore service.

Parameters
clsthe struct GNUNET_DATASTORE_Handle

Definition at line 890 of file datastore_api.c.

References GNUNET_DATASTORE_Handle::cfg, data, gettext_noop, GNUNET_assert, GNUNET_CLIENT_connect(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_DATASTORE_DATA, GNUNET_MESSAGE_TYPE_DATASTORE_DATA_END, GNUNET_MESSAGE_TYPE_DATASTORE_STATUS, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_TIME_STD_BACKOFF, h, LOG, GNUNET_DATASTORE_Handle::mq, mq_error_handler(), process_queue(), GNUNET_DATASTORE_Handle::reconnect_task, GNUNET_DATASTORE_Handle::retry_time, GNUNET_DATASTORE_Handle::stats, and status.

Referenced by do_disconnect(), and GNUNET_DATASTORE_connect().

891 {
892  struct GNUNET_DATASTORE_Handle *h = cls;
896  struct StatusMessage,
897  h),
900  struct DataMessage,
901  h),
902  GNUNET_MQ_hd_fixed_size (data_end,
904  struct GNUNET_MessageHeader,
905  h),
907  };
908 
910  h->reconnect_task = NULL;
911  GNUNET_assert (NULL == h->mq);
912  h->mq = GNUNET_CLIENT_connect (h->cfg,
913  "datastore",
914  handlers,
916  h);
917  if (NULL == h->mq)
918  return;
920  gettext_noop ("# datastore connections (re)created"),
921  1,
922  GNUNET_NO);
924  "Reconnected to DATASTORE\n");
925  process_queue (h);
926 }
#define GNUNET_MESSAGE_TYPE_DATASTORE_STATUS
Message sent by datastore to client informing about status processing a request (in response to RESER...
struct GNUNET_MQ_Handle * mq
Current connection to the datastore service.
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:901
static void process_queue(struct GNUNET_DATASTORE_Handle *h)
Process entries in the queue (or do nothing if we are already doing so).
struct GNUNET_STATISTICS_Handle * stats
Handle for statistics.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
struct GNUNET_SCHEDULER_Task * reconnect_task
Task for trying to reconnect.
#define GNUNET_NO
Definition: gnunet_common.h:81
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
uint16_t status
See PRISM_STATUS_*-constants.
Message handler for a specific message type.
#define LOG(kind,...)
Definition: datastore_api.c:34
#define GNUNET_MESSAGE_TYPE_DATASTORE_DATA_END
Message sent by datastore to client signaling end of matching data.
Message transmitting content from or to the datastore service.
Definition: datastore.h:196
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
Handle to the datastore service.
Message from datastore service informing client about the success or failure of a requested operation...
Definition: datastore.h:64
struct GNUNET_TIME_Relative retry_time
How quickly should we retry? Used for exponential back-off on connect-errors.
Header for all communications.
static void mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Handle error in sending drop request to datastore.
uint32_t data
The data value.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MESSAGE_TYPE_DATASTORE_DATA
Message sent by datastore to client providing requested data (in response to GET or GET_RANDOM reques...
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_disconnect()

static void do_disconnect ( struct GNUNET_DATASTORE_Handle h)
static

Disconnect from the service and then try reconnecting to the datastore service after some delay.

Parameters
hhandle to datastore to disconnect and reconnect

Definition at line 245 of file datastore_api.c.

References GNUNET_break, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_add_delayed(), GNUNET_DATASTORE_Handle::mq, GNUNET_DATASTORE_Handle::reconnect_task, GNUNET_DATASTORE_Handle::retry_time, GNUNET_DATASTORE_Handle::skip_next_messages, and try_reconnect().

Referenced by get_queue_head(), and mq_error_handler().

246 {
247  if (NULL == h->mq)
248  {
249  GNUNET_break (0);
250  return;
251  }
252  GNUNET_MQ_destroy (h->mq);
253  h->mq = NULL;
254  h->skip_next_messages = 0;
255  h->reconnect_task
257  &try_reconnect,
258  h);
259 }
struct GNUNET_MQ_Handle * mq
Current connection to the datastore service.
static void try_reconnect(void *cls)
Try reconnecting to the datastore service.
struct GNUNET_SCHEDULER_Task * reconnect_task
Task for trying to reconnect.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
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:1246
unsigned int skip_next_messages
We should ignore the next message(s) from the service.
struct GNUNET_TIME_Relative retry_time
How quickly should we retry? Used for exponential back-off on connect-errors.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_queue_entry()

static void free_queue_entry ( struct GNUNET_DATASTORE_QueueEntry qe)
static

Free a queue entry.

Removes the given entry from the queue and releases associated resources. Does NOT call the callback.

Parameters
qeentry to free.

Definition at line 270 of file datastore_api.c.

References GNUNET_DATASTORE_QueueEntry::delay_warn_task, GNUNET_DATASTORE_QueueEntry::env, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_discard(), GNUNET_SCHEDULER_cancel(), h, GNUNET_DATASTORE_QueueEntry::h, GNUNET_DATASTORE_Handle::queue_head, GNUNET_DATASTORE_Handle::queue_size, and GNUNET_DATASTORE_Handle::queue_tail.

Referenced by GNUNET_DATASTORE_cancel(), GNUNET_DATASTORE_disconnect(), handle_data(), handle_data_end(), handle_status(), and mq_error_handler().

271 {
272  struct GNUNET_DATASTORE_Handle *h = qe->h;
273 
275  h->queue_tail,
276  qe);
277  h->queue_size--;
278  if (NULL != qe->env)
279  GNUNET_MQ_discard (qe->env);
280  if (NULL != qe->delay_warn_task)
282  GNUNET_free (qe);
283 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
unsigned int queue_size
Number of entries in the queue.
struct GNUNET_DATASTORE_QueueEntry * queue_tail
Current tail of priority queue.
struct GNUNET_DATASTORE_Handle * h
Handle to the master context.
struct GNUNET_MQ_Envelope * env
Envelope of the request to transmit, NULL after transmission.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
Definition: mq.c:321
struct GNUNET_SCHEDULER_Task * delay_warn_task
Task we run if this entry stalls the queue and we need to warn the user.
Handle to the datastore service.
struct GNUNET_DATASTORE_QueueEntry * queue_head
Current head of priority queue.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ delay_warning()

static void delay_warning ( void *  cls)
static

Task that logs an error after some time.

Parameters
qestruct GNUNET_DATASTORE_QueueEntry about which the error is

Definition at line 292 of file datastore_api.c.

References GNUNET_DATASTORE_QueueEntry::delay_warn_task, DELAY_WARN_TIMEOUT, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_SCHEDULER_add_delayed(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_YES, qe, and GNUNET_DATASTORE_QueueEntry::response_type.

Referenced by process_queue().

293 {
294  struct GNUNET_DATASTORE_QueueEntry *qe = cls;
295 
296  qe->delay_warn_task = NULL;
298  "Request %p of type %u at head of datastore queue for more than %s\n",
299  qe,
300  (unsigned int) qe->response_type,
302  GNUNET_YES));
304  &delay_warning,
305  qe);
306 }
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
static void delay_warning(void *cls)
Task that logs an error after some time.
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:1246
Entry in our priority queue.
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:727
struct GNUNET_SCHEDULER_Task * delay_warn_task
Task we run if this entry stalls the queue and we need to warn the user.
#define GNUNET_log(kind,...)
uint16_t response_type
Expected response type.
#define GNUNET_YES
Definition: gnunet_common.h:80
#define DELAY_WARN_TIMEOUT
Definition: datastore_api.c:36
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mq_error_handler()

static void mq_error_handler ( void *  cls,
enum GNUNET_MQ_Error  error 
)
static

Handle error in sending drop request to datastore.

Parameters
clsclosure with the datastore handle
errorerror code

Definition at line 316 of file datastore_api.c.

References _, StatusContext::cont, StatusContext::cont_cls, GNUNET_DATASTORE_QueueEntry::delay_warn_task, do_disconnect(), GNUNET_DATASTORE_QueueEntry::env, free_queue_entry(), GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_DATASTORE_DATA, GNUNET_MESSAGE_TYPE_DATASTORE_STATUS, GNUNET_SCHEDULER_cancel(), GNUNET_SYSERR, GNUNET_TIME_UNIT_ZERO_ABS, h, LOG, ResultContext::proc, ResultContext::proc_cls, GNUNET_DATASTORE_QueueEntry::qc, qe, GNUNET_DATASTORE_Handle::queue_head, QueueContext::rc, GNUNET_DATASTORE_QueueEntry::response_type, and QueueContext::sc.

Referenced by try_reconnect().

318 {
319  struct GNUNET_DATASTORE_Handle *h = cls;
321 
323  "MQ error, reconnecting to DATASTORE\n");
324  do_disconnect (h);
325  qe = h->queue_head;
326  if (NULL == qe)
327  return;
328  if (NULL != qe->delay_warn_task)
329  {
331  qe->delay_warn_task = NULL;
332  }
333  if (NULL == qe->env)
334  {
335  union QueueContext qc = qe->qc;
336  uint16_t rt = qe->response_type;
337 
339  "Failed to receive response from database.\n");
340  free_queue_entry (qe);
341  switch (rt)
342  {
344  if (NULL != qc.sc.cont)
345  qc.sc.cont (qc.sc.cont_cls,
348  _("DATASTORE disconnected"));
349  break;
351  if (NULL != qc.rc.proc)
352  qc.rc.proc (qc.rc.proc_cls,
353  NULL,
354  0,
355  NULL,
356  0,
357  0,
358  0,
359  0,
361  0);
362  break;
363  default:
364  GNUNET_break (0);
365  }
366  }
367 }
#define GNUNET_MESSAGE_TYPE_DATASTORE_STATUS
Message sent by datastore to client informing about status processing a request (in response to RESER...
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
struct GNUNET_MQ_Envelope * env
Envelope of the request to transmit, NULL after transmission.
void * proc_cls
Closure for proc.
Definition: datastore_api.c:82
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
struct StatusContext sc
Definition: datastore_api.c:93
GNUNET_DATASTORE_DatumProcessor proc
Function to call with the result.
Definition: datastore_api.c:77
struct ResultContext rc
Definition: datastore_api.c:95
static void free_queue_entry(struct GNUNET_DATASTORE_QueueEntry *qe)
Free a queue entry.
Entry in our priority queue.
GNUNET_DATASTORE_ContinuationWithStatus cont
Continuation to call with the status.
Definition: datastore_api.c:59
#define LOG(kind,...)
Definition: datastore_api.c:34
union QueueContext qc
Context for the operation.
struct GNUNET_SCHEDULER_Task * delay_warn_task
Task we run if this entry stalls the queue and we need to warn the user.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
Context for a queue operation.
Definition: datastore_api.c:90
static void do_disconnect(struct GNUNET_DATASTORE_Handle *h)
Disconnect from the service and then try reconnecting to the datastore service after some delay...
Handle to the datastore service.
struct GNUNET_DATASTORE_QueueEntry * queue_head
Current head of priority queue.
uint16_t response_type
Expected response type.
void * cont_cls
Closure for cont.
Definition: datastore_api.c:64
#define GNUNET_MESSAGE_TYPE_DATASTORE_DATA
Message sent by datastore to client providing requested data (in response to GET or GET_RANDOM reques...
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ disconnect_after_drop()

static void disconnect_after_drop ( void *  cls)
static

Task used by to disconnect from the datastore after we send the GNUNET_MESSAGE_TYPE_DATASTORE_DROP message.

Parameters
clsthe datastore handle

Definition at line 404 of file datastore_api.c.

References GNUNET_DATASTORE_disconnect(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_NO, h, and LOG.

Referenced by GNUNET_DATASTORE_disconnect().

405 {
406  struct GNUNET_DATASTORE_Handle *h = cls;
407 
409  "Drop sent, disconnecting\n");
411  GNUNET_NO);
412 }
#define GNUNET_NO
Definition: gnunet_common.h:81
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
#define LOG(kind,...)
Definition: datastore_api.c:34
void GNUNET_DATASTORE_disconnect(struct GNUNET_DATASTORE_Handle *h, int drop)
Disconnect from the datastore service (and free associated resources).
Handle to the datastore service.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ disconnect_on_mq_error()

static void disconnect_on_mq_error ( void *  cls,
enum GNUNET_MQ_Error  error 
)
static

Handle error in sending drop request to datastore.

Parameters
clsclosure with the datastore handle
errorerror code

Definition at line 422 of file datastore_api.c.

References GNUNET_DATASTORE_disconnect(), GNUNET_ERROR_TYPE_ERROR, GNUNET_NO, h, and LOG.

Referenced by GNUNET_DATASTORE_disconnect().

424 {
425  struct GNUNET_DATASTORE_Handle *h = cls;
426 
428  "Failed to ask datastore to drop tables\n");
430  GNUNET_NO);
431 }
#define GNUNET_NO
Definition: gnunet_common.h:81
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
#define LOG(kind,...)
Definition: datastore_api.c:34
void GNUNET_DATASTORE_disconnect(struct GNUNET_DATASTORE_Handle *h, int drop)
Disconnect from the datastore service (and free associated resources).
Handle to the datastore service.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ make_queue_entry()

static struct GNUNET_DATASTORE_QueueEntry* make_queue_entry ( struct GNUNET_DATASTORE_Handle h,
struct GNUNET_MQ_Envelope env,
unsigned int  queue_priority,
unsigned int  max_queue_size,
uint16_t  expected_type,
const union QueueContext qc 
)
static

Create a new entry for our priority queue (and possibly discard other entires if the queue is getting too long).

Parameters
hhandle to the datastore
envenvelope with the message to queue
queue_prioritypriority of the entry
max_queue_sizeat what queue size should this request be dropped (if other requests of higher priority are in the queue)
expected_typewhich type of response do we expect, GNUNET_MESSAGE_TYPE_DATASTORE_STATUS or GNUNET_MESSAGE_TYPE_DATASTORE_DATA
qcclient context (NOT a closure for response_proc)
Returns
NULL if the queue is full

Definition at line 537 of file datastore_api.c.

References env, GNUNET_DATASTORE_QueueEntry::env, gettext_noop, GNUNET_CONTAINER_DLL_insert_after, GNUNET_MQ_discard(), GNUNET_new, GNUNET_NO, GNUNET_STATISTICS_update(), h, GNUNET_DATASTORE_QueueEntry::h, GNUNET_DATASTORE_QueueEntry::max_queue, GNUNET_DATASTORE_QueueEntry::next, GNUNET_DATASTORE_QueueEntry::prev, GNUNET_DATASTORE_QueueEntry::priority, GNUNET_DATASTORE_QueueEntry::qc, qe, GNUNET_DATASTORE_Handle::queue_head, GNUNET_DATASTORE_Handle::queue_size, GNUNET_DATASTORE_Handle::queue_tail, GNUNET_DATASTORE_QueueEntry::response_type, and GNUNET_DATASTORE_Handle::stats.

Referenced by GNUNET_DATASTORE_get_for_replication(), GNUNET_DATASTORE_get_key(), GNUNET_DATASTORE_get_zero_anonymity(), GNUNET_DATASTORE_put(), GNUNET_DATASTORE_release_reserve(), GNUNET_DATASTORE_remove(), and GNUNET_DATASTORE_reserve().

543 {
545  struct GNUNET_DATASTORE_QueueEntry *pos;
546  unsigned int c;
547 
548  if ( (NULL != h->queue_tail) &&
549  (h->queue_tail->priority >= queue_priority) )
550  {
551  c = h->queue_size;
552  pos = NULL;
553  }
554  else
555  {
556  c = 0;
557  pos = h->queue_head;
558  }
559  while ( (NULL != pos) &&
560  (c < max_queue_size) &&
561  (pos->priority >= queue_priority) )
562  {
563  c++;
564  pos = pos->next;
565  }
566  if (c >= max_queue_size)
567  {
569  gettext_noop ("# queue overflows"),
570  1,
571  GNUNET_NO);
572  GNUNET_MQ_discard (env);
573  return NULL;
574  }
576  qe->h = h;
577  qe->env = env;
578  qe->response_type = expected_type;
579  qe->qc = *qc;
580  qe->priority = queue_priority;
581  qe->max_queue = max_queue_size;
582  if (NULL == pos)
583  {
584  /* append at the tail */
585  pos = h->queue_tail;
586  }
587  else
588  {
589  pos = pos->prev;
590  /* do not insert at HEAD if HEAD query was already
591  * transmitted and we are still receiving replies! */
592  if ( (NULL == pos) &&
593  (NULL == h->queue_head->env) )
594  pos = h->queue_head;
595  }
596  c++;
597 #if INSANE_STATISTICS
599  gettext_noop ("# queue entries created"),
600  1,
601  GNUNET_NO);
602 #endif
604  h->queue_tail,
605  pos,
606  qe);
607  h->queue_size++;
608  return qe;
609 }
unsigned int queue_size
Number of entries in the queue.
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
struct GNUNET_DATASTORE_QueueEntry * prev
This is a linked list.
struct GNUNET_DATASTORE_QueueEntry * queue_tail
Current tail of priority queue.
struct GNUNET_DATASTORE_Handle * h
Handle to the master context.
struct GNUNET_STATISTICS_Handle * stats
Handle for statistics.
struct GNUNET_MQ_Envelope * env
Envelope of the request to transmit, NULL after transmission.
#define GNUNET_NO
Definition: gnunet_common.h:81
#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.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
unsigned int max_queue
Maximum allowed length of queue (otherwise this request should be discarded).
Entry in our priority queue.
#define GNUNET_CONTAINER_DLL_insert_after(head, tail, other, element)
Insert an element into a DLL after the given other element.
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
Definition: mq.c:321
union QueueContext qc
Context for the operation.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_DATASTORE_QueueEntry * queue_head
Current head of priority queue.
uint16_t response_type
Expected response type.
struct GNUNET_DATASTORE_QueueEntry * next
This is a linked list.
unsigned int priority
Priority in the queue.
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_queue()

static void process_queue ( struct GNUNET_DATASTORE_Handle h)
static

Process entries in the queue (or do nothing if we are already doing so).

Parameters
hhandle to the datastore

Definition at line 619 of file datastore_api.c.

References GNUNET_DATASTORE_QueueEntry::delay_warn_task, DELAY_WARN_TIMEOUT, delay_warning(), GNUNET_DATASTORE_QueueEntry::env, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MQ_send(), GNUNET_SCHEDULER_add_delayed(), LOG, GNUNET_DATASTORE_Handle::mq, qe, and GNUNET_DATASTORE_Handle::queue_head.

Referenced by get_queue_head(), GNUNET_DATASTORE_cancel(), GNUNET_DATASTORE_get_for_replication(), GNUNET_DATASTORE_get_key(), GNUNET_DATASTORE_get_zero_anonymity(), GNUNET_DATASTORE_put(), GNUNET_DATASTORE_release_reserve(), GNUNET_DATASTORE_remove(), GNUNET_DATASTORE_reserve(), handle_data(), handle_data_end(), handle_status(), and try_reconnect().

620 {
622 
623  if (NULL == (qe = h->queue_head))
624  {
625  /* no entry in queue */
627  "Queue empty\n");
628  return;
629  }
630  if (NULL == qe->env)
631  {
632  /* waiting for replies */
634  "Head request already transmitted\n");
635  return;
636  }
637  if (NULL == h->mq)
638  {
639  /* waiting for reconnect */
641  "Not connected\n");
642  return;
643  }
644  GNUNET_assert (NULL == qe->delay_warn_task);
646  &delay_warning,
647  qe);
648  GNUNET_MQ_send (h->mq,
649  qe->env);
650  qe->env = NULL;
651 }
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
struct GNUNET_MQ_Handle * mq
Current connection to the datastore service.
struct GNUNET_MQ_Envelope * env
Envelope of the request to transmit, NULL after transmission.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static void delay_warning(void *cls)
Task that logs an error after some time.
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:1246
Entry in our priority queue.
#define LOG(kind,...)
Definition: datastore_api.c:34
struct GNUNET_SCHEDULER_Task * delay_warn_task
Task we run if this entry stalls the queue and we need to warn the user.
struct GNUNET_DATASTORE_QueueEntry * queue_head
Current head of priority queue.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
#define DELAY_WARN_TIMEOUT
Definition: datastore_api.c:36
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_queue_head()

static struct GNUNET_DATASTORE_QueueEntry* get_queue_head ( struct GNUNET_DATASTORE_Handle h,
uint16_t  response_type 
)
static

Get the entry at the head of the message queue.

Parameters
hhandle to the datastore
response_typethe expected response type
Returns
the queue entry

Definition at line 662 of file datastore_api.c.

References do_disconnect(), GNUNET_DATASTORE_QueueEntry::env, GNUNET_break, process_queue(), qe, GNUNET_DATASTORE_Handle::queue_head, GNUNET_DATASTORE_QueueEntry::response_type, and GNUNET_DATASTORE_Handle::skip_next_messages.

Referenced by handle_data(), handle_data_end(), and handle_status().

664 {
666 
667  if (h->skip_next_messages > 0)
668  {
669  h->skip_next_messages--;
670  process_queue (h);
671  return NULL;
672  }
673  qe = h->queue_head;
674  if (NULL == qe)
675  {
676  GNUNET_break (0);
677  do_disconnect (h);
678  return NULL;
679  }
680  if (NULL != qe->env)
681  {
682  GNUNET_break (0);
683  do_disconnect (h);
684  return NULL;
685  }
686  if (response_type != qe->response_type)
687  {
688  GNUNET_break (0);
689  do_disconnect (h);
690  return NULL;
691  }
692  return qe;
693 }
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
static void process_queue(struct GNUNET_DATASTORE_Handle *h)
Process entries in the queue (or do nothing if we are already doing so).
struct GNUNET_MQ_Envelope * env
Envelope of the request to transmit, NULL after transmission.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Entry in our priority queue.
unsigned int skip_next_messages
We should ignore the next message(s) from the service.
static void do_disconnect(struct GNUNET_DATASTORE_Handle *h)
Disconnect from the service and then try reconnecting to the datastore service after some delay...
struct GNUNET_DATASTORE_QueueEntry * queue_head
Current head of priority queue.
uint16_t response_type
Expected response type.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_status()

static int check_status ( void *  cls,
const struct StatusMessage sm 
)
static

Function called to check status message from the service.

Parameters
clsclosure
smstatus message received
Returns
GNUNET_OK if the message is well-formed

Definition at line 704 of file datastore_api.c.

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, StatusMessage::header, GNUNET_MessageHeader::size, StatusMessage::status, and status.

706 {
707  uint16_t msize = ntohs (sm->header.size) - sizeof (*sm);
708  int32_t status = ntohl (sm->status);
709 
710  if (msize > 0)
711  {
712  const char *emsg = (const char *) &sm[1];
713 
714  if ('\0' != emsg[msize - 1])
715  {
716  GNUNET_break (0);
717  return GNUNET_SYSERR;
718  }
719  }
720  else if (GNUNET_SYSERR == status)
721  {
722  GNUNET_break (0);
723  return GNUNET_SYSERR;
724  }
725  return GNUNET_OK;
726 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
uint16_t status
See PRISM_STATUS_*-constants.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
int32_t status
Status code, -1 for errors.
Definition: datastore.h:74
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_DATASTORE_STATUS.
Definition: datastore.h:69

◆ handle_status()

static void handle_status ( void *  cls,
const struct StatusMessage sm 
)
static

Function called to handle status message from the service.

Parameters
clsclosure
smstatus message received

Definition at line 736 of file datastore_api.c.

References StatusContext::cont, StatusContext::cont_cls, free_queue_entry(), get_queue_head(), gettext_noop, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_DATASTORE_STATUS, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_ntoh(), GNUNET_TIME_UNIT_ZERO, h, StatusMessage::header, LOG, StatusMessage::min_expiration, process_queue(), GNUNET_DATASTORE_QueueEntry::qc, qe, GNUNET_DATASTORE_Handle::retry_time, QueueContext::sc, GNUNET_MessageHeader::size, GNUNET_DATASTORE_Handle::stats, StatusMessage::status, and status.

738 {
739  struct GNUNET_DATASTORE_Handle *h = cls;
741  struct StatusContext rc;
742  const char *emsg;
743  int32_t status = ntohl (sm->status);
744 
745  qe = get_queue_head (h,
747  if (NULL == qe)
748  return;
749  rc = qe->qc.sc;
750  free_queue_entry (qe);
751  if (ntohs (sm->header.size) > sizeof (struct StatusMessage))
752  emsg = (const char *) &sm[1];
753  else
754  emsg = NULL;
756  "Received status %d/%s\n",
757  (int) status,
758  emsg);
760  gettext_noop ("# status messages received"),
761  1,
762  GNUNET_NO);
764  process_queue (h);
765  if (NULL != rc.cont)
766  rc.cont (rc.cont_cls,
767  status,
769  emsg);
770 }
#define GNUNET_MESSAGE_TYPE_DATASTORE_STATUS
Message sent by datastore to client informing about status processing a request (in response to RESER...
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:670
static void process_queue(struct GNUNET_DATASTORE_Handle *h)
Process entries in the queue (or do nothing if we are already doing so).
struct GNUNET_STATISTICS_Handle * stats
Handle for statistics.
struct GNUNET_TIME_AbsoluteNBO min_expiration
Minimum expiration time required for content to be stored by the datacache at this time...
Definition: datastore.h:80
#define GNUNET_NO
Definition: gnunet_common.h:81
static struct GNUNET_DATASTORE_QueueEntry * get_queue_head(struct GNUNET_DATASTORE_Handle *h, uint16_t response_type)
Get the entry at the head of the message queue.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
struct StatusContext sc
Definition: datastore_api.c:93
static void free_queue_entry(struct GNUNET_DATASTORE_QueueEntry *qe)
Free a queue entry.
Entry in our priority queue.
uint16_t status
See PRISM_STATUS_*-constants.
#define LOG(kind,...)
Definition: datastore_api.c:34
union QueueContext qc
Context for the operation.
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
Handle to the datastore service.
Message from datastore service informing client about the success or failure of a requested operation...
Definition: datastore.h:64
struct GNUNET_TIME_Relative retry_time
How quickly should we retry? Used for exponential back-off on connect-errors.
int32_t status
Status code, -1 for errors.
Definition: datastore.h:74
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_DATASTORE_STATUS.
Definition: datastore.h:69
Context for processing status messages.
Definition: datastore_api.c:54
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:

◆ check_data()

static int check_data ( void *  cls,
const struct DataMessage dm 
)
static

Check data message we received from the service.

Parameters
clsclosure with the struct GNUNET_DATASTORE_Handle *
dmmessage received

Definition at line 780 of file datastore_api.c.

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, DataMessage::header, DataMessage::size, and GNUNET_MessageHeader::size.

782 {
783  uint16_t msize = ntohs (dm->header.size) - sizeof (*dm);
784 
785  if (msize != ntohl (dm->size))
786  {
787  GNUNET_break (0);
788  return GNUNET_SYSERR;
789  }
790  return GNUNET_OK;
791 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
uint32_t size
Number of bytes in the item (NBO).
Definition: datastore.h:214
struct GNUNET_MessageHeader header
Type is either GNUNET_MESSAGE_TYPE_DATASTORE_PUT, GNUNET_MESSAGE_TYPE_DATASTORE_REMOVE or GNUNET_MESS...
Definition: datastore.h:204

◆ handle_data()

static void handle_data ( void *  cls,
const struct DataMessage dm 
)
static

Handle data message we got from the service.

Parameters
clsclosure with the struct GNUNET_DATASTORE_Handle *
dmmessage received

Definition at line 801 of file datastore_api.c.

References DataMessage::anonymity, DataMessage::expiration, free_queue_entry(), get_queue_head(), gettext_noop, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_MESSAGE_TYPE_DATASTORE_DATA, GNUNET_NO, GNUNET_ntohll(), GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_ntoh(), GNUNET_TIME_UNIT_ZERO, h, DataMessage::key, LOG, DataMessage::priority, ResultContext::proc, ResultContext::proc_cls, process_queue(), qe, DataMessage::replication, GNUNET_DATASTORE_Handle::retry_time, DataMessage::size, GNUNET_DATASTORE_Handle::stats, DataMessage::type, and DataMessage::uid.

803 {
804  struct GNUNET_DATASTORE_Handle *h = cls;
806  struct ResultContext rc;
807 
808  qe = get_queue_head (h,
810  if (NULL == qe)
811  return;
812 #if INSANE_STATISTICS
814  gettext_noop ("# Results received"),
815  1,
816  GNUNET_NO);
817 #endif
819  "Received result %llu with type %u and size %u with key %s\n",
820  (unsigned long long) GNUNET_ntohll (dm->uid),
821  ntohl (dm->type),
822  ntohl (dm->size),
823  GNUNET_h2s (&dm->key));
824  rc = qe->qc.rc;
825  free_queue_entry (qe);
827  process_queue (h);
828  if (NULL != rc.proc)
829  rc.proc (rc.proc_cls,
830  &dm->key,
831  ntohl (dm->size),
832  &dm[1],
833  ntohl (dm->type),
834  ntohl (dm->priority),
835  ntohl (dm->anonymity),
836  ntohl (dm->replication),
838  GNUNET_ntohll (dm->uid));
839 }
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:670
struct GNUNET_TIME_AbsoluteNBO expiration
Expiration time (NBO); zero for remove.
Definition: datastore.h:252
uint32_t type
Type of the item (NBO), zero for remove, (actually an enum GNUNET_BLOCK_Type)
Definition: datastore.h:219
static void process_queue(struct GNUNET_DATASTORE_Handle *h)
Process entries in the queue (or do nothing if we are already doing so).
struct GNUNET_STATISTICS_Handle * stats
Handle for statistics.
#define GNUNET_NO
Definition: gnunet_common.h:81
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
static struct GNUNET_DATASTORE_QueueEntry * get_queue_head(struct GNUNET_DATASTORE_Handle *h, uint16_t response_type)
Get the entry at the head of the message queue.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
static void free_queue_entry(struct GNUNET_DATASTORE_QueueEntry *qe)
Free a queue entry.
Entry in our priority queue.
#define LOG(kind,...)
Definition: datastore_api.c:34
uint32_t replication
Desired replication level.
Definition: datastore.h:234
uint32_t size
Number of bytes in the item (NBO).
Definition: datastore.h:214
uint32_t anonymity
Desired anonymity level (NBO), zero for remove.
Definition: datastore.h:229
Context for processing result messages.
Definition: datastore_api.c:72
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
uint64_t uid
Unique ID for the content (can be used for UPDATE); can be zero for remove (which indicates that the ...
Definition: datastore.h:247
struct GNUNET_HashCode key
Key under which the item can be found.
Definition: datastore.h:257
uint32_t priority
Priority of the item (NBO), zero for remove.
Definition: datastore.h:224
Handle to the datastore service.
struct GNUNET_TIME_Relative retry_time
How quickly should we retry? Used for exponential back-off on connect-errors.
#define GNUNET_MESSAGE_TYPE_DATASTORE_DATA
Message sent by datastore to client providing requested data (in response to GET or GET_RANDOM reques...
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:

◆ handle_data_end()

static void handle_data_end ( void *  cls,
const struct GNUNET_MessageHeader msg 
)
static

Type of a function to call when we receive a GNUNET_MESSAGE_TYPE_DATASTORE_DATA_END message from the service.

Parameters
clsclosure with the struct GNUNET_DATASTORE_Handle *
msgmessage received

Definition at line 850 of file datastore_api.c.

References free_queue_entry(), get_queue_head(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_DATASTORE_DATA, GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO_ABS, h, LOG, ResultContext::proc, ResultContext::proc_cls, process_queue(), qe, GNUNET_DATASTORE_Handle::queue_size, GNUNET_DATASTORE_Handle::result_count, and GNUNET_DATASTORE_Handle::retry_time.

852 {
853  struct GNUNET_DATASTORE_Handle *h = cls;
855  struct ResultContext rc;
856 
857  qe = get_queue_head (h,
859  if (NULL == qe)
860  return;
861  rc = qe->qc.rc;
862  free_queue_entry (qe);
864  "Received end of result set, new queue size is %u\n",
865  h->queue_size);
867  h->result_count = 0;
868  process_queue (h);
869  /* signal end of iteration */
870  if (NULL != rc.proc)
871  rc.proc (rc.proc_cls,
872  NULL,
873  0,
874  NULL,
875  0,
876  0,
877  0,
878  0,
880  0);
881 }
unsigned int queue_size
Number of entries in the queue.
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
static void process_queue(struct GNUNET_DATASTORE_Handle *h)
Process entries in the queue (or do nothing if we are already doing so).
unsigned int result_count
Number of results we&#39;re receiving for the current query after application stopped to care...
static struct GNUNET_DATASTORE_QueueEntry * get_queue_head(struct GNUNET_DATASTORE_Handle *h, uint16_t response_type)
Get the entry at the head of the message queue.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
static void free_queue_entry(struct GNUNET_DATASTORE_QueueEntry *qe)
Free a queue entry.
Entry in our priority queue.
#define LOG(kind,...)
Definition: datastore_api.c:34
Context for processing result messages.
Definition: datastore_api.c:72
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
Handle to the datastore service.
struct GNUNET_TIME_Relative retry_time
How quickly should we retry? Used for exponential back-off on connect-errors.
#define GNUNET_MESSAGE_TYPE_DATASTORE_DATA
Message sent by datastore to client providing requested data (in response to GET or GET_RANDOM reques...
Here is the call graph for this function:

◆ drop_status_cont()

static void drop_status_cont ( void *  cls,
int32_t  result,
struct GNUNET_TIME_Absolute  min_expiration,
const char *  emsg 
)
static

Dummy continuation used to do nothing (but be non-zero).

Parameters
clsclosure
resultresult
min_expirationexpiration time
emsgerror message

Definition at line 938 of file datastore_api.c.

Referenced by GNUNET_DATASTORE_release_reserve(), GNUNET_DATASTORE_remove(), and GNUNET_DATASTORE_reserve().

942 {
943  /* do nothing */
944 }
Here is the caller graph for this function: