diff --git a/libcharybdis/commio.c b/libcharybdis/commio.c index ac09126c..c7dfe1a4 100644 --- a/libcharybdis/commio.c +++ b/libcharybdis/commio.c @@ -58,6 +58,26 @@ static void comm_connect_dns_callback(void *vptr, struct DNSReply *reply); static PF comm_connect_tryconnect; static int comm_max_connections = 0; +static int +comm_read_raw(fde_t *F, void *buf, size_t count) +{ + s_assert(F != NULL); + s_assert(buf != NULL); + s_assert(count > 0); + + return read(F->fd, buf, count); +} + +static int +comm_write_raw(fde_t *F, const void *buf, size_t count) +{ + s_assert(F != NULL); + s_assert(buf != NULL); + s_assert(count > 0); + + return write(F->fd, buf, count); +} + inline fde_t * comm_locate_fd(int fd) { @@ -88,8 +108,8 @@ comm_add_fd(int fd) F = MyMalloc(sizeof(fde_t)); F->fd = fd; - F->read_impl = read; - F->write_impl = write; + F->read_impl = comm_read_raw; + F->write_impl = comm_write_raw; list = &fd_table[fd % FD_HASH_SIZE]; dlinkAdd(F, &F->node, list); diff --git a/libcharybdis/commio.h b/libcharybdis/commio.h index 3100e6f8..a22db1ad 100644 --- a/libcharybdis/commio.h +++ b/libcharybdis/commio.h @@ -32,12 +32,14 @@ #include "ircd_defs.h" #include "tools.h" +typedef struct _fde fde_t; + /* Callback for completed IO events */ typedef void PF(int fd, void *); /* virtual function types for I/O --nenolod */ -typedef void IOFuncRead(int fd, void *buf, size_t count); -typedef void IOFuncWrite(int fd, const void *buf, size_t count); +typedef int IOFuncRead(fde_t *, void *buf, size_t count); +typedef int IOFuncWrite(fde_t *, const void *buf, size_t count); /* Callback for completed connections */ /* int fd, int status, void * */ @@ -80,8 +82,6 @@ typedef enum fdlist_t } fdlist_t; -typedef struct _fde fde_t; - extern int highest_fd; extern int number_fd; @@ -115,8 +115,8 @@ struct _fde void *flush_data; time_t flush_timeout; - IOReadFunc *read_impl; - IOWriteFunc *write_impl; + IOFuncRead *read_impl; + IOFuncWrite *write_impl; struct DNSQuery *dns_query; struct