SCP: Slow down debug output writes when the debug fd is non blocking
This problem only appears when debug output is prodigious. That prodigious activity is already dramatically affecting timing, so adding additional delays to allow the debug output to catch up won't make anything worse. It appears that we could jump over the C runtime implementation of fwrite() and do an explicit write() system call and retry that until it succeeds, but this approach would have two negative consequences: 1) it would jump over other buffered data that the C runtime fwrite() may have pending due to output produced by other than debug activities, thus emitting output out of order. 2) Windows doesn't have a direct system call used by its C runtime for write(), but merely implements write() as part of the C runtime and as it turns out that write() returns an int vs a ssize_t type result. An explicit cast could address this, but point 1 would still be a concern. As discussed in #957
This commit is contained in:
parent
b0ac93294e
commit
9cb93a64f2
1 changed files with 2 additions and 0 deletions
2
scp.c
2
scp.c
|
@ -13271,6 +13271,8 @@ while (len > 0) {
|
||||||
len_written = fwrite (buf, 1, len, f);
|
len_written = fwrite (buf, 1, len, f);
|
||||||
len -= len_written;
|
len -= len_written;
|
||||||
buf += len_written;
|
buf += len_written;
|
||||||
|
if (errno == EAGAIN) /* Non blocking file descriptor buffer full? */
|
||||||
|
sim_os_ms_sleep(10);/* wait a bit to retry */
|
||||||
errno = 0;
|
errno = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue