mirror of https://gitee.com/openkylin/libvirt.git
daemonStreamHandleWriteData: Preserve error when aborting stream
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@redhat.com> Reviewed-by: Andrea Bolognani <abologna@redhat.com>
This commit is contained in:
parent
bc01d903c2
commit
92a5d12157
|
@ -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));
|
||||
|
||||
|
@ -559,6 +560,11 @@ daemonStreamHandleWriteData(virNetServerClientPtr client,
|
|||
virStreamEventRemoveCallback(stream->st);
|
||||
virStreamAbort(stream->st);
|
||||
|
||||
if (err) {
|
||||
virSetError(err);
|
||||
virFreeError(err);
|
||||
}
|
||||
|
||||
return virNetServerProgramSendReplyError(stream->prog,
|
||||
client,
|
||||
msg,
|
||||
|
|
Loading…
Reference in New Issue