Skip to content
This repository has been archived by the owner on May 27, 2020. It is now read-only.

Commit

Permalink
Use select on stratum send to make sure the socket is writeable.
Browse files Browse the repository at this point in the history
  • Loading branch information
ckolivas committed Oct 16, 2012
1 parent 2aa5163 commit bb4bec9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions util.c
Expand Up @@ -869,6 +869,7 @@ bool extract_sockaddr(struct pool *pool, char *url)
/* Send a single command across a socket, appending \n to it */
static bool __stratum_send(struct pool *pool, char *s, ssize_t len)
{
SOCKETTYPE sock = pool->sock;
ssize_t ssent = 0;

if (opt_protocol)
Expand All @@ -878,8 +879,16 @@ static bool __stratum_send(struct pool *pool, char *s, ssize_t len)
len++;

while (len > 0 ) {
struct timeval timeout = {0, 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) {
applog(LOG_DEBUG, "Failed to curl_easy_send in stratum_send");
return false;
Expand Down

0 comments on commit bb4bec9

Please sign in to comment.