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 881 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().

882 {
883  struct GNUNET_DATASTORE_Handle *h = cls;
887  struct StatusMessage,
888  h),
891  struct DataMessage,
892  h),
893  GNUNET_MQ_hd_fixed_size(data_end,
895  struct GNUNET_MessageHeader,
896  h),
898  };
899 
901  h->reconnect_task = NULL;
902  GNUNET_assert(NULL == h->mq);
903  h->mq = GNUNET_CLIENT_connect(h->cfg,
904  "datastore",
905  handlers,
907  h);
908  if (NULL == h->mq)
909  return;
911  gettext_noop("# datastore connections (re)created"),
912  1,
913  GNUNET_NO);
915  "Reconnected to DATASTORE\n");
916  process_queue(h);
917 }
#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:900
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: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:185
#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:63
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 232 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().

233 {
234  if (NULL == h->mq)
235  {
236  GNUNET_break(0);
237  return;
238  }
239  GNUNET_MQ_destroy(h->mq);
240  h->mq = NULL;
241  h->skip_next_messages = 0;
242  h->reconnect_task
244  &try_reconnect,
245  h);
246 }
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:1237
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:821
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 257 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().

258 {
259  struct GNUNET_DATASTORE_Handle *h = qe->h;
260 
262  h->queue_tail,
263  qe);
264  h->queue_size--;
265  if (NULL != qe->env)
266  GNUNET_MQ_discard(qe->env);
267  if (NULL != qe->delay_warn_task)
269  GNUNET_free(qe);
270 }
#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:319
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:956
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 279 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().

280 {
281  struct GNUNET_DATASTORE_QueueEntry *qe = cls;
282 
283  qe->delay_warn_task = NULL;
285  "Request %p of type %u at head of datastore queue for more than %s\n",
286  qe,
287  (unsigned int)qe->response_type,
289  GNUNET_YES));
291  &delay_warning,
292  qe);
293 }
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:1237
Entry in our priority queue.
Definition: datastore_api.c:96
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:686
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 303 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().

305 {
306  struct GNUNET_DATASTORE_Handle *h = cls;
308 
310  "MQ error, reconnecting to DATASTORE\n");
311  do_disconnect(h);
312  qe = h->queue_head;
313  if (NULL == qe)
314  return;
315  if (NULL != qe->delay_warn_task)
316  {
318  qe->delay_warn_task = NULL;
319  }
320  if (NULL == qe->env)
321  {
322  union QueueContext qc = qe->qc;
323  uint16_t rt = qe->response_type;
324 
326  "Failed to receive response from database.\n");
327  free_queue_entry(qe);
328  switch (rt)
329  {
331  if (NULL != qc.sc.cont)
332  qc.sc.cont(qc.sc.cont_cls,
335  _("DATASTORE disconnected"));
336  break;
337 
339  if (NULL != qc.rc.proc)
340  qc.rc.proc(qc.rc.proc_cls,
341  NULL,
342  0,
343  NULL,
344  0,
345  0,
346  0,
347  0,
349  0);
350  break;
351 
352  default:
353  GNUNET_break(0);
354  }
355  }
356 }
#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:79
#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:181
struct StatusContext sc
Definition: datastore_api.c:87
GNUNET_DATASTORE_DatumProcessor proc
Function to call with the result.
Definition: datastore_api.c:74
struct ResultContext rc
Definition: datastore_api.c:89
static void free_queue_entry(struct GNUNET_DATASTORE_QueueEntry *qe)
Free a queue entry.
Entry in our priority queue.
Definition: datastore_api.c:96
GNUNET_DATASTORE_ContinuationWithStatus cont
Continuation to call with the status.
Definition: datastore_api.c:58
#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:86
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:63
#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:956
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 393 of file datastore_api.c.

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

Referenced by GNUNET_DATASTORE_disconnect().

394 {
395  struct GNUNET_DATASTORE_Handle *h = cls;
396 
398  "Drop sent, disconnecting\n");
400  GNUNET_NO);
401 }
#define GNUNET_NO
Definition: gnunet_common.h:78
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 411 of file datastore_api.c.

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

Referenced by GNUNET_DATASTORE_disconnect().

413 {
414  struct GNUNET_DATASTORE_Handle *h = cls;
415 
417  "Failed to ask datastore to drop tables\n");
419  GNUNET_NO);
420 }
#define GNUNET_NO
Definition: gnunet_common.h:78
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 528 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().

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

611 {
613 
614  if (NULL == (qe = h->queue_head))
615  {
616  /* no entry in queue */
618  "Queue empty\n");
619  return;
620  }
621  if (NULL == qe->env)
622  {
623  /* waiting for replies */
625  "Head request already transmitted\n");
626  return;
627  }
628  if (NULL == h->mq)
629  {
630  /* waiting for reconnect */
632  "Not connected\n");
633  return;
634  }
635  GNUNET_assert(NULL == qe->delay_warn_task);
637  &delay_warning,
638  qe);
639  GNUNET_MQ_send(h->mq,
640  qe->env);
641  qe->env = NULL;
642 }
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:1237
Entry in our priority queue.
Definition: datastore_api.c:96
#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:351
#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 653 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().

655 {
657 
658  if (h->skip_next_messages > 0)
659  {
660  h->skip_next_messages--;
661  process_queue(h);
662  return NULL;
663  }
664  qe = h->queue_head;
665  if (NULL == qe)
666  {
667  GNUNET_break(0);
668  do_disconnect(h);
669  return NULL;
670  }
671  if (NULL != qe->env)
672  {
673  GNUNET_break(0);
674  do_disconnect(h);
675  return NULL;
676  }
677  if (response_type != qe->response_type)
678  {
679  GNUNET_break(0);
680  do_disconnect(h);
681  return NULL;
682  }
683  return qe;
684 }
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:96
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 695 of file datastore_api.c.

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

