Does aio_write always write the entire buffer?

I know that the POSIX write function can return successfully even if it does not write the entire buffer (if interrupted by a signal). You must check the short entries and resume them.

But does aio_write have the same problem? I do not think so, but it is not mentioned in the documentation, and I can not find anything that claims that this is not happening.

+4
source share
2 answers

The list of error codes on the this page does not include EINTR , which is the value in errno , which means "please call another job again." This way you will not need to call aio_write again for the same piece of data that needs to be written.

This does not mean that you can rely on every record you make. You can still, for example, get a partial recording, because the disc is full or some. But you do not need to check the EINTR and try again.

+1
source

Short answer

Excluding any case of error: Practically yes, theoretically not necessary.

Long answer

From my experience, the caller does not need to call aio_write() more than once to write the entire buffer using aoi_write() .

This, however, does not guarantee that the entire buffer transferred in reality will be written. The final call to aio_error() gives the result of an integer asynchronous I / O operation, which may indicate an error.

In any case, the documentation does not explicitly exclude the case when the final call to aio_return() returns a value less than the number of bytes for the record specified in the original call to aio_write() , which really needs to be interpreted as if the entire buffer would not be sent, and this In the case, it would be necessary to call aio_write() , again transferring what was indicated as remaining for recording on the previous call.

+1
source

All Articles