X-Git-Url: http://git.archive.openwrt.org/?p=project%2Flibubox.git;a=blobdiff_plain;f=ustream.c;h=9c6180657e1e0cd746c32ac90150a507d451b0e2;hp=8e6efcda43be5eca12d2dc8b4c131928be9d9123;hb=29c066cfd60cc9101201a2c31a9aa66288288719;hpb=a9b44ebe556c3f60de2fc1154d48a26f43aa15b7 diff --git a/ustream.c b/ustream.c index 8e6efcd..9c61806 100644 --- a/ustream.c +++ b/ustream.c @@ -341,7 +341,7 @@ bool ustream_write_pending(struct ustream *s) if (s->write_error) return false; - while (buf) { + while (buf && s->w.data_bytes) { struct ustream_buf *next = buf->next; int maxlen = buf->tail - buf->data; @@ -435,6 +435,9 @@ int ustream_vprintf(struct ustream *s, const char *format, va_list arg) va_list arg2; int wr, maxlen, buflen; + if (s->write_error) + return 0; + if (!l->data_bytes) { buf = alloca(MAX_STACK_BUFLEN); va_copy(arg2, arg); @@ -493,6 +496,9 @@ int ustream_printf(struct ustream *s, const char *format, ...) va_list arg; int ret; + if (s->write_error) + return 0; + va_start(arg, format); ret = ustream_vprintf(s, format, arg); va_end(arg);