From 91368629ad88114c62c2d4ef89915d0e5b7d30ea Mon Sep 17 00:00:00 2001 From: leitner Date: Fri, 26 Sep 2003 15:55:44 +0000 Subject: [PATCH] two internal structures were named io_entry; renamed the iob one to iob_entry --- io/iob_addbuf.c | 4 ++-- io/iob_addfile.c | 4 ++-- io/iob_new.c | 2 +- io/iob_send.c | 27 +++++++++++++++++++++------ iob_internal.h | 4 ++-- 5 files changed, 28 insertions(+), 13 deletions(-) diff --git a/io/iob_addbuf.c b/io/iob_addbuf.c index d4a49be..b70a08a 100644 --- a/io/iob_addbuf.c +++ b/io/iob_addbuf.c @@ -1,8 +1,8 @@ #include "iob_internal.h" int iob_addbuf(io_batch* b,const void* buf,uint64 n) { - io_entry* e=array_allocate(&b->b,sizeof(io_entry), - array_length(&b->b,sizeof(io_entry))); + iob_entry* e=array_allocate(&b->b,sizeof(iob_entry), + array_length(&b->b,sizeof(iob_entry))); if (!e) return 0; e->type=FROMBUF; e->fd=-1; diff --git a/io/iob_addfile.c b/io/iob_addfile.c index 4daf2e5..6275eb0 100644 --- a/io/iob_addfile.c +++ b/io/iob_addfile.c @@ -1,8 +1,8 @@ #include "iob_internal.h" int iob_addfile(io_batch* b,int64 fd,uint64 off,uint64 n) { - io_entry* e=array_allocate(&b->b,sizeof(io_entry), - array_length(&b->b,sizeof(io_entry))); + iob_entry* e=array_allocate(&b->b,sizeof(iob_entry), + array_length(&b->b,sizeof(iob_entry))); if (!e) return 0; e->type=FROMFILE; e->fd=fd; diff --git a/io/iob_new.c b/io/iob_new.c index f4036f9..0b23af4 100644 --- a/io/iob_new.c +++ b/io/iob_new.c @@ -5,7 +5,7 @@ io_batch* iob_new(int hint_entries) { io_batch* b=(io_batch*)malloc(sizeof(io_batch)); if (!b) return 0; if (hint_entries) { - if (!array_allocate(&b->b,sizeof(io_entry),hint_entries)) { + if (!array_allocate(&b->b,sizeof(iob_entry),hint_entries)) { free(b); return 0; } diff --git a/io/iob_send.c b/io/iob_send.c index 8a73d12..291ffaa 100644 --- a/io/iob_send.c +++ b/io/iob_send.c @@ -15,7 +15,7 @@ #include "iob_internal.h" int64 iob_send(int64 s,io_batch* b) { - io_entry* e,* last; + iob_entry* e,* last; struct iovec* v; int64 total,sent; long i; @@ -29,7 +29,7 @@ int64 iob_send(int64 s,io_batch* b) { v=alloca(b->bufs*sizeof(struct iovec)); total=0; for (;;) { - if (!(e=array_get(&b->b,sizeof(io_entry),b->next))) + if (!(e=array_get(&b->b,sizeof(iob_entry),b->next))) return -3; /* can't happen error */ #ifdef BSD_SENDFILE /* BSD sendfile can send headers and trailers. If we run on BSD, we @@ -58,13 +58,22 @@ int64 iob_send(int64 s,io_batch* b) { r=sendfile(e[headers].fd,s,e[headers].offset,e[headers].n,&hdr,&sbytes,0); if (r==0) sent=b->bytesleft; - else if (r==-1 && errno==EAGAIN) + else if (r==-1 && errno==EAGAIN) { if ((sent=sbytes)) sent=-1; - else + goto eagain; + } else sent=-3; } else { sent=writev(s,v,headers); - if (sent==-1 && errno!=EAGAIN) sent=-3; + if (sent==-1) { + if (errno!=EAGAIN) + sent=-3; + else { +eagain: + io_eagain(s); + return -1; + } + } } #else #ifdef TCP_CORK @@ -75,7 +84,13 @@ int64 iob_send(int64 s,io_batch* b) { #endif if (headers) { sent=writev(s,v,headers); - if (sent==-1 && errno==EAGAIN) sent=-3; + if (sent==-1) { + if (errno==EAGAIN) { + io_eagain(s); + return -1; + } + sent=-3; + } } else sent=io_sendfile(s,e->fd,e->offset,e->n); #endif diff --git a/iob_internal.h b/iob_internal.h index b690ae4..8872d5b 100644 --- a/iob_internal.h +++ b/iob_internal.h @@ -1,9 +1,9 @@ #include "iob.h" #include "array.h" -typedef struct io_entry { +typedef struct iob_entry { enum { FROMBUF, FROMFILE } type; int64 fd; const char* buf; uint64 offset,n; -} io_entry; +} iob_entry;