697 {
698  uint16_t msize = ntohs(sm->header.size) - sizeof(*sm);
699  int32_t status = ntohl(sm->status);
700 
701  if (msize > 0)
702  {
703  const char *emsg = (const char *)&sm[1];
704 
705  if ('\0' != emsg[msize - 1])
706  {
707  GNUNET_break(0);
708  return GNUNET_SYSERR;
709  }
710  }
711  else if (GNUNET_SYSERR == status)
712  {
713  GNUNET_break(0);
714  return GNUNET_SYSERR;
715  }
716  return GNUNET_OK;
717 }
#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:72
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_DATASTORE_STATUS.
Definition: datastore.h:67

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

729 {
730  struct GNUNET_DATASTORE_Handle *h = cls;
732  struct StatusContext rc;
733  const char *emsg;
734  int32_t status = ntohl(sm->status);
735 
736  qe = get_queue_head(h,
738  if (NULL == qe)
739  return;
740  rc = qe->qc.sc;
741  free_queue_entry(qe);
742  if (ntohs(sm->header.size) > sizeof(struct StatusMessage))
743  emsg = (const char *)&sm[1];
744  else
745  emsg = NULL;
747  "Received status %d/%s\n",
748  (int)status,
749  emsg);
751  gettext_noop("# status messages received"),
752  1,
753  GNUNET_NO);
755  process_queue(h);
756  if (NULL != rc.cont)
757  rc.cont(rc.cont_cls,
758  status,
760  emsg);
761 }
#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:671
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:78
#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:94
struct StatusContext sc
Definition: datastore_api.c:87
static void free_queue_entry(struct GNUNET_DATASTORE_QueueEntry *qe)
Free a queue entry.
Entry in our priority queue.
Definition: datastore_api.c:96
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:63
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:72
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_DATASTORE_STATUS.
Definition: datastore.h:67
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 771 of file datastore_api.c.

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

773 {
774  uint16_t msize = ntohs(dm->header.size) - sizeof(*dm);
775 
776  if (msize != ntohl(dm->size))
777  {
778  GNUNET_break(0);
779  return GNUNET_SYSERR;
780  }
781  return GNUNET_OK;
782 }
#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:202
struct GNUNET_MessageHeader header
Type is either GNUNET_MESSAGE_TYPE_DATASTORE_PUT, GNUNET_MESSAGE_TYPE_DATASTORE_REMOVE or GNUNET_MESS...
Definition: datastore.h:192

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

794 {
795  struct GNUNET_DATASTORE_Handle *h = cls;
797  struct ResultContext rc;
798 
799  qe = get_queue_head(h,
801  if (NULL == qe)
802  return;
803 #if INSANE_STATISTICS
805  gettext_noop("# Results received"),
806  1,
807  GNUNET_NO);
808 #endif
810  "Received result %llu with type %u and size %u with key %s\n",
811  (unsigned long long)GNUNET_ntohll(dm->uid),
812  ntohl(dm->type),
813  ntohl(dm->size),
814  GNUNET_h2s(&dm->key));
815  rc = qe->qc.rc;
816  free_queue_entry(qe);
818  process_queue(h);
819  if (NULL != rc.proc)
820  rc.proc(rc.proc_cls,
821  &dm->key,
822  ntohl(dm->size),
823  &dm[1],
824  ntohl(dm->type),
825  ntohl(dm->priority),
826  ntohl(dm->anonymity),
827  ntohl(dm->replication),
829  GNUNET_ntohll(dm->uid));
830 }
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:671
struct GNUNET_TIME_AbsoluteNBO expiration
Expiration time (NBO); zero for remove.
Definition: datastore.h:240
uint32_t type
Type of the item (NBO), zero for remove, (actually an enum GNUNET_BLOCK_Type)
Definition: datastore.h:207
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:94
static void free_queue_entry(struct GNUNET_DATASTORE_QueueEntry *qe)
Free a queue entry.
Entry in our priority queue.
Definition: datastore_api.c:96
#define LOG(kind,...)
Definition: datastore_api.c:34
uint32_t replication
Desired replication level.
Definition: datastore.h:222
uint32_t size
Number of bytes in the item (NBO).
Definition: datastore.h:202
uint32_t anonymity
Desired anonymity level (NBO), zero for remove.
Definition: datastore.h:217
Context for processing result messages.
Definition: datastore_api.c:70
#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:235
struct GNUNET_HashCode key
Key under which the item can be found.
Definition: datastore.h:245
uint32_t priority
Priority of the item (NBO), zero for remove.
Definition: datastore.h:212
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 841 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.

843 {
844  struct GNUNET_DATASTORE_Handle *h = cls;
846  struct ResultContext rc;
847 
848  qe = get_queue_head(h,
850  if (NULL == qe)
851  return;
852  rc = qe->qc.rc;
853  free_queue_entry(qe);
855  "Received end of result set, new queue size is %u\n",
856  h->queue_size);
858  h->result_count = 0;
859  process_queue(h);
860  /* signal end of iteration */
861  if (NULL != rc.proc)
862  rc.proc(rc.proc_cls,
863  NULL,
864  0,
865  NULL,
866  0,
867  0,
868  0,
869  0,
871  0);
872 }
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.
Definition: datastore_api.c:96
#define LOG(kind,...)
Definition: datastore_api.c:34
Context for processing result messages.
Definition: datastore_api.c:70
#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 929 of file datastore_api.c.

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

933 {
934  /* do nothing */
935 }
Here is the caller graph for this function: