Jelajahi Sumber

Jean-Christian de Rivaz writes:
I actually suspect this code into the file uClibc/libc/sysdeps/linux/common/poll.c:
tval.tv_nsec = (timeout % 1000) *1000; <==== make only usec!
From milisecond this really needs a * 1000000 to make nanosecond. Without this
a 1100 milisecond timeout is converted into a 1 seconde and 100 microsecond
timeout! This can explain the weird result of the test code.

Mike Frysinger 18 tahun lalu
induk
melakukan
dc542b5742
1 mengubah file dengan 1 tambahan dan 1 penghapusan
  1. 1 1
      libc/sysdeps/linux/common/poll.c

+ 1 - 1
libc/sysdeps/linux/common/poll.c

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