Reputation: 62109
I know that the POSIX write
function can return successfully even though it didn't write the whole buffer (if interrupted by a signal). You have to check for short writes and resume them.
But does aio_write
have the same issue? I don't think it does, but it's not mentioned in the documentation, and I can't find anything that states that it doesn't happen.
Upvotes: 4
Views: 482
Reputation: 129514
The list of error codes on this page doesn't include EINTR
, which is the value in errno
that means "please call again to do some more work". So, no you shouldn't need to call aio_write
again for the same piece of data to be written.
This doesn't mean that you can rely on every write being completed. You still could, for example, get an partial write because the disk is full or some such. But you don't need to check for EINTR
and "try again".
Upvotes: 1
Reputation: 70981
Short answer
Excluding any case of error: Practical yes, theoratical not necessarily.
Long answer
From my experience the caller does not need to call aio_write()
more then once to write the whole buffer using aoi_write()
.
This however is not a guarantee that the whole buffer passed in really will be written. A final call to aio_error()
gives the result of the whole asyncronous I/O operation, which could indicate an error.
Anyhow the documentation does not explicitly excludes the case that the final call to aio_return()
returns a value less then the amount of bytes to write out specified in the original call to aio_write()
, what indeed needs to be interpreted as that not the whole buffer would have been sent, in which case it would be necessary to call aio_write()
again passing in what whould have been indicated as having been left over to write by the previous call.
Upvotes: 1