From e53a6e028fb2705a100ba3f0590674c6c0e588ca Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 21 Sep 2015 17:05:42 +1000 Subject: [PATCH] Close the passthrough socket if it's not already on a failed write in passthrough_send --- src/generator.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/generator.c b/src/generator.c index 2695cabc..d560199e 100644 --- a/src/generator.c +++ b/src/generator.c @@ -1717,14 +1717,16 @@ static void *proxy_send(void *arg) static void passthrough_send(ckpool_t *ckp, pass_msg_t *pm) { + connsock_t *cs = pm->cs; int len, sent; LOGDEBUG("Sending upstream json msg: %s", pm->msg); len = strlen(pm->msg); - sent = write_socket(pm->cs->fd, pm->msg, len); - if (sent != len) { + sent = write_socket(cs->fd, pm->msg, len); + if (unlikely(sent != len)) { LOGWARNING("Failed to passthrough %d bytes of message %s, attempting reconnect", len, pm->msg); + Close(cs->fd); reconnect_generator(ckp); } free(pm->msg); @@ -1912,8 +1914,6 @@ static void *passthrough_recv(void *arg) } sleep(5); } - if (!alive) - reconnect_generator(ckp); /* Make sure we receive a line within 90 seconds */ ret = read_socket_line(cs, &timeout);