introduce io_eagain_read and io_eagain_write (discontinue using io_eagain plz)

master
leitner 11 years ago
parent d9cbb3940c
commit 39e7ee90bb

@ -14,6 +14,7 @@
SECURITY: check for integer overflow in stralloc_ready SECURITY: check for integer overflow in stralloc_ready
switch io_fds from array to newly implemented (hopefully thread-safe) iarray switch io_fds from array to newly implemented (hopefully thread-safe) iarray
switch epoll from level triggering to edge triggering switch epoll from level triggering to edge triggering
introduce io_eagain_read and io_eagain_write (discontinue using io_eagain plz)
0.29: 0.29:
save 8 bytes in taia.h for 64-bit systems save 8 bytes in taia.h for 64-bit systems

@ -64,8 +64,10 @@ int64 io_waituntil2(int64 milliseconds);
void io_check(); void io_check();
/* signal that read/accept/whatever returned EAGAIN */ /* signal that read/accept/whatever returned EAGAIN */
/* needed for SIGIO */ /* needed for SIGIO and epoll */
void io_eagain(int64 d); void io_eagain(int64 d); /* do not use, API was a bad idea */
void io_eagain_read(int64 d); /* use these ones */
void io_eagain_write(int64 d);
/* return next descriptor from io_wait that can be read from */ /* return next descriptor from io_wait that can be read from */
int64 io_canread(); int64 io_canread();

@ -0,0 +1,15 @@
#include "io_internal.h"
void io_eagain_read(int64 d) {
io_entry* e=iarray_get(&io_fds,d);
if (e) {
e->canread=0;
#if defined(HAVE_SIGIO) || defined(HAVE_EPOLL)
if (d==alt_firstread) {
debug_printf(("io_eagain: dequeueing %lld from alt read queue (next is %ld)\n",d,e->next_read));
alt_firstread=e->next_read;
}
#endif
e->next_read=-1;
}
}

@ -0,0 +1,15 @@
#include "io_internal.h"
void io_eagain_write(int64 d) {
io_entry* e=iarray_get(&io_fds,d);
if (e) {
e->canwrite=0;
#if defined(HAVE_SIGIO) || defined(HAVE_EPOLL)
if (d==alt_firstwrite) {
debug_printf(("io_eagain: dequeueing %lld from alt write queue (next is %ld)\n",d,e->next_write));
alt_firstwrite=e->next_write;
}
#endif
e->next_write=-1;
}
}

@ -182,7 +182,7 @@ int64 iob_send(int64 s,io_batch* b) {
sent=-3; sent=-3;
else { else {
eagain: eagain:
io_eagain(s); io_eagain_write(s);
return -1; return -1;
} }
} }
@ -201,7 +201,7 @@ eagain:
sent=writev(s,v,headers); sent=writev(s,v,headers);
if (sent==-1) { if (sent==-1) {
if (errno==EAGAIN) { if (errno==EAGAIN) {
io_eagain(s); io_eagain_write(s);
return -1; return -1;
} }
sent=-3; sent=-3;
@ -237,7 +237,7 @@ eagain:
goto abort; goto abort;
} }
} }
io_eagain(s); io_eagain_write(s);
} else break; } else break;
} }
abort: abort:

@ -235,7 +235,7 @@ int main() {
buffer_putnlflush(buffer_2); buffer_putnlflush(buffer_2);
} }
if (errno==EAGAIN) if (errno==EAGAIN)
io_eagain(s); io_eagain_read(s);
else else
carp("socket_accept6"); carp("socket_accept6");
} else { } else {
@ -285,7 +285,7 @@ emerge:
struct http_data* h=io_getcookie(i); struct http_data* h=io_getcookie(i);
int64 r=iob_send(i,&h->iob); int64 r=iob_send(i,&h->iob);
/* printf("iob_send returned %lld\n",r); */ /* printf("iob_send returned %lld\n",r); */
if (r==-1) io_eagain(i); else if (r==-1) io_eagain_write(i); else
if (r<=0) { if (r<=0) {
array_trunc(&h->r); array_trunc(&h->r);
iob_reset(&h->iob); iob_reset(&h->iob);

Loading…
Cancel
Save