two internal structures were named io_entry; renamed the iob one to iob_entry

master
leitner 21 years ago
parent 3ec95df805
commit 91368629ad

@ -1,8 +1,8 @@
#include "iob_internal.h" #include "iob_internal.h"
int iob_addbuf(io_batch* b,const void* buf,uint64 n) { int iob_addbuf(io_batch* b,const void* buf,uint64 n) {
io_entry* e=array_allocate(&b->b,sizeof(io_entry), iob_entry* e=array_allocate(&b->b,sizeof(iob_entry),
array_length(&b->b,sizeof(io_entry))); array_length(&b->b,sizeof(iob_entry)));
if (!e) return 0; if (!e) return 0;
e->type=FROMBUF; e->type=FROMBUF;
e->fd=-1; e->fd=-1;

@ -1,8 +1,8 @@
#include "iob_internal.h" #include "iob_internal.h"
int iob_addfile(io_batch* b,int64 fd,uint64 off,uint64 n) { int iob_addfile(io_batch* b,int64 fd,uint64 off,uint64 n) {
io_entry* e=array_allocate(&b->b,sizeof(io_entry), iob_entry* e=array_allocate(&b->b,sizeof(iob_entry),
array_length(&b->b,sizeof(io_entry))); array_length(&b->b,sizeof(iob_entry)));
if (!e) return 0; if (!e) return 0;
e->type=FROMFILE; e->type=FROMFILE;
e->fd=fd; e->fd=fd;

@ -5,7 +5,7 @@ io_batch* iob_new(int hint_entries) {
io_batch* b=(io_batch*)malloc(sizeof(io_batch)); io_batch* b=(io_batch*)malloc(sizeof(io_batch));
if (!b) return 0; if (!b) return 0;
if (hint_entries) { 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); free(b);
return 0; return 0;
} }

@ -15,7 +15,7 @@
#include "iob_internal.h" #include "iob_internal.h"
int64 iob_send(int64 s,io_batch* b) { int64 iob_send(int64 s,io_batch* b) {
io_entry* e,* last; iob_entry* e,* last;
struct iovec* v; struct iovec* v;
int64 total,sent; int64 total,sent;
long i; long i;
@ -29,7 +29,7 @@ int64 iob_send(int64 s,io_batch* b) {
v=alloca(b->bufs*sizeof(struct iovec)); v=alloca(b->bufs*sizeof(struct iovec));
total=0; total=0;
for (;;) { 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 */ return -3; /* can't happen error */
#ifdef BSD_SENDFILE #ifdef BSD_SENDFILE
/* BSD sendfile can send headers and trailers. If we run on BSD, we /* 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); r=sendfile(e[headers].fd,s,e[headers].offset,e[headers].n,&hdr,&sbytes,0);
if (r==0) if (r==0)
sent=b->bytesleft; sent=b->bytesleft;
else if (r==-1 && errno==EAGAIN) else if (r==-1 && errno==EAGAIN) {
if ((sent=sbytes)) sent=-1; if ((sent=sbytes)) sent=-1;
else goto eagain;
} else
sent=-3; sent=-3;
} else { } else {
sent=writev(s,v,headers); 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 #else
#ifdef TCP_CORK #ifdef TCP_CORK
@ -75,7 +84,13 @@ int64 iob_send(int64 s,io_batch* b) {
#endif #endif
if (headers) { if (headers) {
sent=writev(s,v,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 } else
sent=io_sendfile(s,e->fd,e->offset,e->n); sent=io_sendfile(s,e->fd,e->offset,e->n);
#endif #endif

@ -1,9 +1,9 @@
#include "iob.h" #include "iob.h"
#include "array.h" #include "array.h"
typedef struct io_entry { typedef struct iob_entry {
enum { FROMBUF, FROMFILE } type; enum { FROMBUF, FROMFILE } type;
int64 fd; int64 fd;
const char* buf; const char* buf;
uint64 offset,n; uint64 offset,n;
} io_entry; } iob_entry;

Loading…
Cancel
Save