GNUnet 0.22.2
curl_reschedule.c File Reference

API for event loop integration with GNUnet SCHEDULER. More...

#include "platform.h"
#include <jansson.h>
#include "gnunet_curl_lib.h"
#include "gnunet_util_lib.h"
#include "curl_internal.h"
Include dependency graph for curl_reschedule.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_CURL_RescheduleContext
 Closure for GNUNET_CURL_gnunet_scheduler_reschedule(). More...
 

Functions

struct GNUNET_CURL_RescheduleContextGNUNET_CURL_gnunet_rc_create_with_parser (struct GNUNET_CURL_Context *ctx, GNUNET_CURL_RawParser rp, GNUNET_CURL_ResponseCleaner rc)
 Initialize reschedule context; with custom response parser. More...
 
static void clean_result (void *response)
 Just a wrapper to avoid casting of function pointers. More...
 
struct GNUNET_CURL_RescheduleContextGNUNET_CURL_gnunet_rc_create (struct GNUNET_CURL_Context *ctx)
 Initialize reschedule context. More...
 
void GNUNET_CURL_gnunet_rc_destroy (struct GNUNET_CURL_RescheduleContext *rc)
 Destroy reschedule context. More...
 
static void context_task (void *cls)
 Task that runs the context's event loop with the GNUnet scheduler. More...
 
void GNUNET_CURL_gnunet_scheduler_reschedule (void *cls)
 Implementation of the GNUNET_CURL_RescheduleCallback for GNUnet's scheduler. More...
 

Detailed Description

API for event loop integration with GNUnet SCHEDULER.

Author
Christian Grothoff

Definition in file curl_reschedule.c.

Function Documentation

◆ clean_result()

static void clean_result ( void *  response)
static

Just a wrapper to avoid casting of function pointers.

Parameters
responsethe (JSON) response to clean.

Definition at line 80 of file curl_reschedule.c.

81{
82 json_decref (response);
83}
static struct MHD_Response * response
Our canonical response.

References response.

Referenced by GNUNET_CURL_gnunet_rc_create().

Here is the caller graph for this function:

◆ context_task()

static void context_task ( void *  cls)
static

Task that runs the context's event loop with the GNUnet scheduler.

Parameters
clsa struct GNUNET_CURL_RescheduleContext *

Definition at line 114 of file curl_reschedule.c.

115{
116 struct GNUNET_CURL_RescheduleContext *rc = cls;
117 long timeout;
118 int max_fd;
119 fd_set read_fd_set;
120 fd_set write_fd_set;
121 fd_set except_fd_set;
122 struct GNUNET_NETWORK_FDSet *rs;
123 struct GNUNET_NETWORK_FDSet *ws;
124 struct GNUNET_TIME_Relative delay;
125
126 rc->task = NULL;
127 GNUNET_CURL_perform2 (rc->ctx, rc->parser, rc->cleaner);
128 max_fd = -1;
129 timeout = -1;
130 FD_ZERO (&read_fd_set);
131 FD_ZERO (&write_fd_set);
132 FD_ZERO (&except_fd_set);
134 &read_fd_set,
135 &write_fd_set,
136 &except_fd_set,
137 &max_fd,
138 &timeout);
139 if (timeout >= 0)
140 delay =
142 timeout);
143 else
147 &read_fd_set,
148 max_fd + 1);
151 &write_fd_set,
152 max_fd + 1);
153 if (NULL == rc->task)
155 delay,
156 rs,
157 ws,
159 rc);
162}
static void context_task(void *cls)
Task that runs the context's event loop with the GNUnet scheduler.
static struct GNUNET_TIME_Relative timeout
User defined timestamp for completing operations.
Definition: gnunet-arm.c:118
void GNUNET_CURL_get_select_info(struct GNUNET_CURL_Context *ctx, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, int *max_fd, long *timeout)
Obtain the information for a select() call to wait until GNUNET_CURL_perform() is ready again.
Definition: curl.c:834
void GNUNET_CURL_perform2(struct GNUNET_CURL_Context *ctx, GNUNET_CURL_RawParser rp, GNUNET_CURL_ResponseCleaner rc)
Run the main event loop for the HTTP interaction.
Definition: curl.c:753
@ GNUNET_SCHEDULER_PRIORITY_DEFAULT
Run with the default priority (normal P2P operations).
void GNUNET_NETWORK_fdset_destroy(struct GNUNET_NETWORK_FDSet *fds)
Releases the associated memory of an fd set.
Definition: network.c:1185
void GNUNET_NETWORK_fdset_copy_native(struct GNUNET_NETWORK_FDSet *to, const fd_set *from, int nfds)
Copy a native fd set into the GNUnet representation.
Definition: network.c:1041
struct GNUNET_NETWORK_FDSet * GNUNET_NETWORK_fdset_create(void)
Creates an fd set.
Definition: network.c:1169
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_select(enum GNUNET_SCHEDULER_Priority prio, struct GNUNET_TIME_Relative delay, const struct GNUNET_NETWORK_FDSet *rs, const struct GNUNET_NETWORK_FDSet *ws, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay or when any of the specified file descriptor set...
Definition: scheduler.c:1835
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition: time.c:486
Closure for GNUNET_CURL_gnunet_scheduler_reschedule().
struct GNUNET_SCHEDULER_Task * task
Just the task.
GNUNET_CURL_RawParser parser
Parser of the raw response.
struct GNUNET_CURL_Context * ctx
Context we manage.
GNUNET_CURL_ResponseCleaner cleaner
Deallocate the response object.
collection of IO descriptors
Time for relative time used by GNUnet, in microseconds.

References GNUNET_CURL_RescheduleContext::cleaner, context_task(), GNUNET_CURL_RescheduleContext::ctx, GNUNET_CURL_get_select_info(), GNUNET_CURL_perform2(), GNUNET_NETWORK_fdset_copy_native(), GNUNET_NETWORK_fdset_create(), GNUNET_NETWORK_fdset_destroy(), GNUNET_SCHEDULER_add_select(), GNUNET_SCHEDULER_PRIORITY_DEFAULT, GNUNET_TIME_relative_multiply(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TIME_UNIT_MILLISECONDS, GNUNET_CURL_RescheduleContext::parser, GNUNET_CURL_RescheduleContext::task, and timeout.

Referenced by context_task(), and GNUNET_CURL_gnunet_scheduler_reschedule().

Here is the call graph for this function:
Here is the caller graph for this function: