Browse Source

Don't try to passthrough_send messages to dead proxies or sockets

master
ckolivas 9 years ago
parent
commit
92ad3c76cd
  1. 10
      src/generator.c

10
src/generator.c

@ -1717,19 +1717,25 @@ static void *proxy_send(void *arg)
static void passthrough_send(ckpool_t *ckp, pass_msg_t *pm) static void passthrough_send(ckpool_t *ckp, pass_msg_t *pm)
{ {
proxy_instance_t *proxy = pm->proxy;
connsock_t *cs = pm->cs; connsock_t *cs = pm->cs;
int len, sent; int len, sent;
if (unlikely(!proxy->alive || cs->fd < 0)) {
LOGDEBUG("Dropping send to dead proxy of upstream json msg: %s", pm->msg);
goto out;
}
LOGDEBUG("Sending upstream json msg: %s", pm->msg); LOGDEBUG("Sending upstream json msg: %s", pm->msg);
len = strlen(pm->msg); len = strlen(pm->msg);
sent = write_socket(cs->fd, pm->msg, len); sent = write_socket(cs->fd, pm->msg, len);
if (unlikely(sent != len && cs->fd)) { if (unlikely(sent != len)) {
LOGWARNING("Failed to passthrough %d bytes of message %s, attempting reconnect", LOGWARNING("Failed to passthrough %d bytes of message %s, attempting reconnect",
len, pm->msg); len, pm->msg);
Close(cs->fd); Close(cs->fd);
pm->proxy->alive = false; proxy->alive = false;
reconnect_generator(ckp); reconnect_generator(ckp);
} }
out:
free(pm->msg); free(pm->msg);
free(pm); free(pm);
} }

Loading…
Cancel
Save