[Xrd] Fix a short writev recovery case #1825
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While looking into another problem I noticed an apparently not-handled case in XrdLinkXeq::SendIOV when it resumes a write after an incomplete writev: For instance in the case of iocnt=2, if the writev returns a short number of bytes from the first iov, iov[0], then remainder of iov[0] is sent by write(), and then iov[1] is sent by writev() [all as intended]; but then an attempt would be made to write() the contents of iov[2]. This should either give an error like ("bad address") for the link, or possibly send some trailing nonsense data to the client.
In fact I don't think this was related to the problem I had been looking at, and I didn't find any indication this is happening. e.g. even if I look at a busy server I don't notice any "bad address" link errors. So maybe this is rather rare or even not possible for some reason I've not understood. (e.g. iov[0] is typically very short, e.g. 8 bytes, and iov[1] or iov[2] is much longer, so a short writev is more likely to happen in the last iov[]).