Flush output buffers in the tap reader thread on Windows.
[tinc] / src / net_socket.c
index 0ba2bf3..0ee3655 100644 (file)
@@ -294,9 +294,6 @@ void retry_outgoing(outgoing_t *outgoing) {
 void finish_connecting(connection_t *c) {
        logger(DEBUG_CONNECTIONS, LOG_INFO, "Connected to %s (%s)", c->name, c->hostname);
 
-       if(proxytype != PROXY_EXEC)
-               configure_tcp(c);
-
        c->last_ping_time = time(NULL);
        c->status.connecting = false;
 
@@ -352,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) {
@@ -380,7 +380,7 @@ static void handle_meta_io(void *data, int flags) {
 
                int result;
                socklen_t len = sizeof result;
-               getsockopt(c->socket, SOL_SOCKET, SO_ERROR, &result, &len);
+               getsockopt(c->socket, SOL_SOCKET, SO_ERROR, (void *)&result, &len);
 
                if(!result)
                        finish_connecting(c);
@@ -459,6 +459,7 @@ begin:
                }
                logger(DEBUG_CONNECTIONS, LOG_INFO, "Using proxy at %s port %s", proxyhost, proxyport);
                c->socket = socket(proxyai->ai_family, SOCK_STREAM, IPPROTO_TCP);
+               configure_tcp(c);
        }
 
        if(c->socket == -1) {