Browse Source

stratum: Deliver exact socket-error within the debug error message

Matthias Strubel 13 years ago
parent
commit
3589749993
1 changed files with 3 additions and 1 deletions
  1. 3 1
      util.c

+ 3 - 1
util.c

@@ -1140,6 +1140,7 @@ char *recv_line(struct pool *pool)
 	if (!strstr(pool->sockbuf, "\n")) {
 	if (!strstr(pool->sockbuf, "\n")) {
 		enum recv_ret ret = RECV_OK;
 		enum recv_ret ret = RECV_OK;
 		struct timeval rstart, now;
 		struct timeval rstart, now;
+		int socket_recv_errno;
 
 
 		gettimeofday(&rstart, NULL);
 		gettimeofday(&rstart, NULL);
 		if (!socket_full(pool, true)) {
 		if (!socket_full(pool, true)) {
@@ -1160,6 +1161,7 @@ char *recv_line(struct pool *pool)
 				break;
 				break;
 			}
 			}
 			if (n < 0) {
 			if (n < 0) {
+				socket_recv_errno = errno;
 				if (!sock_blocks()) {
 				if (!sock_blocks()) {
 					ret = RECV_RECVFAIL;
 					ret = RECV_RECVFAIL;
 					break;
 					break;
@@ -1181,7 +1183,7 @@ char *recv_line(struct pool *pool)
 				applog(LOG_DEBUG, "Socket closed waiting in recv_line");
 				applog(LOG_DEBUG, "Socket closed waiting in recv_line");
 				goto out;
 				goto out;
 			case RECV_RECVFAIL:
 			case RECV_RECVFAIL:
-				applog(LOG_DEBUG, "Failed to recv sock in recv_line");
+				applog(LOG_DEBUG, "Failed to recv sock in recv_line: %d", socket_recv_errno);
 				goto out;
 				goto out;
 		}
 		}
 	}
 	}