|
|
@ -134,6 +134,9 @@ int64 iob_send(int64 s,io_batch* b) {
|
|
|
|
#ifdef HAVE_BSDSENDFILE
|
|
|
|
#ifdef HAVE_BSDSENDFILE
|
|
|
|
long trailers;
|
|
|
|
long trailers;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TCP_CORK
|
|
|
|
|
|
|
|
int corked=0;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
if (b->bytesleft==0) return 0;
|
|
|
|
if (b->bytesleft==0) return 0;
|
|
|
|
last=(iob_entry*)(((char*)array_start(&b->b))+array_bytes(&b->b));
|
|
|
|
last=(iob_entry*)(((char*)array_start(&b->b))+array_bytes(&b->b));
|
|
|
@ -202,8 +205,10 @@ eagain:
|
|
|
|
docork=-1; /* no files, only buffer, so no need for TCP_CORK or MSG_MORE */
|
|
|
|
docork=-1; /* no files, only buffer, so no need for TCP_CORK or MSG_MORE */
|
|
|
|
else
|
|
|
|
else
|
|
|
|
docork=!(e+i+1==last);
|
|
|
|
docork=!(e+i+1==last);
|
|
|
|
if (docork>0)
|
|
|
|
if (docork>0) {
|
|
|
|
setsockopt(s,IPPROTO_TCP,TCP_CORK,(int[]){ 1 },sizeof(int));
|
|
|
|
setsockopt(s,IPPROTO_TCP,TCP_CORK,(int[]){ 1 },sizeof(int));
|
|
|
|
|
|
|
|
corked=1;
|
|
|
|
|
|
|
|
}
|
|
|
|
if (headers) {
|
|
|
|
if (headers) {
|
|
|
|
if (docork<0) { /* write+writev */
|
|
|
|
if (docork<0) { /* write+writev */
|
|
|
|
if (headers==1) /* cosmetics for strace */
|
|
|
|
if (headers==1) /* cosmetics for strace */
|
|
|
@ -233,8 +238,8 @@ eagain:
|
|
|
|
#else /* !MSG_MORE */
|
|
|
|
#else /* !MSG_MORE */
|
|
|
|
#ifdef TCP_CORK
|
|
|
|
#ifdef TCP_CORK
|
|
|
|
if (b->bufs && b->files && !b->next) {
|
|
|
|
if (b->bufs && b->files && !b->next) {
|
|
|
|
static int one=1;
|
|
|
|
setsockopt(s,IPPROTO_TCP,TCP_CORK,(int[]){ 1 },sizeof(int));
|
|
|
|
setsockopt(s,IPPROTO_TCP,TCP_CORK,&one,sizeof(one));
|
|
|
|
corked=1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
if (headers) {
|
|
|
|
if (headers) {
|
|
|
@ -249,8 +254,9 @@ eagain:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sent=-3;
|
|
|
|
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 /* !MSG_MORE */
|
|
|
|
#endif /* !MSG_MORE */
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
if (sent>0)
|
|
|
|
if (sent>0)
|
|
|
@ -258,18 +264,6 @@ eagain:
|
|
|
|
else
|
|
|
|
else
|
|
|
|
return total?total:(uint64)sent;
|
|
|
|
return total?total:(uint64)sent;
|
|
|
|
if ((uint64)sent==b->bytesleft) {
|
|
|
|
if ((uint64)sent==b->bytesleft) {
|
|
|
|
#ifdef MSG_MORE
|
|
|
|
|
|
|
|
if (docork==1) {
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TCP_CORK
|
|
|
|
|
|
|
|
if (b->bufs && b->files) {
|
|
|
|
|
|
|
|
static int zero=0;
|
|
|
|
|
|
|
|
setsockopt(s,IPPROTO_TCP,TCP_CORK,&zero,sizeof(zero));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MSG_MORE
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
iob_reset(b);
|
|
|
|
iob_reset(b);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
} else if (sent>0) {
|
|
|
|
} else if (sent>0) {
|
|
|
@ -291,6 +285,10 @@ eagain:
|
|
|
|
} else break;
|
|
|
|
} else break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
abort:
|
|
|
|
abort:
|
|
|
|
|
|
|
|
#ifdef TCP_CORK
|
|
|
|
|
|
|
|
if (corked)
|
|
|
|
|
|
|
|
setsockopt(s,IPPROTO_TCP,TCP_CORK,(int[]){ 0 },sizeof(int));
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return total;
|
|
|
|
return total;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|