Browse Source

Fix: mg_poll assumes poll() errno=0 in case of success

In case poll returns success (1), the errno value could still be EAGAIN from a prior call.
This can cause an infinite loop on some systems.
See #1132
bel2125 2 years ago
parent
commit
f87d515017
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/civetweb.c

+ 1 - 1
src/civetweb.c

@@ -5967,7 +5967,7 @@ mg_poll(struct mg_pollfd *pfd,
 		result = poll(pfd, n, ms_now);
 		if (result != 0) {
 			int err = ERRNO;
-			if (!ERROR_TRY_AGAIN(err)) {
+			if ((result == 1) || (!ERROR_TRY_AGAIN(err))) {
 				/* Poll returned either success (1) or error (-1).
 				 * Forward both to the caller. */
 				if ((check_pollerr)