Sfoglia il codice sorgente

Retry if "poll" returns EAGAIN

Fixes #1104
bel2125 2 anni fa
parent
commit
84cb134e72
1 ha cambiato i file con 11 aggiunte e 8 eliminazioni
  1. 11 8
      src/civetweb.c

+ 11 - 8
src/civetweb.c

@@ -5964,15 +5964,18 @@ mg_poll(struct mg_pollfd *pfd,
 
 		result = poll(pfd, n, ms_now);
 		if (result != 0) {
-			/* Poll returned either success (1) or error (-1).
-			 * Forward both to the caller. */
-			if ((check_pollerr)
-			    && ((pfd[0].revents & (POLLIN | POLLOUT | POLLERR))
-			        == POLLERR)) {
-				/* One and only file descriptor returned error */
-				return -1;
+			int err = ERRNO;
+			if (!ERROR_TRY_AGAIN(err)) {
+				/* Poll returned either success (1) or error (-1).
+				 * Forward both to the caller. */
+				if ((check_pollerr)
+				    && ((pfd[0].revents & (POLLIN | POLLOUT | POLLERR))
+				        == POLLERR)) {
+					/* One and only file descriptor returned error */
+					return -1;
+				}
+				return result;
 			}
-			return result;
 		}
 
 		/* Poll returned timeout (0). */