Reset blocking::SimpleClient::pos before every read#265
Conversation
| let until = Instant::now() + self.config.tx_timeout; | ||
| let mut pos = 0; | ||
| while pos < self.pos { | ||
| while pos < len { |
There was a problem hiding this comment.
This loop does not seem right? While the change is correct (len instead of self.pos), the self.buf bound and the pos increment seems wrong?
I think it would be better to use self.rw.write_all(&self.buf[..len]) instead of hand-rolling it, unless you have a particular reason for hand-rolling the same?
There was a problem hiding this comment.
You are right about that, I don't know how I missed that 😅.
The hand-rolling is necessary tho, write_ready signals that the next write will be block-free, but write_all may perform as many writes as it needs.
If we cannot add any check in-between write calls the timeout won't work and the client may get stuck indefinitely depending on the inner writer.
There was a problem hiding this comment.
Fair, in that case pos += self.rw.write(&self.buf[pos..len]).or(Err(Error::Write))?;
(cherry picked from commit 125330d)
No description provided.