- 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:
parent
64513f3675
commit
868590746d
|
@ -85,8 +85,12 @@ comm_add_fd(int fd)
|
||||||
if (F != NULL)
|
if (F != NULL)
|
||||||
return F;
|
return F;
|
||||||
|
|
||||||
F = calloc(sizeof(fde_t), 1);
|
F = MyMalloc(sizeof(fde_t));
|
||||||
F->fd = fd;
|
F->fd = fd;
|
||||||
|
|
||||||
|
F->read_impl = read;
|
||||||
|
F->write_impl = write;
|
||||||
|
|
||||||
list = &fd_table[fd % FD_HASH_SIZE];
|
list = &fd_table[fd % FD_HASH_SIZE];
|
||||||
dlinkAdd(F, &F->node, list);
|
dlinkAdd(F, &F->node, list);
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,10 @@
|
||||||
/* Callback for completed IO events */
|
/* Callback for completed IO events */
|
||||||
typedef void PF(int fd, void *);
|
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 */
|
/* Callback for completed connections */
|
||||||
/* int fd, int status, void * */
|
/* int fd, int status, void * */
|
||||||
typedef void CNCB(int fd, int, void *);
|
typedef void CNCB(int fd, int, void *);
|
||||||
|
@ -96,16 +100,24 @@ struct _fde
|
||||||
fdlist_t list; /* Which list this FD should sit on */
|
fdlist_t list; /* Which list this FD should sit on */
|
||||||
int comm_index; /* where in the poll list we live */
|
int comm_index; /* where in the poll list we live */
|
||||||
char desc[FD_DESC_SZ];
|
char desc[FD_DESC_SZ];
|
||||||
|
|
||||||
PF *read_handler;
|
PF *read_handler;
|
||||||
void *read_data;
|
void *read_data;
|
||||||
|
|
||||||
PF *write_handler;
|
PF *write_handler;
|
||||||
void *write_data;
|
void *write_data;
|
||||||
|
|
||||||
PF *timeout_handler;
|
PF *timeout_handler;
|
||||||
void *timeout_data;
|
void *timeout_data;
|
||||||
time_t timeout;
|
time_t timeout;
|
||||||
|
|
||||||
PF *flush_handler;
|
PF *flush_handler;
|
||||||
void *flush_data;
|
void *flush_data;
|
||||||
time_t flush_timeout;
|
time_t flush_timeout;
|
||||||
|
|
||||||
|
IOReadFunc *read_impl;
|
||||||
|
IOWriteFunc *write_impl;
|
||||||
|
|
||||||
struct DNSQuery *dns_query;
|
struct DNSQuery *dns_query;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue