diff options
author | Bjorn Andersson <bjorn.andersson@linaro.org> | 2021-04-15 21:46:57 -0500 |
---|---|---|
committer | Bjorn Andersson <bjorn.andersson@linaro.org> | 2021-04-15 21:52:00 -0500 |
commit | 650b477ca5c410ed05df1b30e0e71e7b1e494ce8 (patch) | |
tree | 4afd9801709eec8039aebe57f524db420fc17747 | |
parent | 00d93b29f5496cf5700c4a1a5ed6f2d55f2c12bb (diff) |
firehose: Drain logs on write timeout
On db410c writes sometimes fails becasue the device had more log entries
to read after the <response> and refuses writes until these are drained.
Deal with this by attempting a read when write fails with a timeout.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
-rw-r--r-- | firehose.c | 24 |
1 files changed, 19 insertions, 5 deletions
@@ -168,11 +168,25 @@ static int firehose_write(struct qdl_device *qdl, xmlDoc *doc) xmlDocDumpMemory(doc, &s, &len); - if (qdl_debug) - fprintf(stderr, "FIREHOSE WRITE: %s\n", s); - - ret = qdl_write(qdl, s, len); - saved_errno = errno; + for (;;) { + if (qdl_debug) + fprintf(stderr, "FIREHOSE WRITE: %s\n", s); + + ret = qdl_write(qdl, s, len); + saved_errno = errno; + + /* + * db410c sometimes sense a <response> followed by <log> + * entries and won't accept write commands until these are + * drained, so attempt to read any pending data and then retry + * the write. + */ + if (ret < 0 && errno == ETIMEDOUT) { + firehose_read(qdl, 100, firehose_generic_parser, NULL); + } else { + break; + } + } xmlFree(s); return ret < 0 ? -saved_errno : 0; } |