How to know if all pending tevent_req requests have completed?

Amitay Isaacs amitay at
Fri Feb 24 00:28:32 UTC 2017

On Thu, Feb 23, 2017 at 5:45 PM, Ralph Böhme <slow at> wrote:

> On Thu, Feb 23, 2017 at 11:18:41AM +1100, Amitay Isaacs wrote:
> > Hi tevent experts,
> >
> > tevent_req_poll() allows to wait for a specific request.
> >
> > If I want to create n requests and wait for all of them to finish, is
> there
> > an easy way to do it?
> >
> > Here is an example computation:
> >
> > run_event_send()
> >    ... run scripts one after the other ...
> >
> >    if (timer expires) {
> >       run_debug_send()
> >       tevent_req_done()
> >    }
> >
> > In this case, run_debug_send() computation is *not* hanging off the
> > run_event_send() request.
> > The calling code needs to know that run_event computation has timed out,
> > but doesn't really care whether debugging computation is over or not.
> The
> > debug program can run in the background and log useful debug information
> > without affecting the caller.
> maybe I don't understand what you're trying to do, but you have N
> run_event_send
> subreqs and each of those requests either calls tevent_req_done or
> tevent_req_error(ETIMEDOUT) in case of a timeout.

I am not worried about the requests created by run_event_send().  Those
calls are made by the caller and caller can deal with them when the request
is done.  However, the (sub) requests created by run_debug_send() are of
interest here.  They are created internally and no external caller is
really waiting on them.  Looks like I have to keep track of those (sub)
requests internally.

> The caller must have a state with the number of in-flight subrequests and
> then
> you can just count the number of successfull calls and failures in the
> subreq
> callback.

As I said before, from the caller point of view the request is over.  The
debugging (sub) request cannot hold off the caller, so it has to be dealt
with internally.


More information about the samba-technical mailing list