- add IOReadFunc and IOWriteFunc types.

- add fde::read_impl, fde::write_impl.
  (defaults to read(2) and write(2) with raw FDs at the moment;
   this will be revised to act on the fde later.)
This commit is contained in:
William Pitcock 2007-12-22 16:05:51 -06:00
parent 64513f3675
commit 868590746d
2 changed files with 17 additions and 1 deletions

View File

@ -85,8 +85,12 @@ comm_add_fd(int fd)
if (F != NULL)
return F;
F = calloc(sizeof(fde_t), 1);
F = MyMalloc(sizeof(fde_t));
F->fd = fd;
F->read_impl = read;
F->write_impl = write;
list = &fd_table[fd % FD_HASH_SIZE];
dlinkAdd(F, &F->node, list);

View File

@ -35,6 +35,10 @@
/* 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);
/* Callback for completed connections */
/* int fd, int status, void * */
typedef void CNCB(int fd, int, void *);
@ -96,16 +100,24 @@ struct _fde
fdlist_t list; /* Which list this FD should sit on */
int comm_index; /* where in the poll list we live */
char desc[FD_DESC_SZ];
PF *read_handler;
void *read_data;
PF *write_handler;
void *write_data;
PF *timeout_handler;
void *timeout_data;
time_t timeout;
PF *flush_handler;
void *flush_data;
time_t flush_timeout;
IOReadFunc *read_impl;
IOWriteFunc *write_impl;
struct DNSQuery *dns_query;
struct
{