* reach unprocessed NLMSG_DONE */
#define UL_NL_SOFT_ERROR 4 /* soft error, indicating a race condition or
* message relating to events before program
- * start); could be optionally ignored */
+ * start); could be optionally ignored and it
+ * should not considered as a reason to leave the
+ * processing */
struct ul_nl_data;
/* Process netlink messages.
* async: If true, return UL_NL_WOULDBLOCK immediately if there is no data
* ready. If false, wait for a message.
+ * NOTE: You should read all data until you get UL_NL_WOULDBLOCK, otherwise
+ * select() will not trigger even if there is a netlink message.
* loop: If true, run in a loop until NLMSG_DONE is received. Returns after
* finishing a reply from ul_nl_request_dump(), otherwise it acts as an
* infinite loop. If false, it returns after processing one message.
}
if (ie->nl.fd >= 0 && FD_ISSET(ie->nl.fd, &rfds)) {
- /* We are ignoring errors here to prevent unability of
- * further processing. */
- ul_nl_process(&(ie->nl), UL_NL_ASYNC, UL_NL_ONESHOT);
+ int rc;
+
+ /* We are looping until it returns UL_NL_WOULDBLOCK.
+ * To prevent infinite loop, we are leaving on any other
+ * error except UL_NL_SOFT_ERROR. To prevent unability
+ * of further processing, we never exit. */
+ do {
+ rc = ul_nl_process(&(ie->nl), UL_NL_ASYNC,
+ UL_NL_ONESHOT);
+ }
+ while (!rc || rc == UL_NL_SOFT_ERROR);
/* Just drain the inotify buffer */
} else if (inotify_fd >= 0 && FD_ISSET(inotify_fd, &rfds)) {