diff --git a/src/generator.c b/src/generator.c index f018a04b..7df505b4 100644 --- a/src/generator.c +++ b/src/generator.c @@ -1835,7 +1835,7 @@ static void send_json_msgq(cs_msg_t **csmsgq) * to avoid sending parts of different messages */ if (proxy->sending && proxy->sending != csmsg) continue; - while (csmsg->len) { + while (csmsg->len > 0) { int fd; if (unlikely(!proxy->alive)) { @@ -1850,7 +1850,7 @@ static void send_json_msgq(cs_msg_t **csmsgq) if (ret < 1) { if (!ret || errno == EAGAIN || errno == EWOULDBLOCK) break; - csmsg->len = 0; + csmsg->len = ret = 0; LOGNOTICE("Proxy %d:%d %s failed to send msg in send_json_msgq, dropping", proxy->id, proxy->subid, proxy->url); set_proxy_disabled(proxy); @@ -1858,7 +1858,7 @@ static void send_json_msgq(cs_msg_t **csmsgq) csmsg->ofs += ret; csmsg->len -= ret; } - if (!csmsg->len) { + if (csmsg->len < 1) { proxy->sending = NULL; DL_DELETE(*csmsgq, csmsg); free(csmsg->buf);