--- libaitsched/src/hooks.c 2012/08/01 14:27:52 1.10.2.3 +++ libaitsched/src/hooks.c 2012/08/01 16:47:06 1.10.2.6 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: hooks.c,v 1.10.2.3 2012/08/01 14:27:52 misho Exp $ +* $Id: hooks.c,v 1.10.2.6 2012/08/01 16:47:06 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -168,7 +168,8 @@ sched_hook_cancel(void *task, void *arg __unused) #endif acb = (struct aiocb*) TASK_VAL(t); if (acb) { - aio_cancel(acb->aio_fildes, acb); + if (aio_cancel(acb->aio_fildes, acb) == AIO_CANCELED) + aio_return(acb); free(acb); TASK_VAL(t) = 0; } @@ -454,6 +455,7 @@ sched_hook_fetch(void *root, void *arg __unused) register int i, flg; int en; #ifdef EVFILT_AIO + int len, fd; struct aiocb *acb; #endif @@ -776,10 +778,9 @@ sched_hook_fetch(void *root, void *arg __unused) #ifdef EVFILT_AIO case EVFILT_AIO: flg = 0; - acb = (struct aiocb*) TASK_VAL(task); TAILQ_FOREACH_SAFE(task, &r->root_aio, task_node, tmp) { - if (acb != ((struct aiocb*) res[i].ident) || - acb->aio_sigevent.sigev_value.sival_ptr != res[i].udata) + acb = (struct aiocb*) TASK_VAL(task); + if (acb != ((struct aiocb*) res[i].udata)) continue; else flg++; @@ -799,6 +800,16 @@ sched_hook_fetch(void *root, void *arg __unused) #ifdef HAVE_LIBPTHREAD pthread_mutex_unlock(&r->root_mtx[taskREADY]); #endif + fd = acb->aio_fildes; + if ((len = aio_return(acb)) != -1) { + if (lseek(fd, acb->aio_offset + len, SEEK_CUR) == -1) + LOGERR; + } else + LOGERR; + + free(acb); + TASK_FD(task) = fd; + TASK_DATLEN(task) = (u_long) len; } /* if match at least 2, don't remove resouce of event */ if (flg > 1)