jabberd2
2.3.2
|
mio - manage i/o More...
#include "util/inaddr.h"
#include "ac-stdint.h"
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <stdarg.h>
Go to the source code of this file.
Data Structures | |
struct | mio_fd_st |
struct | mio_st |
Macros | |
#define | JABBERD2_API extern |
#define | MIO_MAXFD 1024 |
#define | mio_free(m) (*m)->mio_free(m) |
#define | mio_listen(m, port, sourceip, app, arg) (*m)->mio_listen(m, port, sourceip, app, arg) |
for creating a new listen socket in this mio (returns new fd or <0) More... | |
#define | mio_connect(m, port, hostip, srcip, app, arg) (*m)->mio_connect(m, port, hostip, srcip, app, arg) |
for creating a new socket connected to this ip:port (returns new fd or <0, use mio_read/write first) More... | |
#define | mio_register(m, fd, app, arg) (*m)->mio_register(m, fd, app, arg) |
for adding an existing socket connected to this mio More... | |
#define | mio_app(m, fd, app, arg) (*m)->mio_app(m, fd, app, arg) |
re-set the app handler More... | |
#define | mio_close(m, fd) (*m)->mio_close(m, fd) |
request that mio close this fd More... | |
#define | mio_write(m, fd) (*m)->mio_write(m, fd) |
mio should try the write action on this fd now More... | |
#define | mio_read(m, fd) (*m)->mio_read(m, fd) |
process read events for this fd More... | |
#define | mio_run(m, timeout) (*m)->mio_run(m, timeout) |
give some cpu time to mio to check it's sockets, 0 is non-blocking More... | |
#define | MIO_ERROR errno |
all MIO related routines should use those for error reporting More... | |
#define | MIO_SETERROR(e) (errno = e) |
#define | MIO_STRERROR(e) strerror(e) |
#define | MIO_WOULDBLOCK (errno == EWOULDBLOCK || errno == EINTR || errno == EAGAIN) |
Typedefs | |
typedef struct mio_fd_st * | mio_fd_t |
typedef int(* | mio_handler_t )(struct mio_st **m, mio_action_t a, struct mio_fd_st *fd, void *data, void *arg) |
typedef struct mio_st ** | mio_t |
Enumerations | |
enum | mio_action_t { action_ACCEPT, action_READ, action_WRITE, action_CLOSE } |
these are the actions and a handler type assigned by the applicaiton using mio More... | |
Functions | |
JABBERD2_API mio_t | mio_new (int maxfd) |
create/free the mio subsytem More... | |
mio - manage i/o
This is the most simple fd wrapper possible. It is also customized per-app and may be limited/extended depending on needs.
It's basically our own implementation of libevent or libev.
Usage is pretty simple:
Note: normal fd's don't get events unless the app calls mio_read/write() first!
Definition in file mio.h.
#define MIO_MAXFD 1024 |
Definition at line 46 of file mio.h.
Referenced by JABBER_MAIN().
#define mio_free | ( | m | ) | (*m)->mio_free(m) |
Definition at line 137 of file mio.h.
Referenced by JABBER_MAIN().
#define mio_listen | ( | m, | |
port, | |||
sourceip, | |||
app, | |||
arg | |||
) | (*m)->mio_listen(m, port, sourceip, app, arg) |
for creating a new listen socket in this mio (returns new fd or <0)
Definition at line 140 of file mio.h.
Referenced by c2s_router_sx_callback(), JABBER_MAIN(), and s2s_router_sx_callback().
#define mio_connect | ( | m, | |
port, | |||
hostip, | |||
srcip, | |||
app, | |||
arg | |||
) | (*m)->mio_connect(m, port, hostip, srcip, app, arg) |
for creating a new socket connected to this ip:port (returns new fd or <0, use mio_read/write first)
Definition at line 144 of file mio.h.
Referenced by _c2s_router_connect(), _s2s_router_connect(), _sm_router_connect(), and out_route().
#define mio_register | ( | m, | |
fd, | |||
app, | |||
arg | |||
) | (*m)->mio_register(m, fd, app, arg) |
for adding an existing socket connected to this mio
Definition at line 148 of file mio.h.
Referenced by _pbx_open_pipe(), and JABBER_MAIN().
#define mio_app | ( | m, | |
fd, | |||
app, | |||
arg | |||
) | (*m)->mio_app(m, fd, app, arg) |
re-set the app handler
Definition at line 152 of file mio.h.
Referenced by _c2s_client_mio_callback(), in_mio_callback(), JABBER_MAIN(), and router_mio_callback().
#define mio_close | ( | m, | |
fd | |||
) | (*m)->mio_close(m, fd) |
request that mio close this fd
Definition at line 155 of file mio.h.
Referenced by _c2s_client_sx_callback(), _in_sx_callback(), _out_sx_callback(), _pbx_close_pipe(), c2s_router_sx_callback(), JABBER_MAIN(), s2s_router_sx_callback(), and sm_sx_callback().
#define mio_write | ( | m, | |
fd | |||
) | (*m)->mio_write(m, fd) |
mio should try the write action on this fd now
Definition at line 158 of file mio.h.
Referenced by _c2s_client_sx_callback(), _in_sx_callback(), _mio__connect(), _out_sx_callback(), _pbx_write_pipe(), _router_sx_callback(), c2s_router_sx_callback(), s2s_router_sx_callback(), and sm_sx_callback().
#define mio_read | ( | m, | |
fd | |||
) | (*m)->mio_read(m, fd) |
process read events for this fd
Definition at line 161 of file mio.h.
Referenced by _c2s_client_sx_callback(), _in_sx_callback(), _mio__connect(), _mio_listen(), _out_sx_callback(), _pbx_read_pipe(), _router_sx_callback(), c2s_router_sx_callback(), JABBER_MAIN(), s2s_router_sx_callback(), and sm_sx_callback().
#define mio_run | ( | m, | |
timeout | |||
) | (*m)->mio_run(m, timeout) |
give some cpu time to mio to check it's sockets, 0 is non-blocking
Definition at line 164 of file mio.h.
Referenced by JABBER_MAIN().
#define MIO_ERROR errno |
all MIO related routines should use those for error reporting
Definition at line 168 of file mio.h.
Referenced by _c2s_client_sx_callback(), _c2s_router_connect(), _in_sx_callback(), _mio_connect(), _mio_run(), _out_sx_callback(), _s2s_router_connect(), _sm_router_connect(), c2s_router_sx_callback(), JABBER_MAIN(), out_route(), s2s_router_sx_callback(), and sm_sx_callback().
#define MIO_SETERROR | ( | e | ) | (errno = e) |
Definition at line 169 of file mio.h.
Referenced by _mio_connect().
#define MIO_STRERROR | ( | e | ) | strerror(e) |
Definition at line 170 of file mio.h.
Referenced by _c2s_client_sx_callback(), _c2s_router_connect(), _in_sx_callback(), _mio_connect(), _out_sx_callback(), _s2s_router_connect(), _sm_router_connect(), c2s_router_sx_callback(), JABBER_MAIN(), out_route(), s2s_router_sx_callback(), and sm_sx_callback().
#define MIO_WOULDBLOCK (errno == EWOULDBLOCK || errno == EINTR || errno == EAGAIN) |
Definition at line 171 of file mio.h.
Referenced by _c2s_client_sx_callback(), _in_sx_callback(), _out_sx_callback(), _router_sx_callback(), c2s_router_sx_callback(), s2s_router_sx_callback(), and sm_sx_callback().
typedef int(* mio_handler_t)(struct mio_st **m, mio_action_t a, struct mio_fd_st *fd, void *data, void *arg) |
enum mio_action_t |
JABBERD2_API mio_t mio_new | ( | int | maxfd | ) |
create/free the mio subsytem
Definition at line 38 of file mio.c.
References mio_epoll_new(), mio_kqueue_new(), mio_poll_new(), mio_select_new(), and mio_wsasync_new().
Referenced by JABBER_MAIN().