libeio: discrepancy between the manual and the code
Jonathan Neuschäfer
j.neuschaefer at gmx.net
Thu Jan 24 18:57:02 CET 2013
On Thu, Jan 24, 2013 at 02:37:27PM +0400, Konstantin Osipov wrote:
> ssize_t
> coeio_custom(ssize_t (*func)(va_list ap), ev_tstamp timeout, ...)
> {
> struct coeio_task task;
> task.fiber = fiber;
> task.func = func;
> task.result = -1;
> va_start(task.ap, timeout);
> struct eio_req *req = eio_custom(coeio_custom_cb, 0,
> coeio_on_complete, &task);
> if (req == NULL) {
> errno = ENOMEM;
> } else if (fiber_yield_timeout(timeout)) {
> /* timeout. */
> errno = ETIMEDOUT;
> task.result = -1;
> eio_cancel(req);
I think you need to yield here again, and wait for the on_complete
callback to wake you up.
[...]
> static int
> coeio_on_complete(eio_req *req)
> {
> if (! EIO_CANCELLED(req)) {
> struct coeio_task *task = req->data;
> task->result = req->result;
> task->errorno = req->errorno;
> fiber_wakeup(task->fiber);
> } else {
> /* never runs :( */
Obvious question: Have you tried sleeping/blocking long enough in a
"worker" function for the timeout to trigger?
HTH,
Jonathan Neuschäfer
More information about the libev
mailing list