Make fde raw I/O functions act on the FDE object, not the FD directly.

This commit is contained in:
William Pitcock 2007-12-22 16:15:09 -06:00
parent 5893220fdc
commit d877759f5b
2 changed files with 28 additions and 8 deletions

View file

@ -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);

View file

@ -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