]> granicus.if.org Git - libevent/commitdiff
Make the no_iovecs case of write_atmost compile
authorNick Mathewson <nickm@torproject.org>
Sat, 27 Mar 2010 04:09:25 +0000 (00:09 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 31 Mar 2010 16:52:57 +0000 (12:52 -0400)
Apparently nobody had tested it before on a system that had sendfile.
Why would you have sendfile and not writev?  Perhaps you're trying to
test the no-iovecs code to make sure it still works.

buffer.c

index 85890ff6007f36cdc65dcc64f0ab59bb20d76125..22a377364f6bd09dfeb39c648d08a3e63e2533dd 100644 (file)
--- a/buffer.c
+++ b/buffer.c
@@ -2010,12 +2010,12 @@ evbuffer_write_atmost(struct evbuffer *buffer, evutil_socket_t fd,
        if (howmuch < 0 || howmuch > buffer->total_len)
                howmuch = buffer->total_len;
 
-       {
+       if (howmuch > 0) {
 #ifdef USE_SENDFILE
                struct evbuffer_chain *chain = buffer->first;
                if (chain != NULL && (chain->flags & EVBUFFER_SENDFILE))
                        n = evbuffer_write_sendfile(buffer, fd, howmuch);
-               else
+               else {
 #endif
 #ifdef USE_IOVEC_IMPL
                n = evbuffer_write_iovec(buffer, fd, howmuch);
@@ -2027,6 +2027,9 @@ evbuffer_write_atmost(struct evbuffer *buffer, evutil_socket_t fd,
 #else
                void *p = evbuffer_pullup(buffer, howmuch);
                n = write(fd, p, howmuch);
+#endif
+#ifdef USE_SENDFILE
+               }
 #endif
        }