Browse Source

Check for errors on stratum recv for any recv return value less than 1 and only parse the response if it's positive.

nfactor-troky
Con Kolivas 12 years ago
parent
commit
e95695dbc7
  1. 22
      util.c

22
util.c

@ -1104,17 +1104,19 @@ char *recv_line(struct pool *pool)
memset(s, 0, RBUFSIZE); memset(s, 0, RBUFSIZE);
n = recv(pool->sock, s, RECVSIZE, 0); n = recv(pool->sock, s, RECVSIZE, 0);
if (!n) { if (n < 1) {
ret = RECV_CLOSED; if (errno != EAGAIN && errno != EWOULDBLOCK) {
break; if (n == 0)
} ret = RECV_CLOSED;
if (n < 0 && errno != EAGAIN && errno != EWOULDBLOCK) { else
ret = RECV_RECVFAIL; ret = RECV_RECVFAIL;
break; break;
}
} else {
slen = strlen(s);
recalloc_sock(pool, slen);
strcat(pool->sockbuf, s);
} }
slen = strlen(s);
recalloc_sock(pool, slen);
strcat(pool->sockbuf, s);
cgtime(&now); cgtime(&now);
} while (tdiff(&now, &rstart) < 60 && !strstr(pool->sockbuf, "\n")); } while (tdiff(&now, &rstart) < 60 && !strstr(pool->sockbuf, "\n"));
mutex_unlock(&pool->stratum_lock); mutex_unlock(&pool->stratum_lock);

Loading…
Cancel
Save