From: Guus Sliepen Date: Fri, 1 Mar 2013 16:15:26 +0000 (+0100) Subject: Flush output buffers in the tap reader thread on Windows. X-Git-Tag: release-1.1pre7~10 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=f9ab8e266b93aa3be772374ef4a8fdb06e376568;p=oweals%2Ftinc.git Flush output buffers in the tap reader thread on Windows. This is basically a port of commit 50fcfea1 to 1.1. --- diff --git a/src/event.c b/src/event.c index 6b730f6..095e7c3 100644 --- a/src/event.c +++ b/src/event.c @@ -245,6 +245,12 @@ bool event_loop(void) { return true; } +void event_flush_output(void) { + for splay_each(io_t, io, &io_tree) + if(FD_ISSET(io->fd, &writefds)) + io->cb(io->data, IO_WRITE); +} + void event_exit(void) { running = false; } diff --git a/src/event.h b/src/event.h index d0129d0..bd91b7b 100644 --- a/src/event.h +++ b/src/event.h @@ -65,6 +65,7 @@ extern void signal_add(signal_t *sig, signal_cb_t cb, void *data, int signum); extern void signal_del(signal_t *sig); extern bool event_loop(void); +extern void event_flush_output(void); extern void event_exit(void); #endif diff --git a/src/mingw/device.c b/src/mingw/device.c index aa05972..ac83d8c 100644 --- a/src/mingw/device.c +++ b/src/mingw/device.c @@ -80,6 +80,7 @@ static DWORD WINAPI tapreader(void *bla) { packet.len = len; packet.priority = 0; route(myself, &packet); + event_flush_output(); LeaveCriticalSection(&mutex); } } diff --git a/src/net_socket.c b/src/net_socket.c index a28be54..0ee3655 100644 --- a/src/net_socket.c +++ b/src/net_socket.c @@ -349,6 +349,9 @@ static void do_outgoing_pipe(connection_t *c, char *command) { } static void handle_meta_write(connection_t *c) { + if(c->outbuf.len <= c->outbuf.offset) + return; + ssize_t outlen = send(c->socket, c->outbuf.data + c->outbuf.offset, c->outbuf.len - c->outbuf.offset, 0); if(outlen <= 0) { if(!errno || errno == EPIPE) {