Added more debugging to stdout writes.

This commit is contained in:
Andrew Wood
2024-05-11 21:13:12 +01:00
parent 98994bbeaa
commit ace8f44f59
2 changed files with 9 additions and 0 deletions
+5
View File
@@ -192,6 +192,7 @@ int pv_main_loop(pvstate_t state)
&& (0 == state->control.rate_limit))) {
cansend = state->control.size - total_written;
if (0 >= cansend) {
debug("%s", "write limit reached (size explicitly set) - setting EOF flags");
eof_in = true;
eof_out = true;
}
@@ -207,6 +208,7 @@ int pv_main_loop(pvstate_t state)
/* End on write error. */
if (written < 0) {
debug("%s: %s", "write error from pv_transfer", strerror(errno));
if (state->control.cursor)
pv_crs_fini(state);
return state->status.exit_status;
@@ -344,6 +346,9 @@ int pv_main_loop(pvstate_t state)
transferred_since_last = 0;
}
debug("%s: %s=%s, %s=%s", "loop ended", "eof_in", eof_in ? "true" : "false", "eof_out",
eof_out ? "true" : "false");
if (state->control.cursor) {
pv_crs_fini(state);
} else {
+4
View File
@@ -678,12 +678,15 @@ static int pv__transfer_write(pvstate_t state, bool *eof_in, bool *eof_out, long
#else /* ! HAVE_SETITIMER */
(void) alarm(1);
debug("%s", "setting alarm");
#endif /* HAVE_SETITIMER */
debug("%s: %ld %s", "beginning write attempt", (long) (state->transfer.to_write), "bytes");
nwritten = pv__transfer_write_repeated(STDOUT_FILENO,
state->transfer.transfer_buffer +
state->transfer.write_position,
(size_t) (state->transfer.to_write),
state->control.sync_after_write);
debug("%s: %ld", "bytes written", (long) nwritten);
#if HAVE_SETITIMER
memset(&new_timer, 0, sizeof(new_timer));
new_timer.it_interval.tv_sec = 0;
@@ -696,6 +699,7 @@ static int pv__transfer_write(pvstate_t state, bool *eof_in, bool *eof_out, long
/*@+unrecog@ */
#else /* ! HAVE_SETITIMER */
debug("%s", "cancelling alarm");
(void) alarm(0);
#endif /* HAVE_SETITIMER */
}