Added static inline wrappers to simplify calls to I/O engine functions.

This commit is contained in:
henri 2013-01-23 22:06:40 +00:00
parent a7f2788b26
commit b4400d0a44
3 changed files with 33 additions and 8 deletions

View file

@ -114,7 +114,7 @@ int socket_count_zero(msiod *iod, mspool *ms) {
#if HAVE_PCAP
iod->readpcapsd_count = 0;
#endif
return ms->engine->iod_unregister(ms, iod);
return nsock_engine_iod_unregister(ms, iod);
}
static int socket_count_read_inc(msiod *iod) {
@ -205,9 +205,9 @@ static void update_events(msiod * iod, mspool *ms, int ev_inc, int ev_dec) {
if (!IOD_PROPGET(iod, IOD_REGISTERED)) {
assert(clrmask == EV_NONE);
ms->engine->iod_register(ms, iod, setmask);
nsock_engine_iod_register(ms, iod, setmask);
} else {
ms->engine->iod_modify(ms, iod, setmask, clrmask);
nsock_engine_iod_modify(ms, iod, setmask, clrmask);
}
}
@ -474,10 +474,10 @@ void handle_connect_result(mspool *ms, msevent *nse, enum nse_status status) {
nsock_log_info(ms, "EID %li reconnecting with SSL_OP_NO_SSLv2", nse->id);
saved_ev = iod->watched_events;
ms->engine->iod_unregister(ms, iod);
nsock_engine_iod_unregister(ms, iod);
close(iod->sd);
nsock_connect_internal(ms, nse, SOCK_STREAM, iod->lastproto, &iod->peer, iod->peerlen, nsi_peerport(iod));
ms->engine->iod_register(ms, iod, saved_ev);
nsock_engine_iod_register(ms, iod, saved_ev);
SSL_clear(iod->ssl);
if(!SSL_clear(iod->ssl))
@ -912,7 +912,7 @@ enum nsock_loopstatus nsock_loop(nsock_pool nsp, int msec_timeout) {
}
}
if (ms->engine->loop(ms, msecs_left) == -1) {
if (nsock_engine_loop(ms, msecs_left) == -1) {
quitstatus = NSOCK_LOOP_ERROR;
break;
}

View file

@ -386,6 +386,31 @@ struct io_engine {
int (*loop)(mspool *nsp, int msec_timeout);
};
/* ----------- NSOCK I/O ENGINE CONVENIENCE WRAPPERS ------------ */
static inline int nsock_engine_init(mspool *nsp) {
return nsp->engine->init(nsp);
}
static inline void nsock_engine_destroy(mspool *nsp) {
nsp->engine->destroy(nsp);
return;
}
static inline int nsock_engine_iod_register(mspool *nsp, msiod *iod, int ev) {
return nsp->engine->iod_register(nsp, iod, ev);
}
static inline int nsock_engine_iod_unregister(mspool *nsp, msiod *iod) {
return nsp->engine->iod_unregister(nsp, iod);
}
static inline int nsock_engine_iod_modify(mspool *nsp, msiod *iod, int ev_set, int ev_clr) {
return nsp->engine->iod_modify(nsp, iod, ev_set, ev_clr);
}
static inline int nsock_engine_loop(mspool *nsp, int msec_timeout) {
return nsp->engine->loop(nsp, msec_timeout);
}
/* ------------------- PROTOTYPES ------------------- */

View file

@ -158,7 +158,7 @@ nsock_pool nsp_new(void *userdata) {
nsp->userdata = userdata;
nsp->engine = get_io_engine();
nsp->engine->init(nsp);
nsock_engine_init(nsp);
/* initialize IO events lists */
gh_list_init(&nsp->connect_events);
@ -252,7 +252,7 @@ void nsp_delete(nsock_pool ms_pool) {
gh_list_free(&nsp->free_iods);
gh_list_free(&nsp->free_events);
nsp->engine->destroy(nsp);
nsock_engine_destroy(nsp);
#if HAVE_OPENSSL
if (nsp->sslctx != NULL)