jabberd2  2.3.3
Data Structures | Macros | Typedefs | Enumerations | Functions
mio.h File Reference

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_stmio_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...
 

Detailed Description

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.

Macro Definition Documentation

#define JABBERD2_API   extern

Definition at line 39 of 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)
#define mio_write (   m,
  fd 
)    (*m)->mio_write(m, fd)
#define mio_read (   m,
  fd 
)    (*m)->mio_read(m, fd)
#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
#define MIO_SETERROR (   e)    (errno = e)

Definition at line 169 of file mio.h.

Referenced by _mio_connect().

#define MIO_STRERROR (   e)    strerror(e)
#define MIO_WOULDBLOCK   (errno == EWOULDBLOCK || errno == EINTR || errno == EAGAIN)

Typedef Documentation

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)

Definition at line 107 of file mio.h.

typedef struct mio_st ** mio_t

Enumeration Type Documentation

these are the actions and a handler type assigned by the applicaiton using mio

Enumerator
action_ACCEPT 
action_READ 
action_WRITE 
action_CLOSE 

Definition at line 106 of file mio.h.

Function Documentation

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