We don't want to wait on uevent forever, but the return value
of polling in timeout is 0 rather than a negative value.
Fixes: http://tracker.ceph.com/issues/38792
Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
for (;;) {
struct pollfd fds[1];
struct udev_device *dev;
+ int r;
fds[0].fd = udev_monitor_get_fd(mon);
fds[0].events = POLLIN;
- if (poll(fds, 1, POLL_TIMEOUT) < 0)
+ r = poll(fds, 1, POLL_TIMEOUT);
+ if (r < 0)
return -errno;
+ if (r == 0)
+ return -ETIMEDOUT;
+
dev = udev_monitor_receive_device(mon);
if (!dev)
continue;
for (;;) {
struct pollfd fds[1];
struct udev_device *dev;
+ int r;
fds[0].fd = udev_monitor_get_fd(mon);
fds[0].events = POLLIN;
- if (poll(fds, 1, POLL_TIMEOUT) < 0)
+ r = poll(fds, 1, POLL_TIMEOUT);
+ if (r < 0)
return -errno;
+ if (r == 0)
+ return -ETIMEDOUT;
+
dev = udev_monitor_receive_device(mon);
if (!dev)
continue;