version 1.10.2.7, 2012/08/02 11:37:08
|
version 1.10.2.8, 2012/08/02 12:19:29
|
Line 546 schedAIO(sched_root_task_t * __restrict root, sched_ta
|
Line 546 schedAIO(sched_root_task_t * __restrict root, sched_ta
|
* @fd = file descriptor |
* @fd = file descriptor |
* @buffer = Buffer |
* @buffer = Buffer |
* @buflen = Buffer length |
* @buflen = Buffer length |
|
* @offset = Offset from start of file, if =-1 from current position |
* return: NULL error or !=NULL new queued task |
* return: NULL error or !=NULL new queued task |
*/ |
*/ |
inline sched_task_t * |
inline sched_task_t * |
schedAIORead(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, int fd, |
schedAIORead(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, int fd, |
void *buffer, size_t buflen) | void *buffer, size_t buflen, off_t offset) |
{ |
{ |
struct aiocb *acb; |
struct aiocb *acb; |
off_t off = 0; | off_t off; |
|
|
if (!root || !func || !buffer || !buflen) |
if (!root || !func || !buffer || !buflen) |
return NULL; |
return NULL; |
else |
|
memset(buffer, 0, buflen); |
|
|
|
|
if (offset == (off_t) -1) { |
|
off = lseek(fd, 0, SEEK_CUR); |
|
if (off == -1) { |
|
LOGERR; |
|
return NULL; |
|
} |
|
} else |
|
off = offset; |
|
|
if (!(acb = malloc(sizeof(struct aiocb)))) { |
if (!(acb = malloc(sizeof(struct aiocb)))) { |
LOGERR; |
LOGERR; |
return NULL; |
return NULL; |
Line 569 schedAIORead(sched_root_task_t * __restrict root, sche
|
Line 577 schedAIORead(sched_root_task_t * __restrict root, sche
|
acb->aio_fildes = fd; |
acb->aio_fildes = fd; |
acb->aio_nbytes = buflen; |
acb->aio_nbytes = buflen; |
acb->aio_buf = buffer; |
acb->aio_buf = buffer; |
off = lseek(fd, 0, SEEK_CUR); | acb->aio_offset = off; |
if (off == -1) { | |
LOGERR; | |
free(acb); | |
return NULL; | |
} else | |
acb->aio_offset = off; | |
acb->aio_sigevent.sigev_notify = SIGEV_KEVENT; |
acb->aio_sigevent.sigev_notify = SIGEV_KEVENT; |
acb->aio_sigevent.sigev_notify_kqueue = root->root_kq; |
acb->aio_sigevent.sigev_notify_kqueue = root->root_kq; |
acb->aio_sigevent.sigev_value.sival_ptr = acb; |
acb->aio_sigevent.sigev_value.sival_ptr = acb; |
Line 598 schedAIORead(sched_root_task_t * __restrict root, sche
|
Line 600 schedAIORead(sched_root_task_t * __restrict root, sche
|
* @fd = file descriptor |
* @fd = file descriptor |
* @buffer = Buffer |
* @buffer = Buffer |
* @buflen = Buffer length |
* @buflen = Buffer length |
|
* @offset = Offset from start of file, if =-1 from current position |
* return: NULL error or !=NULL new queued task |
* return: NULL error or !=NULL new queued task |
*/ |
*/ |
inline sched_task_t * |
inline sched_task_t * |
schedAIOWrite(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, int fd, |
schedAIOWrite(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, int fd, |
void *buffer, size_t buflen) | void *buffer, size_t buflen, off_t offset) |
{ |
{ |
struct aiocb *acb; |
struct aiocb *acb; |
off_t off = 0; | off_t off; |
|
|
if (!root || !func || !buffer || !buflen) |
if (!root || !func || !buffer || !buflen) |
return NULL; |
return NULL; |
|
|
|
if (offset == (off_t) -1) { |
|
off = lseek(fd, 0, SEEK_CUR); |
|
if (off == -1) { |
|
LOGERR; |
|
return NULL; |
|
} |
|
} else |
|
off = offset; |
|
|
if (!(acb = malloc(sizeof(struct aiocb)))) { |
if (!(acb = malloc(sizeof(struct aiocb)))) { |
LOGERR; |
LOGERR; |
return NULL; |
return NULL; |
Line 619 schedAIOWrite(sched_root_task_t * __restrict root, sch
|
Line 631 schedAIOWrite(sched_root_task_t * __restrict root, sch
|
acb->aio_fildes = fd; |
acb->aio_fildes = fd; |
acb->aio_nbytes = buflen; |
acb->aio_nbytes = buflen; |
acb->aio_buf = buffer; |
acb->aio_buf = buffer; |
off = lseek(fd, 0, SEEK_CUR); | acb->aio_offset = off; |
if (off == -1) { | |
LOGERR; | |
free(acb); | |
return NULL; | |
} else | |
acb->aio_offset = off; | |
acb->aio_sigevent.sigev_notify = SIGEV_KEVENT; |
acb->aio_sigevent.sigev_notify = SIGEV_KEVENT; |
acb->aio_sigevent.sigev_notify_kqueue = root->root_kq; |
acb->aio_sigevent.sigev_notify_kqueue = root->root_kq; |
acb->aio_sigevent.sigev_value.sival_ptr = acb; |
acb->aio_sigevent.sigev_value.sival_ptr = acb; |