Skip to content
Snippets Groups Projects
Commit 2f2a4787 authored by Alexandre Janniaux's avatar Alexandre Janniaux Committed by Jean-Baptiste Kempf
Browse files

control: dbus: check EINTR for read

The definition of read() mandates from its prototype that the return
value and errno must be checked since the syscall can be interrupted
without being processed by a signal:

    ../../modules/control/dbus/dbus.c: In function ‘Run’:
    ../../modules/control/dbus/dbus.c:958:19: warning: ignoring return value of ‘read’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
      958 |             (void)read( fds[0].fd, &buf, 1 );
          |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~

In practice, the read is not done on a slow device, but a UNIX pipe
instead, and only when poll() notify that a read operation will be
non-blocking, and we're not supposed to have a signal handler here in
the normal execution (not using tools making use of SIGPROF for
instance), so read() being interrupted is nearly impossible, as opposed
to poll() being interrupted.

The read() call is also changed to use an anonymous compound litteral
which doesn't need to be marked as used manually, since we didn't use
the buffer variable at all.

In the future, using eventfd() to generate a semaphore compatible with
poll() and making the event handling lock-free might be a better
alternative, since read() will return the number of new events, and the
lock would become redundant.
parent 6a445c0a
No related branches found
Tags 0.6.0
1 merge request!4068control: dbus: check EINTR for read
Pipeline #372641 passed with stage
in 24 minutes and 24 seconds
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment