Commit 4e44270
ltx_send_message() retry write properly on EAGAIN
When we are doing file transfer we can easily saturate the serial
connection or pipe we write into and get EAGAIN.
The original code just ignored all write errors, which caused lost bytes
and broken communication with kirk.
This commit fixes two bugs in the retry loop:
- properly adjust the buffer position on subsequent write attempts
- do a short sleep on EAGAIN and retry later on
We also print message into stderr when write() failed for any other
reason than EAGAIN so that there is at least some hint of a failure in
that case.
Signed-off-by: Cyril Hrubis <metan@ucw.cz>1 parent 334d1ab commit 4e44270
1 file changed
Lines changed: 11 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
213 | 214 | | |
214 | 215 | | |
215 | 216 | | |
216 | | - | |
217 | | - | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
218 | 226 | | |
| 227 | + | |
219 | 228 | | |
220 | 229 | | |
221 | 230 | | |
| |||
0 commit comments