TAPI for asynchronous I/O calls
Overview
// global functions rpc_aiocb_p rpc_create_aiocb(rcf_rpc_server* rpcs); void rpc_delete_aiocb(rcf_rpc_server* rpcs, rpc_aiocb_p cb); void rpc_fill_aiocb(rcf_rpc_server* rpcs, rpc_aiocb_p cb, int fildes, rpc_lio_opcode opcode, int reqprio, rpc_ptr buf, size_t nbytes, const tarpc_sigevent* sigevent); int rpc_aio_read(rcf_rpc_server* rpcs, rpc_aiocb_p cb); int rpc_aio_write(rcf_rpc_server* rpcs, rpc_aiocb_p cb); ssize_t rpc_aio_return(rcf_rpc_server* rpcs, rpc_aiocb_p cb); int rpc_aio_error(rcf_rpc_server* rpcs, rpc_aiocb_p cb); int rpc_aio_cancel(rcf_rpc_server* rpcs, int fd, rpc_aiocb_p cb); int rpc_aio_fsync(rcf_rpc_server* rpcs, rpc_fcntl_flags op, rpc_aiocb_p cb); int rpc_aio_suspend(rcf_rpc_server* rpcs, const rpc_aiocb_p* cblist, int n, const struct timespec* timeout); int rpc_lio_listio(rcf_rpc_server* rpcs, rpc_lio_mode mode, const rpc_aiocb_p* cblist, int nent, const tarpc_sigevent* sigevent); // macros #define CLEANUP_RPC_DELETE_AIOCB(_rpcs, _cb)
Detailed Documentation
Global Functions
rpc_aiocb_p rpc_create_aiocb(rcf_rpc_server* rpcs)
Allocate a AIO control block.
Parameters:
rpcs |
RPC server handle |
Returns:
AIO control block address, otherwise NULL is returned on error
void rpc_delete_aiocb(rcf_rpc_server* rpcs, rpc_aiocb_p cb)
Destroy a specified AIO control block.
Parameters:
rpcs |
RPC server handle |
cb |
control block to be deleted |
void rpc_fill_aiocb(rcf_rpc_server* rpcs, rpc_aiocb_p cb, int fildes, rpc_lio_opcode opcode, int reqprio, rpc_ptr buf, size_t nbytes, const tarpc_sigevent* sigevent)
Fill a specified AIO control block.
Parameters:
rpcs |
RPC server handle |
cb |
control block to be updated |
fildes |
file descriptor |
opcode |
lio_listio operation code |
reqprio |
request priority |
buf |
pre-allocated memory buffer |
nbytes |
buffer length |
sigevent |
notification mode description |
int rpc_aio_read(rcf_rpc_server* rpcs, rpc_aiocb_p cb)
Request asynchronous read operation.
Parameters:
rpcs |
RPC server handle |
cb |
control block |
Returns:
0 (success) or -1 (failure)
int rpc_aio_write(rcf_rpc_server* rpcs, rpc_aiocb_p cb)
Request asynchronous write operation.
Parameters:
rpcs |
RPC server handle |
cb |
control block |
Returns:
0 (success) or -1 (failure)
ssize_t rpc_aio_return(rcf_rpc_server* rpcs, rpc_aiocb_p cb)
Retrieve final return status for asynchronous I/O request.
The function converting OS errno to OS-independent one is also applied to value returned by aio_return() on RPC server. The result of the conversion is stored as errno in RPC server structure. This is necessary to obtain correct aio_return() result when it is called for failre request.
Parameters:
rpcs |
RPC server handle |
cb |
control block |
Returns:
Return status of AIO request
int rpc_aio_error(rcf_rpc_server* rpcs, rpc_aiocb_p cb)
Get status of the asynchronous I/O request.
Parameters:
rpcs |
RPC server handle |
cb |
control block |
Returns:
OS-independent error code
int rpc_aio_cancel(rcf_rpc_server* rpcs, int fd, rpc_aiocb_p cb)
Cancel asynchronous I/O request(s) corresponding to the file descriptor.
Parameters:
rpcs |
RPC server handle |
fd |
file descriptor |
cb |
control block or NULL (in this case all AIO requests are cancelled) |
AIO_CANCELED |
all requests are successfully cancelled |
AIO_NOTCANCELED |
at least one request is not cancelled |
AIO_ALLDONE |
all requests are completed before this call |
-1 |
error occurred |
Returns:
Status code
int rpc_aio_fsync(rcf_rpc_server* rpcs, rpc_fcntl_flags op, rpc_aiocb_p cb)
Do a sync on all outstanding asynchronous I/O operations associated with cb->aio_fildes.
Parameters:
rpcs |
RPC server handle |
op |
operation (RPC_O_SYNC or RPC_O_DSYNC) |
cb |
control block with file descriptor and notification mode description |
Returns:
0 (success) or -1 (failure)
int rpc_aio_suspend(rcf_rpc_server* rpcs, const rpc_aiocb_p* cblist, int n, const struct timespec* timeout)
Suspend the calling process until at least one of the asynchronous I/O requests in the list cblist of length n have completed, a signal is delivered, or timeout is not NULL and the time interval it indicates has passed.
Parameters:
rpcs |
RPC server handle |
cblist |
list of control blocks corresponding to AIO requests |
n |
number of elements in cblist |
timeout |
timeout of NULL |
Returns:
0 (success) or -1 (failure)
int rpc_lio_listio(rcf_rpc_server* rpcs, rpc_lio_mode mode, const rpc_aiocb_p* cblist, int nent, const tarpc_sigevent* sigevent)
Initiate a list of I/O requests with a single function call.
Parameters:
rpcs |
RPC server handle |
mode |
if RPC_LIO_WAIT, return after completion of all requests; if RPC_LIO_NOWAIT, requrn after requests queueing |
cblist |
list of control blocks corresponding to AIO requests |
nent |
number of elements in cblist |
sigevent |
notification mode description |
Returns:
0 (success) or -1 (failure)
Macros
#define CLEANUP_RPC_DELETE_AIOCB(_rpcs, _cb)
Delete AIO control block in cleanup part of the test.
Parameters:
_rpcs |
RPC server handle |
_cb |
AIO control block |