Bläddra i källkod

Poll with zero timeout

Jean-Christian de Rivaz writes:
The attached patch solve an issue I faced while using the libdbus-glib
waiting for a D-Bus message or the end of a glib timer at the same time.
This specific case of use generate a poll call with a zero timeout. On
platformes with the glibc a zero timeout poll return immetiately even if
there is no file descriptor event. But on platformes with uClibc a zero
timeout poll block until a file descriptor event occurs.
Joakim Tjernlund 16 år sedan
förälder
incheckning
7340d67f42
1 ändrade filer med 4 tillägg och 0 borttagningar
  1. 4 0
      libc/sysdeps/linux/common/poll.c

+ 4 - 0
libc/sysdeps/linux/common/poll.c

@@ -38,6 +38,10 @@ int __libc_poll(struct pollfd *fds, nfds_t nfds, int timeout)
 		tval.tv_sec = timeout / 1000;
 		tval.tv_nsec = (timeout % 1000) * 1000000;
 		ts = &tval;
+	} else if (timeout == 0) {
+		tval.tv_sec = 0;
+		tval.tv_nsec = 0;
+		ts = &tval;
 	}
 	return ppoll(fds, nfds, ts, NULL);
 }