Re: udev: Why non-blocking poll() with blocking recvmsg()?

Kay Sievers <[email protected]>
Newsgroups gmane.linux.hotplug.devel
Message-ID <CAPXgP13x_O6M8abuPYzHM5=18MeuJki2-szWxGt=tzuB6oO2QQ@mail.gmail.com>
On Mon, Aug 19, 2013 at 1:39 PM, Tetsuo Handa
<[email protected]> wrote:

> recvmsg() waits until something is queued if udev_monitor->sock is blocking,

Only on a blocking socket, which it isn't by default:
  http://www.freedesktop.org/software/systemd/libudev/libudev-udev-monitor.html#udev-monitor-receive-device

> but poll() does not wait until something is queued even if udev_monitor->sock
> is blocking.
>
> I think that this inconsistency makes udev_monitor_receive_device()
> to immediately return NULL when an event where passes_filter() returns 0 was
> already queued but another event where passes_filter() returns 1 is not yet
> queued, making wait-for-root utility which is waiting for only "block" subsystem
> events fail.
>
> Why don't we unconditionally go to retry rather than poll(pfd, 1, 0) so that
> "blocking socket can wait for next event" and "non-blocking socket can return
> immediately"?

It's from a time where the socket was still blocking, but we still
used poll() in calling code. We didn't want to block the caller, hence
the poll() inside the library.

The poll() inside of libudev-monitor.c can probably just be removed
today. Or even the whole retry be removed, it might not be a useful
optimization at all.

Kay
--
To unsubscribe from this list: send the line "unsubscribe linux-hotplug" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.