On Mon, 2018-03-12 at 10:32 +0100, Michal Privoznik wrote:
The daemonStreamHandleWriteData() function is called whenever
server side of stream is able to receive some data. Nevertheless,
it calls virStreamSend() (to pass data down to virFDStream) and
depending on its return value it may abort the stream. However,
the functions it called when doing so are public APIs and as such
reset any error set previously. Therefore, if there was any error
in writing data to stream (i.e. repored in virStreamSend) it is
reset before virNetServerProgramSendReplyError() can get to it.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/remote/remote_daemon_stream.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/remote/remote_daemon_stream.c b/src/remote/remote_daemon_stream.c
index 4dd3af9e0..532afd856 100644
--- a/src/remote/remote_daemon_stream.c
+++ b/src/remote/remote_daemon_stream.c
@@ -549,8 +549,9 @@ daemonStreamHandleWriteData(virNetServerClientPtr client,
} else if (ret == -2) {
/* Blocking, so indicate we have more todo later */
return 1;
- } else {
+ } else if (ret < 0) {
virNetMessageError rerr;
+ virErrorPtr err = virSaveLastError();
memset(&rerr, 0, sizeof(rerr));
@@ -558,7 +559,10 @@ daemonStreamHandleWriteData(virNetServerClientPtr client,
stream->closed = true;
virStreamEventRemoveCallback(stream->st);
virStreamAbort(stream->st);
-
Don't drop the empty line here...
+ if (err) {
+ virSetError(err);
+ virFreeError(err);
+ }
... and feel free to add one here :)
return virNetServerProgramSendReplyError(stream->prog,
client,
msg,
Reviewed-by: Andrea Bolognani <abologna(a)redhat.com>
--
Andrea Bolognani / Red Hat / Virtualization