Browse Source

Suspend stratum connections when we know they've failed and don't try to recv data from them once the socket no longer exists.

nfactor-troky
Con Kolivas 12 years ago
parent
commit
6560878e03
  1. 11
      util.c

11
util.c

@ -1012,9 +1012,11 @@ bool stratum_send(struct pool *pool, char *s, ssize_t len)
break; break;
case SEND_SELECTFAIL: case SEND_SELECTFAIL:
applog(LOG_DEBUG, "Write select failed on pool %d sock", pool->pool_no); applog(LOG_DEBUG, "Write select failed on pool %d sock", pool->pool_no);
suspend_stratum(pool);
break; break;
case SEND_SENDFAIL: case SEND_SENDFAIL:
applog(LOG_DEBUG, "Failed to curl_easy_send in stratum_send"); applog(LOG_DEBUG, "Failed to send in stratum_send");
suspend_stratum(pool);
break; break;
case SEND_INACTIVE: case SEND_INACTIVE:
applog(LOG_DEBUG, "Stratum send failed due to no pool stratum_active"); applog(LOG_DEBUG, "Stratum send failed due to no pool stratum_active");
@ -1061,7 +1063,10 @@ static void clear_sock(struct pool *pool)
mutex_lock(&pool->stratum_lock); mutex_lock(&pool->stratum_lock);
do { do {
n = recv(pool->sock, pool->sockbuf, RECVSIZE, 0); if (pool->sock)
n = recv(pool->sock, pool->sockbuf, RECVSIZE, 0);
else
n = 0;
} while (n > 0); } while (n > 0);
mutex_unlock(&pool->stratum_lock); mutex_unlock(&pool->stratum_lock);
@ -1114,11 +1119,13 @@ char *recv_line(struct pool *pool)
n = recv(pool->sock, s, RECVSIZE, 0); n = recv(pool->sock, s, RECVSIZE, 0);
if (!n) { if (!n) {
applog(LOG_DEBUG, "Socket closed waiting in recv_line"); applog(LOG_DEBUG, "Socket closed waiting in recv_line");
suspend_stratum(pool);
break; break;
} }
if (n < 0) { if (n < 0) {
if (!sock_blocks() || !socket_full(pool, false)) { if (!sock_blocks() || !socket_full(pool, false)) {
applog(LOG_DEBUG, "Failed to recv sock in recv_line"); applog(LOG_DEBUG, "Failed to recv sock in recv_line");
suspend_stratum(pool);
break; break;
} }
} else { } else {

Loading…
Cancel
Save