int nopoll_loop_wait ( noPollCtx ctx,
long  timeout 

Allows to implement a wait over all connections registered under the provided context during the provided timeout until something is detected meaningful to the user, calling to the action handler defined, optionally receving the user data pointer.

ctxThe context object where the wait will be implemented.
timeoutThe timeout to wait for changes. If no changes happens, the function returns. The function will block the caller until a call to nopoll_loop_stop is done in the case timeout passed is 0.
The function returns 0 when finished without error or -2 in the case ctx is NULL or timeout is negative. Function returns -3 if timeout was reached. Function returns -4 in the case ctx->io_engine->wait failed to implement wait or it reported error.

Recovering from IO Wait failure (return code -4)

In the case I/O wait mechanism fails, this function will return -4. In can catch that error code and recover (keep on waiting), log the error or implement some other policy.

Here is an example:

1 while (nopoll_true) {
2  // wait for ever
3  int error_code = nopoll_loop_wait (ctx, 0);
5  if (error_code == -4) {
6  printf ("Log here you had an error cause by the io waiting mechanism, errno=%d\n", errno);
7  // recover by just calling io wait engine
8  // try to limit recoveries to avoid infinite loop
9  continue;
10  }

References nopoll_ctx_foreach_conn(), NOPOLL_LEVEL_CRITICAL, nopoll_return_val_if_fail, nopoll_timeval_substract(), and nopoll_true.