introduce io_eagain_read and io_eagain_write (discontinue using io_eagain plz)
This commit is contained in:
parent
d9cbb3940c
commit
39e7ee90bb
1
CHANGES
1
CHANGES
@ -14,6 +14,7 @@
|
||||
SECURITY: check for integer overflow in stralloc_ready
|
||||
switch io_fds from array to newly implemented (hopefully thread-safe) iarray
|
||||
switch epoll from level triggering to edge triggering
|
||||
introduce io_eagain_read and io_eagain_write (discontinue using io_eagain plz)
|
||||
|
||||
0.29:
|
||||
save 8 bytes in taia.h for 64-bit systems
|
||||
|
6
io.h
6
io.h
@ -64,8 +64,10 @@ int64 io_waituntil2(int64 milliseconds);
|
||||
void io_check();
|
||||
|
||||
/* signal that read/accept/whatever returned EAGAIN */
|
||||
/* needed for SIGIO */
|
||||
void io_eagain(int64 d);
|
||||
/* needed for SIGIO and epoll */
|
||||
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 */
|
||||
int64 io_canread();
|
||||
|
15
io/io_eagain_read.c
Normal file
15
io/io_eagain_read.c
Normal file
@ -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;
|
||||
}
|
||||
}
|
15
io/io_eagain_write.c
Normal file
15
io/io_eagain_write.c
Normal file
@ -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;
|
||||
else {
|
||||
eagain:
|
||||
io_eagain(s);
|
||||
io_eagain_write(s);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -201,7 +201,7 @@ eagain:
|
||||
sent=writev(s,v,headers);
|
||||
if (sent==-1) {
|
||||
if (errno==EAGAIN) {
|
||||
io_eagain(s);
|
||||
io_eagain_write(s);
|
||||
return -1;
|
||||
}
|
||||
sent=-3;
|
||||
@ -237,7 +237,7 @@ eagain:
|
||||
goto abort;
|
||||
}
|
||||
}
|
||||
io_eagain(s);
|
||||
io_eagain_write(s);
|
||||
} else break;
|
||||
}
|
||||
abort:
|
||||
|
@ -235,7 +235,7 @@ int main() {
|
||||
buffer_putnlflush(buffer_2);
|
||||
}
|
||||
if (errno==EAGAIN)
|
||||
io_eagain(s);
|
||||
io_eagain_read(s);
|
||||
else
|
||||
carp("socket_accept6");
|
||||
} else {
|
||||
@ -285,7 +285,7 @@ emerge:
|
||||
struct http_data* h=io_getcookie(i);
|
||||
int64 r=iob_send(i,&h->iob);
|
||||
/* 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) {
|
||||
array_trunc(&h->r);
|
||||
iob_reset(&h->iob);
|
||||
|
Loading…
x
Reference in New Issue
Block a user