Conditions always true in tevent_standard.c

Jeremy Allison jra at
Tue Jun 28 17:30:09 UTC 2016

On Tue, Jun 28, 2016 at 02:07:10PM +0300, Nikolai Kondrashov wrote:
> Hi everyone,
> I was reading about tevent and browsing the code, when I noticed these two
> conditions in tevent_standard.c:
>      ret = glue->epoll_ops->loop_once(ev, location);
>      if (glue->epoll_ops != NULL) {
>          /* No fallback */
>          return ret;
>      }
> and
>      ret = glue->epoll_ops->loop_wait(ev, location);
>      if (glue->epoll_ops != NULL) {
>          /* No fallback */
>          return ret;
>      }
> To me it seems they are never going to be false (the program would segfault
> before they are reached if glue->epoll_ops is NULL) and I suspect there's some
> logic bug here. However, unfortunately, I don't have time to figure out what
> exactly should be done about this, so I'll leave it up to you.

No, it isn't a logic bug (I had to explain the same thing to a
Google engineer). The epoll backend can fall back on an epoll
syscall failure (early versions of Linux might have had problems
here) so check out the code in tevent_standard.c:

                tevent_epoll_set_panic_fallback(ev, std_fallback_to_poll);

> Still, if there's some purpose to that, then I think a comment is in order.

Please submit a comment as a git-am patch, once you grok the code :-).

Note there is already the comment:

120         if (!glue->fallback_replay) {
121                 /*
122                  * The problem happened while modifying an event.
123                  * An event handler was triggered in this case
124                  * and there is no need to call loop_once() again.
125                  */
126                 return ret;
127         }

More information about the samba-technical mailing list