GNUnet  0.11.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 886 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().

887 {
888  struct GNUNET_DATASTORE_Handle *h = cls;
892  struct StatusMessage,
893  h),
896  struct DataMessage,
897  h),
898  GNUNET_MQ_hd_fixed_size (data_end,
900  struct GNUNET_MessageHeader,
901  h),
903  };
904 
906  h->reconnect_task = NULL;
907  GNUNET_assert (NULL == h->mq);
908  h->mq = GNUNET_CLIENT_connect (h->cfg,
909  "datastore",
910  handlers,
912  h);
913  if (NULL == h->mq)
914  return;
916  gettext_noop (
917  "# datastore connections (re)created"),
918  1,
919  GNUNET_NO);
921  "Reconnected to DATASTORE\n");
922  process_queue (h);
923 }
#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:1057
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: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.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
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:191
#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 237 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().

238 {
239  if (NULL == h->mq)
240  {
241  GNUNET_break (0);
242  return;
243  }
244  GNUNET_MQ_destroy (h->mq);
245  h->mq = NULL;
246  h->skip_next_messages = 0;
247  h->reconnect_task
249  &try_reconnect,
250  h);
251 }
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:1253
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 262 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().

263 {
264  struct GNUNET_DATASTORE_Handle *h = qe->h;
265 
267  h->queue_tail,
268  qe);
269  h->queue_size--;
270  if (NULL != qe->env)
271  GNUNET_MQ_discard (qe->env);
272  if (NULL != qe->delay_warn_task)
274  GNUNET_free (qe);
275 }
#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:99
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:966
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 284 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().

285 {
286  struct GNUNET_DATASTORE_QueueEntry *qe = cls;
287 
288  qe->delay_warn_task = NULL;
290  "Request %p of type %u at head of datastore queue for more than %s\n",
291  qe,
292  (unsigned int) qe->response_type,
294  GNUNET_YES));
296  &delay_warning,
297  qe);
298 }
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:1253
Entry in our priority queue.
Definition: datastore_api.c:99
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_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:77
#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 308 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().

310 {
311  struct GNUNET_DATASTORE_Handle *h = cls;
313 
315  "MQ error, reconnecting to DATASTORE\n");
316  do_disconnect (h);
317  qe = h->queue_head;
318  if (NULL == qe)
319  return;
320  if (NULL != qe->delay_warn_task)
321  {
323  qe->delay_warn_task = NULL;
324  }
325  if (NULL == qe->env)
326  {
327  union QueueContext qc = qe->qc;
328  uint16_t rt = qe->response_type;
329 
331  "Failed to receive response from database.\n");
332  free_queue_entry (qe);
333  switch (rt)
334  {
336  if (NULL != qc.sc.cont)
337  qc.sc.cont (qc.sc.cont_cls,
340  _ ("DATASTORE disconnected"));
341  break;
342 
344  if (NULL != qc.rc.proc)
345  qc.rc.proc (qc.rc.proc_cls,
346  NULL,
347  0,
348  NULL,
349  0,
350  0,
351  0,
352  0,
354  0);
355  break;
356 
357  default:
358  GNUNET_break (0);
359  }
360  }
361 }
#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:81
#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:99
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
struct StatusContext sc
Definition: datastore_api.c:90
GNUNET_DATASTORE_DatumProcessor proc
Function to call with the result.
Definition: datastore_api.c:76
struct ResultContext rc
Definition: datastore_api.c:92
static void free_queue_entry(struct GNUNET_DATASTORE_QueueEntry *qe)
Free a queue entry.
Entry in our priority queue.
Definition: datastore_api.c:99
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:76
Context for a queue operation.
Definition: datastore_api.c:88
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:966
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 398 of file datastore_api.c.

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

Referenced by GNUNET_DATASTORE_disconnect().

399 {
400  struct GNUNET_DATASTORE_Handle *h = cls;
401 
403  "Drop sent, disconnecting\n");
405  GNUNET_NO);
406 }
#define GNUNET_NO
Definition: gnunet_common.h:78
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
#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 416 of file datastore_api.c.

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

Referenced by GNUNET_DATASTORE_disconnect().

418 {
419  struct GNUNET_DATASTORE_Handle *h = cls;
420 
422  "Failed to ask datastore to drop tables\n");
424  GNUNET_NO);
425 }
#define GNUNET_NO
Definition: gnunet_common.h:78
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
#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 533 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().

539 {
541  struct GNUNET_DATASTORE_QueueEntry *pos;
542  unsigned int c;
543 
544  if ((NULL != h->queue_tail) &&
545  (h->queue_tail->priority >= queue_priority))
546  {
547  c = h->queue_size;
548  pos = NULL;
549  }
550  else
551  {
552  c = 0;
553  pos = h->queue_head;
554  }
555  while ((NULL != pos) &&
556  (c < max_queue_size) &&
557  (pos->priority >= queue_priority))
558  {
559  c++;
560  pos = pos->next;
561  }
562  if (c >= max_queue_size)
563  {
565  gettext_noop ("# queue overflows"),
566  1,
567  GNUNET_NO);
568  GNUNET_MQ_discard (env);
569  return NULL;
570  }
572  qe->h = h;
573  qe->env = env;
574  qe->response_type = expected_type;
575  qe->qc = *qc;
576  qe->priority = queue_priority;
577  qe->max_queue = max_queue_size;
578  if (NULL == pos)
579  {
580  /* append at the tail */
581  pos = h->queue_tail;
582  }
583  else
584  {
585  pos = pos->prev;
586  /* do not insert at HEAD if HEAD query was already
587  * transmitted and we are still receiving replies! */
588  if ((NULL == pos) &&
589  (NULL == h->queue_head->env))
590  pos = h->queue_head;
591  }
592  c++;
593 #if INSANE_STATISTICS
595  gettext_noop ("# queue entries created"),
596  1,
597  GNUNET_NO);
598 #endif
600  h->queue_tail,
601  pos,
602  qe);
603  h->queue_size++;
604  return qe;
605 }
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: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.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
unsigned int max_queue
Maximum allowed length of queue (otherwise this request should be discarded).
Entry in our priority queue.
Definition: datastore_api.c:99
#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 615 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().

616 {
618 
619  if (NULL == (qe = h->queue_head))
620  {
621  /* no entry in queue */
623  "Queue empty\n");
624  return;
625  }
626  if (NULL == qe->env)
627  {
628  /* waiting for replies */
630  "Head request already transmitted\n");
631  return;
632  }
633  if (NULL == h->mq)
634  {
635  /* waiting for reconnect */
637  "Not connected\n");
638  return;
639  }
640  GNUNET_assert (NULL == qe->delay_warn_task);
642  &delay_warning,
643  qe);
644  GNUNET_MQ_send (h->mq,
645  qe->env);
646  qe->env = NULL;
647 }
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:1253
Entry in our priority queue.
Definition: datastore_api.c:99
#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 658 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().

660 {
662 
663  if (h->skip_next_messages > 0)
664  {
665  h->skip_next_messages--;
666  process_queue (h);
667  return NULL;
668  }
669  qe = h->queue_head;
670  if (NULL == qe)
671  {
672  GNUNET_break (0);
673  do_disconnect (h);
674  return NULL;
675  }
676  if (NULL != qe->env)
677  {
678  GNUNET_break (0);
679  do_disconnect (h);
680  return NULL;
681  }
682  if (response_type != qe->response_type)
683  {
684  GNUNET_break (0);
685  do_disconnect (h);
686  return NULL;
687  }
688  return qe;
689 }
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.
Definition: datastore_api.c:99
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 700 of file datastore_api.c.

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

702 {
703  uint16_t msize = ntohs (sm->header.size) - sizeof(*sm);
704  int32_t status = ntohl (sm->status);
705 
706  if (msize > 0)
707  {
708  const char *emsg = (const char *) &sm[1];
709 
710  if ('\0' != emsg[msize - 1])
711  {
712  GNUNET_break (0);
713  return GNUNET_SYSERR;
714  }
715  }
716  else if (GNUNET_SYSERR == status)
717  {
718  GNUNET_break (0);
719  return GNUNET_SYSERR;
720  }
721  return GNUNET_OK;
722 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
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:76
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 732 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.

734 {
735  struct GNUNET_DATASTORE_Handle *h = cls;
737  struct StatusContext rc;
738  const char *emsg;
739  int32_t status = ntohl (sm->status);
740 
741  qe = get_queue_head (h,
743  if (NULL == qe)
744  return;
745  rc = qe->qc.sc;
746  free_queue_entry (qe);
747  if (ntohs (sm->header.size) > sizeof(struct StatusMessage))
748  emsg = (const char *) &sm[1];
749  else
750  emsg = NULL;
752  "Received status %d/%s\n",
753  (int) status,
754  emsg);
756  gettext_noop ("# status messages received"),
757  1,
758  GNUNET_NO);
760  process_queue (h);
761  if (NULL != rc.cont)
762  rc.cont (rc.cont_cls,
763  status,
765  emsg);
766 }
#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:673
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:78
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:99
struct StatusContext sc
Definition: datastore_api.c:90
static void free_queue_entry(struct GNUNET_DATASTORE_QueueEntry *qe)
Free a queue entry.
Entry in our priority queue.
Definition: datastore_api.c:99
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 776 of file datastore_api.c.

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

