diff options
author | Jorge Arellano Cid <jcid@dillo.org> | 2009-08-05 21:46:32 -0400 |
---|---|---|
committer | Jorge Arellano Cid <jcid@dillo.org> | 2009-08-05 21:46:32 -0400 |
commit | 4858c790e6e0c4023d265d6e54e934d1a31eb72c (patch) | |
tree | b2e457f5107d0cef2ed3d11545cb973d04bbbe9d /src/IO/IO.c | |
parent | 4760495cae7967364a97f9d59b73454ab03ee772 (diff) |
Changed the CCCs to build in one step (for both HTTP and DPI)
Diffstat (limited to 'src/IO/IO.c')
-rw-r--r-- | src/IO/IO.c | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/src/IO/IO.c b/src/IO/IO.c index ddcbe2e7..40677345 100644 --- a/src/IO/IO.c +++ b/src/IO/IO.c @@ -59,13 +59,13 @@ void a_IO_ccc(int Op, int Branch, int Dir, ChainLink *Info, /* IO API - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - * Return a newly created, and initialized, 'io' struct + * Return a new, initialized, 'io' struct */ -static IOData_t *IO_new(int op, int fd) +static IOData_t *IO_new(int op) { IOData_t *io = dNew0(IOData_t, 1); io->Op = op; - io->FD = fd; + io->FD = -1; io->Flags = 0; io->Key = 0; io->Buf = dStr_sized_new(IOBufLen); @@ -309,6 +309,11 @@ static void IO_fd_write_cb(int fd, void *data) */ static void IO_submit(IOData_t *r_io) { + if (r_io->FD < 0) { + MSG_ERR("IO_submit: FD not initialized\n"); + return; + } + /* Insert this IO in ValidIOs */ IO_ins(r_io); @@ -346,14 +351,18 @@ void a_IO_ccc(int Op, int Branch, int Dir, ChainLink *Info, /* Write data using select */ switch (Op) { case OpStart: - io = IO_new(IOWrite, *(int*)Data1); /* SockFD */ + io = IO_new(IOWrite); Info->LocalKey = io; break; case OpSend: io = Info->LocalKey; - dbuf = Data1; - dStr_append_l(io->Buf, dbuf->Buf, dbuf->Size); - IO_submit(io); + if (Data2 && !strcmp(Data2, "FD")) { + io->FD = *(int*)Data1; /* SockFD */ + } else { + dbuf = Data1; + dStr_append_l(io->Buf, dbuf->Buf, dbuf->Size); + IO_submit(io); + } break; case OpEnd: case OpAbort: @@ -371,7 +380,7 @@ void a_IO_ccc(int Op, int Branch, int Dir, ChainLink *Info, MSG_WARN("Unused CCC\n"); break; } - } else { /* FWD */ + } else { /* 1 FWD */ /* Write-data status */ switch (Op) { default: @@ -385,10 +394,16 @@ void a_IO_ccc(int Op, int Branch, int Dir, ChainLink *Info, /* This part catches the reader's messages */ switch (Op) { case OpStart: - io = IO_new(IORead, *(int*)Data2); /* SockFD */ + io = IO_new(IORead); Info->LocalKey = io; io->Info = Info; - IO_submit(io); + break; + case OpSend: + io = Info->LocalKey; + if (Data2 && !strcmp(Data2, "FD")) { + io->FD = *(int*)Data1; /* SockFD */ + IO_submit(io); + } break; case OpAbort: io = Info->LocalKey; @@ -400,7 +415,7 @@ void a_IO_ccc(int Op, int Branch, int Dir, ChainLink *Info, MSG_WARN("Unused CCC\n"); break; } - } else { /* FWD */ + } else { /* 2 FWD */ /* Send read-data */ io = Data1; switch (Op) { |