diff --git a/fmt/fmt_iso8601.c b/fmt/fmt_iso8601.c index f379325..81ede75 100644 --- a/fmt/fmt_iso8601.c +++ b/fmt/fmt_iso8601.c @@ -14,8 +14,7 @@ size_t fmt_iso8601(char* dest,time_t t) { if (dest==0) return sizeof("2014-05-27T19:22:16Z")-1; /* "2014-05-27T19:22:16Z" */ - i=fmt_2digits(dest,(x->tm_year+1900)/100); - i+=fmt_2digits(dest+i,(x->tm_year+1900)%100); + i=fmt_ulong(dest,(x->tm_year+1900)); dest[i++]='-'; i+=fmt_2digits(dest+i,x->tm_mon+1); dest[i++]='-'; diff --git a/io/io_debugstring.c b/io/io_debugstring.c index 051b441..a47bc22 100644 --- a/io/io_debugstring.c +++ b/io/io_debugstring.c @@ -1,7 +1,7 @@ #include "io_internal.h" #include #include -#include +#include unsigned int io_debugstring(int64 s,char* buf,unsigned int bufsize) { struct timeval tv; diff --git a/io/iob_send.c b/io/iob_send.c index b872b43..48a6d00 100644 --- a/io/iob_send.c +++ b/io/iob_send.c @@ -134,6 +134,9 @@ int64 iob_send(int64 s,io_batch* b) { #ifdef HAVE_BSDSENDFILE long trailers; #endif +#ifdef TCP_CORK + int corked=0; +#endif if (b->bytesleft==0) return 0; 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 */ else docork=!(e+i+1==last); - if (docork>0) + if (docork>0) { setsockopt(s,IPPROTO_TCP,TCP_CORK,(int[]){ 1 },sizeof(int)); + corked=1; + } if (headers) { if (docork<0) { /* write+writev */ if (headers==1) /* cosmetics for strace */ @@ -233,8 +238,8 @@ eagain: #else /* !MSG_MORE */ #ifdef TCP_CORK if (b->bufs && b->files && !b->next) { - static int one=1; - setsockopt(s,IPPROTO_TCP,TCP_CORK,&one,sizeof(one)); + setsockopt(s,IPPROTO_TCP,TCP_CORK,(int[]){ 1 },sizeof(int)); + corked=1; } #endif if (headers) { @@ -249,8 +254,9 @@ eagain: } sent=-3; } - } else + } else { sent=io_sendfile(s,e->fd,e->offset,e->n); + } #endif /* !MSG_MORE */ #endif if (sent>0) @@ -258,18 +264,6 @@ eagain: else return total?total:(uint64)sent; 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); break; } else if (sent>0) { @@ -291,6 +285,10 @@ eagain: } else break; } abort: +#ifdef TCP_CORK + if (corked) + setsockopt(s,IPPROTO_TCP,TCP_CORK,(int[]){ 0 },sizeof(int)); +#endif return total; } diff --git a/socket/socket_tcp6.3 b/socket/socket_tcp6.3 index 598d098..5372962 100644 --- a/socket/socket_tcp6.3 +++ b/socket/socket_tcp6.3 @@ -23,4 +23,4 @@ any resources. socket_connect6(s,ip,p,0); .SH "SEE ALSO" -socket_bind4(3), socket_bind6(3) +socket_tcp6b(3), socket_bind4(3), socket_bind6(3)