Browse Source

Avoid negative length values.

master
Con Kolivas 7 years ago
parent
commit
47ccb01d03
  1. 6
      src/generator.c

6
src/generator.c

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

Loading…
Cancel
Save