Next: Synchronizing AIO Operations, Previous: Asynchronous Reads/Writes, Up: Asynchronous I/O
As already described in the documentation of the functions in the last
section, it must be possible to get information about the status of an I/O
request. When the operation is performed truly asynchronously (as with
aio_read and aio_write and with lio_listio when the
mode is LIO_NOWAIT), one sometimes needs to know whether a
specific request already terminated and if so, what the result was.
The following two functions allow you to get this kind of information.
This function determines the error state of the request described by the
struct aiocbvariable pointed to by aiocbp. If the request has not yet terminated the value returned is alwaysEINPROGRESS. Once the request has terminated the valueaio_errorreturns is either 0 if the request completed successfully or it returns the value which would be stored in theerrnovariable if the request would have been done usingread,write, orfsync.The function can return
ENOSYSif it is not implemented. It could also returnEINVALif the aiocbp parameter does not refer to an asynchronous operation whose return status is not yet known.When the sources are compiled with
_FILE_OFFSET_BITS == 64this function is in factaio_error64since the LFS interface transparently replaces the normal implementation.
This function is similar to
aio_errorwith the only difference that the argument is a reference to a variable of typestruct aiocb64.When the sources are compiled with
_FILE_OFFSET_BITS == 64this function is available under the nameaio_errorand so transparently replaces the interface for small files on 32 bit machines.
This function can be used to retrieve the return status of the operation carried out by the request described in the variable pointed to by aiocbp. As long as the error status of this request as returned by
aio_errorisEINPROGRESSthe return of this function is undefined.Once the request is finished this function can be used exactly once to retrieve the return value. Following calls might lead to undefined behavior. The return value itself is the value which would have been returned by the
read,write, orfsynccall.The function can return
ENOSYSif it is not implemented. It could also returnEINVALif the aiocbp parameter does not refer to an asynchronous operation whose return status is not yet known.When the sources are compiled with
_FILE_OFFSET_BITS == 64this function is in factaio_return64since the LFS interface transparently replaces the normal implementation.
This function is similar to
aio_returnwith the only difference that the argument is a reference to a variable of typestruct aiocb64.When the sources are compiled with
_FILE_OFFSET_BITS == 64this function is available under the nameaio_returnand so transparently replaces the interface for small files on 32 bit machines.