Browse Source

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

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

+ 3 - 1
util.c

@@ -1269,6 +1269,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)) {
@@ -1289,6 +1290,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;
@@ -1310,7 +1312,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;
 		}
 		}
 	}
 	}