浏览代码

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 年之前
父节点
当前提交
f87d515017
共有 1 个文件被更改,包括 1 次插入1 次删除
  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);
 		result = poll(pfd, n, ms_now);
 		if (result != 0) {
 		if (result != 0) {
 			int err = ERRNO;
 			int err = ERRNO;
-			if (!ERROR_TRY_AGAIN(err)) {
+			if ((result == 1) || (!ERROR_TRY_AGAIN(err))) {
 				/* Poll returned either success (1) or error (-1).
 				/* Poll returned either success (1) or error (-1).
 				 * Forward both to the caller. */
 				 * Forward both to the caller. */
 				if ((check_pollerr)
 				if ((check_pollerr)