778 {
779  uint16_t msize = ntohs (dm->header.size) - sizeof(*dm);
780 
781  if (msize != ntohl (dm->size))
782  {
783  GNUNET_break (0);
784  return GNUNET_SYSERR;
785  }
786  return GNUNET_OK;
787 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
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:76
uint32_t size
Number of bytes in the item (NBO).
Definition: datastore.h:209
struct GNUNET_MessageHeader header
Type is either GNUNET_MESSAGE_TYPE_DATASTORE_PUT, GNUNET_MESSAGE_TYPE_DATASTORE_REMOVE or GNUNET_MESS...
Definition: datastore.h:199

◆ 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 797 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.

799 {
800  struct GNUNET_DATASTORE_Handle *h = cls;
802  struct ResultContext rc;
803 
804  qe = get_queue_head (h,
806  if (NULL == qe)
807  return;
808 #if INSANE_STATISTICS
810  gettext_noop ("# Results received"),
811  1,
812  GNUNET_NO);
813 #endif
815  "Received result %llu with type %u and size %u with key %s\n",
816  (unsigned long long) GNUNET_ntohll (dm->uid),
817  ntohl (dm->type),
818  ntohl (dm->size),
819  GNUNET_h2s (&dm->key));
820  rc = qe->qc.rc;
821  free_queue_entry (qe);
823  process_queue (h);
824  if (NULL != rc.proc)
825  rc.proc (rc.proc_cls,
826  &dm->key,
827  ntohl (dm->size),
828  &dm[1],
829  ntohl (dm->type),
830  ntohl (dm->priority),
831  ntohl (dm->anonymity),
832  ntohl (dm->replication),
834  GNUNET_ntohll (dm->uid));
835 }
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:673
struct GNUNET_TIME_AbsoluteNBO expiration
Expiration time (NBO); zero for remove.
Definition: datastore.h:247
uint32_t type
Type of the item (NBO), zero for remove, (actually an enum GNUNET_BLOCK_Type)
Definition: datastore.h:214
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:78
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:99
static void free_queue_entry(struct GNUNET_DATASTORE_QueueEntry *qe)
Free a queue entry.
Entry in our priority queue.
Definition: datastore_api.c:99
#define LOG(kind,...)
Definition: datastore_api.c:34
uint32_t replication
Desired replication level.
Definition: datastore.h:229
uint32_t size
Number of bytes in the item (NBO).
Definition: datastore.h:209
uint32_t anonymity
Desired anonymity level (NBO), zero for remove.
Definition: datastore.h:224
Context for processing result messages.
Definition: datastore_api.c:71
#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:242
struct GNUNET_HashCode key
Key under which the item can be found.
Definition: datastore.h:252
uint32_t priority
Priority of the item (NBO), zero for remove.
Definition: datastore.h:219
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 846 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.

848 {
849  struct GNUNET_DATASTORE_Handle *h = cls;
851  struct ResultContext rc;
852 
853  qe = get_queue_head (h,
855  if (NULL == qe)
856  return;
857  rc = qe->qc.rc;
858  free_queue_entry (qe);
860  "Received end of result set, new queue size is %u\n",
861  h->queue_size);
863  h->result_count = 0;
864  process_queue (h);
865  /* signal end of iteration */
866  if (NULL != rc.proc)
867  rc.proc (rc.proc_cls,
868  NULL,
869  0,
870  NULL,
871  0,
872  0,
873  0,
874  0,
876  0);
877 }
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:99
static void free_queue_entry(struct GNUNET_DATASTORE_QueueEntry *qe)
Free a queue entry.
Entry in our priority queue.
Definition: datastore_api.c:99
#define LOG(kind,...)
Definition: datastore_api.c:34
Context for processing result messages.
Definition: datastore_api.c:71
#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 935 of file datastore_api.c.

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

939 {
940  /* do nothing */
941 }
Here is the caller graph for this function: