Explorar el Código

poll: Add all sockets to select() error set

bel2125 hace 4 años
padre
commit
049efd0db2
Se han modificado 1 ficheros con 8 adiciones y 7 borrados
  1. 8 7
      src/civetweb.c

+ 8 - 7
src/civetweb.c

@@ -5200,13 +5200,14 @@ poll(struct mg_pollfd *pfd, unsigned int n, int milliseconds)
 	FD_ZERO(&eset);
 
 	for (i = 0; i < n; i++) {
-		if (pfd[i].events & POLLIN) {
-			FD_SET(pfd[i].fd, &rset);
-		}
-		if (pfd[i].events & POLLOUT) {
-			FD_SET(pfd[i].fd, &wset);
-		}
-		if (pfd[i].events & POLLERR) {
+		if (pfd[i].events & (POLLIN | POLLOUT | POLLERR)) {
+			if (pfd[i].events & POLLIN) {
+				FD_SET(pfd[i].fd, &rset);
+			}
+			if (pfd[i].events & POLLOUT) {
+				FD_SET(pfd[i].fd, &wset);
+			}
+			/* Check for errors for any FD in the set */
 			FD_SET(pfd[i].fd, &eset);
 		}
 		pfd[i].revents = 0;