Dillo v3.1.1-119-g140d9ebd
|
Dillo's event driven IO engine. More...
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include "../msg.h"
#include "../chain.h"
#include "../klist.h"
#include "IO.h"
#include "iowatch.hh"
#include "tls.h"
Go to the source code of this file.
Macros | |
#define | IO_StopRd 1 |
#define | IO_StopWr 2 |
#define | IO_StopRdWr (IO_StopRd | IO_StopWr) |
Functions | |
void | a_IO_ccc (int Op, int Branch, int Dir, ChainLink *Info, void *Data1, void *Data2) |
CCC function for the IO module. | |
static IOData_t * | IO_new (int op) |
Return a new, initialized, 'io' struct. | |
static void | IO_ins (IOData_t *io) |
Register an IO in ValidIOs. | |
static void | IO_del (IOData_t *io) |
Remove an IO from ValidIOs. | |
static IOData_t * | IO_get (int Key) |
Return a io by its Key (NULL if not found) | |
static void | IO_free (IOData_t *io) |
Free an 'io' struct. | |
static void | IO_close_fd (IOData_t *io, int CloseCode) |
Close an open FD, and remove io controls. | |
static bool_t | IO_read (IOData_t *io) |
Read data from a file descriptor into a specific buffer. | |
static bool_t | IO_write (IOData_t *io) |
Write data, from a specific buffer, into a file descriptor. | |
static int | IO_callback (IOData_t *io) |
Handle background IO for a given FD (reads | writes). | |
static void | IO_fd_read_cb (int fd, void *data) |
Handle the READ event of a FD. | |
static void | IO_fd_write_cb (int fd, void *data) |
Handle the WRITE event of a FD. | |
static void | IO_submit (IOData_t *r_io) |
Receive an IO request (IORead | IOWrite), Set a watch for it, and let it flow! | |
Variables | |
static Klist_t * | ValidIOs = NULL |
Dillo's event driven IO engine.
Definition in file IO.c.
void a_IO_ccc | ( | int | Op, |
int | Branch, | ||
int | Dir, | ||
ChainLink * | Info, | ||
void * | Data1, | ||
void * | Data2 | ||
) |
CCC function for the IO module.
( Data1 = IOData_t* ; Data2 = NULL )
Definition at line 359 of file IO.c.
References a_Chain_check(), a_Chain_dbuf_new(), a_Chain_fcb(), BCK, DataBuf::Buf, dFree(), dReturn_if_fail, dStr_append_l(), dStr_printable(), IO_close_fd(), IO_free(), IO_new(), IO_StopRd, IO_StopRdWr, IO_StopWr, IO_submit(), IORead, IOWrite, ChainLink::LocalKey, MSG, MSG_WARN, OpAbort, OpEnd, OpSend, OpStart, and DataBuf::Size.
Referenced by a_Dpi_ccc(), a_Http_ccc(), IO_fd_read_cb(), IO_fd_write_cb(), and IO_read().
|
static |
Handle background IO for a given FD (reads | writes).
(This function gets called when there's activity in the FD)
Definition at line 265 of file IO.c.
References _MSG, FALSE, IO_read(), IO_write(), IORead, and IOWrite.
Referenced by IO_fd_read_cb(), and IO_fd_write_cb().
|
static |
Close an open FD, and remove io controls.
(This function can be used for Close and Abort operations) BUG: there's a race condition for Abort. The file descriptor is closed twice, and it could be reused for something else in between. It's simple to fix, but it'd be better to design a canonical way to Abort the CCC.
Definition at line 125 of file IO.c.
References _MSG, a_IOwatch_remove_fd(), dClose(), DIO_READ, DIO_WRITE, IO_del(), IO_StopRd, IO_StopRdWr, and IO_StopWr.
Referenced by a_IO_ccc().
|
static |
Remove an IO from ValidIOs.
Definition at line 92 of file IO.c.
References _MSG, a_Klist_length(), a_Klist_remove(), and ValidIOs.
Referenced by IO_close_fd().
|
static |
Handle the READ event of a FD.
Definition at line 283 of file IO.c.
References a_IO_ccc(), a_IOwatch_remove_fd(), DIO_READ, FWD, IO_callback(), IO_get(), MSG_ERR, OpAbort, and VOIDP2INT.
Referenced by IO_submit().
|
static |
Handle the WRITE event of a FD.
Definition at line 306 of file IO.c.
References a_IO_ccc(), a_IOwatch_remove_fd(), DIO_WRITE, FWD, IO_callback(), IO_get(), MSG_ERR, OpAbort, and VOIDP2INT.
Referenced by IO_submit().
|
static |
Free an 'io' struct.
Definition at line 112 of file IO.c.
References dFree(), and dStr_free().
Referenced by a_IO_ccc().
|
static |
Return a io by its Key (NULL if not found)
Definition at line 104 of file IO.c.
References a_Klist_get_data(), and ValidIOs.
Referenced by IO_fd_read_cb(), IO_fd_write_cb(), and IO_read().
|
static |
Register an IO in ValidIOs.
Definition at line 80 of file IO.c.
References _MSG, a_Klist_insert(), a_Klist_length(), and ValidIOs.
Referenced by IO_submit().
|
static |
Return a new, initialized, 'io' struct.
Definition at line 64 of file IO.c.
References dNew0, dStr_sized_new(), and IOBufLen.
Referenced by a_IO_ccc().
|
static |
Read data from a file descriptor into a specific buffer.
Definition at line 157 of file IO.c.
References _MSG, a_IO_ccc(), a_Tls_connection(), a_Tls_read(), dStr_append_l(), dStr_truncate(), FALSE, FWD, IO_get(), IOBufLen, MSG, OpEnd, OpSend, and TRUE.
Referenced by IO_callback().
|
static |
Receive an IO request (IORead | IOWrite), Set a watch for it, and let it flow!
Definition at line 328 of file IO.c.
References _MSG, a_IOwatch_add_fd(), DIO_READ, DIO_WRITE, INT2VOIDP, IO_fd_read_cb(), IO_fd_write_cb(), IO_ins(), IORead, IOWrite, and MSG_ERR.
Referenced by a_IO_ccc().
|
static |
Write data, from a specific buffer, into a file descriptor.
Definition at line 219 of file IO.c.
References _MSG, a_Tls_connection(), a_Tls_write(), dStr_erase(), dStr_truncate(), FALSE, MSG, and TRUE.
Referenced by IO_callback().