The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Macros | Functions
io.c File Reference

Implement asynchronous callbacks for curl. More...

#include <freeradius-devel/curl/base.h>
#include <freeradius-devel/server/module.h>
#include <freeradius-devel/unlang/interpret.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/syserror.h>
+ Include dependency graph for io.c:

Go to the source code of this file.

Macros

#define SET_MOPTION(_mandle, _opt, _val)
 

Functions

static void _fr_curl_io_demux (fr_curl_handle_t *mhandle, CURLM *mandle)
 De-queue curl requests and wake up the requests that initiated them. More...
 
static int _fr_curl_io_event_modify (UNUSED CURL *easy, curl_socket_t fd, int what, void *ctx, UNUSED void *fd_ctx)
 Called by libcurl to register a socket that it's intefr_curled in receiving IO events for. More...
 
static int _fr_curl_io_request_free (fr_curl_io_request_t *randle)
 
static void _fr_curl_io_service (fr_curl_handle_t *mhandle, int fd, int event)
 Service an IO event on a file descriptor. More...
 
static void _fr_curl_io_service_errored (UNUSED fr_event_list_t *el, int fd, int flags, int fd_errno, void *uctx)
 File descriptor experienced an error. More...
 
static void _fr_curl_io_service_readable (UNUSED fr_event_list_t *el, int fd, UNUSED int flags, void *uctx)
 File descriptor became readable. More...
 
static void _fr_curl_io_service_writable (UNUSED fr_event_list_t *el, int fd, UNUSED int flags, void *uctx)
 File descriptor became writable. More...
 
static void _fr_curl_io_timer_expired (UNUSED fr_event_list_t *el, UNUSED fr_time_t now, void *uctx)
 libcurl's timer expired More...
 
static int _fr_curl_io_timer_modify (CURLM *mandle, long timeout_ms, void *ctx)
 Callback called by libcurl to set/unset timers. More...
 
static int _mhandle_free (fr_curl_handle_t *mhandle)
 Free the multi-handle. More...
 
static int curl_debug_log (UNUSED CURL *candle, curl_infotype type, char *data, size_t len, void *uctx)
 Callback to receive debugging data from libcurl. More...
 
fr_curl_handle_tfr_curl_io_init (TALLOC_CTX *ctx, fr_event_list_t *el, UNUSED bool multiplex)
 Performs the libcurl initialisation of the thread. More...
 
fr_curl_io_request_tfr_curl_io_request_alloc (TALLOC_CTX *ctx)
 Allocate a new curl easy request and wrapper struct. More...
 
int fr_curl_io_request_enqueue (fr_curl_handle_t *mhandle, request_t *request, fr_curl_io_request_t *randle)
 Sends a request using libcurl. More...
 

Detailed Description

Implement asynchronous callbacks for curl.

Id
b72064bb98a3e1e49d61f15f5941c5cb9465dbc7

Definition in file io.c.

Macro Definition Documentation

◆ SET_MOPTION

#define SET_MOPTION (   _mandle,
  _opt,
  _val 
)
Value:
do {\
if ((ret = curl_multi_setopt(mandle, _opt, _val)) != CURLM_OK) {\
option = STRINGIFY(_opt);\
goto error;\
}\
} while (0)
#define STRINGIFY(x)
Definition: build.h:195

Definition at line 38 of file io.c.

Function Documentation

◆ _fr_curl_io_demux()

static void _fr_curl_io_demux ( fr_curl_handle_t mhandle,
CURLM *  mandle 
)
inlinestatic

De-queue curl requests and wake up the requests that initiated them.

Parameters
[in]mhandlecontaining the event loop and request counter.
[in]mandleto dequeue curl easy handles/responses from.

Definition at line 51 of file io.c.

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

◆ _fr_curl_io_event_modify()

static int _fr_curl_io_event_modify ( UNUSED CURL *  easy,
curl_socket_t  fd,
int  what,
void *  ctx,
UNUSED void *  fd_ctx 
)
static

Called by libcurl to register a socket that it's intefr_curled in receiving IO events for.

Parameters
[in]easyhandle this fd relates to.
[in]fdFile descriptor curl wants to be notified about.
[in]whatWhich events libcurl wants to be notified of, may be one of:
  • CURL_POLL_IN Wait for incoming data. For the socket to become readable.
  • CURL_POLL_OUT Wait for outgoing data. For the socket to become writable.
  • CURL_POLL_INOUT Wait for incoming and outgoing data. For the socket to become readable or writable.
  • CURL_POLL_REMOVE The specified socket/file descriptor is no longer used by libcurl.
[in]ctxThe fr_curl_handle_t specific to this thread.
[in]fd_ctxPrivate data associated with the socket.

Definition at line 327 of file io.c.

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

◆ _fr_curl_io_request_free()

static int _fr_curl_io_request_free ( fr_curl_io_request_t randle)
static

Definition at line 536 of file io.c.

+ Here is the caller graph for this function:

◆ _fr_curl_io_service()

static void _fr_curl_io_service ( fr_curl_handle_t mhandle,
int  fd,
int  event 
)
inlinestatic

