Browse Source

There should be no error response code with return value 0 in recv_line.

Conflicts:
	util.c
Con Kolivas 12 years ago
parent
commit
6b0dac2dac
1 changed files with 10 additions and 12 deletions
  1. 10 12
      util.c

+ 10 - 12
util.c

@@ -1137,19 +1137,17 @@ 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 < 1) {
-				if (errno != EAGAIN && errno != EWOULDBLOCK) {
-					if (n == 0)
-						ret = RECV_CLOSED;
-					else
-						ret = RECV_RECVFAIL;
-					break;
-				}
-			} else {
-				slen = strlen(s);
-				recalloc_sock(pool, slen);
-				strcat(pool->sockbuf, s);
+			if (!n) {
+				ret = RECV_CLOSED;
+				break;
+			}
+			if (n < 0 && errno != EAGAIN && errno != EWOULDBLOCK) {
+				ret = RECV_RECVFAIL;
+				break;
 			}
 			}
+			slen = strlen(s);
+			recalloc_sock(pool, slen);
+			strcat(pool->sockbuf, s);
 			gettimeofday(&now, NULL);
 			gettimeofday(&now, NULL);
 		} 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);