Follow-up for
bab889c51e888c1b288fed253c349e979a6cf31a (#33032).
Currently, they unconditionally returns EPOLLIN and USEC_INFINITY, respectively.
Just for consistency with sd-bus, sd-journal, sd-varlink, and so on. All
they have _get_fd(), _get_events(), and _get_timeout().
Closes #34094.
sd_varlink_wait;
sd_device_monitor_is_running;
sd_device_monitor_get_fd;
+ sd_device_monitor_get_events;
+ sd_device_monitor_get_timeout;
sd_device_monitor_receive;
} LIBSYSTEMD_256;
return m->sock;
}
+_public_ int sd_device_monitor_get_events(sd_device_monitor *m) {
+ assert_return(m, -EINVAL);
+ assert_return(m->sock >= 0, -ESTALE);
+
+ return EPOLLIN;
+}
+
+_public_ int sd_device_monitor_get_timeout(sd_device_monitor *m, uint64_t *ret) {
+ assert_return(m, -EINVAL);
+ assert_return(m->sock >= 0, -ESTALE);
+
+ if (ret)
+ *ret = USEC_INFINITY;
+ return 0;
+}
+
int device_monitor_new_full(sd_device_monitor **ret, MonitorNetlinkGroup group, int fd) {
_cleanup_(sd_device_monitor_unrefp) sd_device_monitor *m = NULL;
_cleanup_close_ int sock = -EBADF;
ASSERT_OK(device_monitor_send(monitor_server, &sa, device));
ASSERT_OK(fd = sd_device_monitor_get_fd(monitor_client));
+
for (;;) {
- r = fd_wait_for_event(fd, POLLIN, 10 * USEC_PER_SEC);
+ usec_t timeout;
+ int events;
+
+ ASSERT_OK(events = sd_device_monitor_get_events(monitor_client));
+ ASSERT_EQ(events, (int) EPOLLIN);
+ ASSERT_OK(sd_device_monitor_get_timeout(monitor_client, &timeout));
+ ASSERT_EQ(timeout, USEC_INFINITY);
+
+ r = fd_wait_for_event(fd, events, MAX(10 * USEC_PER_SEC, timeout));
if (r == -EINTR)
continue;
ASSERT_OK_POSITIVE(r);
sd_device_monitor *sd_device_monitor_unref(sd_device_monitor *m);
int sd_device_monitor_get_fd(sd_device_monitor *m);
+int sd_device_monitor_get_events(sd_device_monitor *m);
+int sd_device_monitor_get_timeout(sd_device_monitor *m, uint64_t *ret);
int sd_device_monitor_set_receive_buffer_size(sd_device_monitor *m, size_t size);
int sd_device_monitor_attach_event(sd_device_monitor *m, sd_event *event);
int sd_device_monitor_detach_event(sd_device_monitor *m);