Service an IO event on a file descriptor.

Parameters
[in]mhandlecontaining the event loop and request counter.
[in]fdthe IO event occurred for.
[in]eventtype.

Definition at line 151 of file io.c.

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

◆ _fr_curl_io_service_errored()

static void _fr_curl_io_service_errored ( UNUSED fr_event_list_t el,
int  fd,
int  flags,
int  fd_errno,
void *  uctx 
)
static

File descriptor experienced an error.

Parameters
[in]elfd was registered with.
[in]fdthat errored.
[in]flagsfrom kevent.
[in]fd_errnofrom kevent.
[in]uctxThe rlm_fr_curl_thread_t specific to this thread.

Definition at line 205 of file io.c.

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

◆ _fr_curl_io_service_readable()

static void _fr_curl_io_service_readable ( UNUSED fr_event_list_t el,
int  fd,
UNUSED int  flags,
void *  uctx 
)
static

File descriptor became readable.

Parameters
[in]elfd was registered with.
[in]fdthat became readable.
[in]flagsfrom kevent.
[in]uctxThe rlm_fr_curl_thread_t specific to this thread.

Definition at line 251 of file io.c.

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

◆ _fr_curl_io_service_writable()

static void _fr_curl_io_service_writable ( UNUSED fr_event_list_t el,
int  fd,
UNUSED int  flags,
void *  uctx 
)
static

File descriptor became writable.

Parameters
[in]elfd was registered with.
[in]fdthat became writable.
[in]flagsfrom kevent.
[in]uctxThe rlm_fr_curl_thread_t specific to this thread.

Definition at line 235 of file io.c.

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

◆ _fr_curl_io_timer_expired()

static void _fr_curl_io_timer_expired ( UNUSED fr_event_list_t el,
UNUSED fr_time_t  now,
void *  uctx 
)
static

libcurl's timer expired

Parameters
[in]elthe timer was inserted into.
[in]nowThe current time according to the event loop.
[in]uctxThe rlm_fr_curl_thread_t specific to this thread.

Definition at line 124 of file io.c.

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

◆ _fr_curl_io_timer_modify()

static int _fr_curl_io_timer_modify ( CURLM *  mandle,
long  timeout_ms,
void *  ctx 
)
static

Callback called by libcurl to set/unset timers.

Each rlm_fr_curl_thread_t has a timer event which is controller by libcurl. This allows libcurl to honour timeouts set on requests to remote hosts, and means we don't need to set timeouts for individual I/O events.

Parameters
[in]mandlehandle requesting the timer be set/unset.
[in]timeout_msIf > 0, how long to wait before calling curl_multi_socket_action. If == 0, we call curl_multi_socket_action as soon as possible. If < 0, we delete the timer.
[in]ctxThe rlm_fr_curl_thread_t specific to this thread.
Returns
  • 0 on success.
  • -1 on error.

Definition at line 275 of file io.c.

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

◆ _mhandle_free()

static int _mhandle_free ( fr_curl_handle_t mhandle)
static

Free the multi-handle.

Definition at line 567 of file io.c.

+ Here is the caller graph for this function:

◆ curl_debug_log()

static int curl_debug_log ( UNUSED CURL *  candle,
curl_infotype  type,
char *  data,
size_t  len,
void *  uctx 
)
static

Callback to receive debugging data from libcurl.

Note
Should only be set on a handle if RDEBUG_ENABLED3 is true.
Parameters
[in]candleCurl handle the debugging data pertains to.
[in]typeThe type of debugging data we received.
[in]dataBuffer containing debug data (not \0 terminated). Despite the type being char *, this can be binary data depending on the curl_infotype.
[in]lenThe length of the data in the buffer.
[in]uctxThe current request.
Returns
  • 0 (we always indicate success)

Definition at line 401 of file io.c.

+ Here is the caller graph for this function:

◆ fr_curl_io_init()

fr_curl_handle_t* fr_curl_io_init ( TALLOC_CTX *  ctx,
fr_event_list_t el,
UNUSED bool  multiplex 
)

Performs the libcurl initialisation of the thread.

Parameters
[in]ctxto alloc handle in.
[in]elto initial.
[in]multiplexRun multiple requests over the same connection simultaneously. HTTP/2 only.
Returns
  • 0 on success.
  • -1 on error.

Definition at line 584 of file io.c.

+ Here is the call graph for this function:

◆ fr_curl_io_request_alloc()

fr_curl_io_request_t* fr_curl_io_request_alloc ( TALLOC_CTX *  ctx)

Allocate a new curl easy request and wrapper struct.

Definition at line 546 of file io.c.

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

◆ fr_curl_io_request_enqueue()

int fr_curl_io_request_enqueue ( fr_curl_handle_t mhandle,
request_t request,
fr_curl_io_request_t randle 
)

Sends a request using libcurl.

Send the actual curl request to the server. The response will be handled by the numerous callbacks configured for the easy handle.

Parameters
[in]mhandleThread-specific mhandle wrapper.
[in]requestCurrent request.
[in]randlerepresenting the request.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 482 of file io.c.

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