Browse Source

Use select on stratum send to make sure the socket is writeable.

nfactor-troky
ckolivas 12 years ago
parent
commit
bb4bec98d5
  1. 9
      util.c

9
util.c

@ -869,6 +869,7 @@ bool extract_sockaddr(struct pool *pool, char *url)
/* Send a single command across a socket, appending \n to it */ /* Send a single command across a socket, appending \n to it */
static bool __stratum_send(struct pool *pool, char *s, ssize_t len) static bool __stratum_send(struct pool *pool, char *s, ssize_t len)
{ {
SOCKETTYPE sock = pool->sock;
ssize_t ssent = 0; ssize_t ssent = 0;
if (opt_protocol) if (opt_protocol)
@ -878,8 +879,16 @@ static bool __stratum_send(struct pool *pool, char *s, ssize_t len)
len++; len++;
while (len > 0 ) { while (len > 0 ) {
struct timeval timeout = {0, 0};
size_t sent = 0; size_t sent = 0;
fd_set wd;
FD_ZERO(&wd);
FD_SET(sock, &wd);
if (select(sock + 1, NULL, &wd, NULL, &timeout) < 1) {
applog(LOG_DEBUG, "Write select failed on pool %d sock", pool->pool_no);
return false;
}
if (curl_easy_send(pool->stratum_curl, s + ssent, len, &sent) != CURLE_OK) { if (curl_easy_send(pool->stratum_curl, s + ssent, len, &sent) != CURLE_OK) {
applog(LOG_DEBUG, "Failed to curl_easy_send in stratum_send"); applog(LOG_DEBUG, "Failed to curl_easy_send in stratum_send");
return false; return false;

Loading…
Cancel
Save