mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
remote: Use consistent error preservation and restoration calls
Provide some consistency over error message variable name and usage when saving error messages across possible other errors or possibility of resetting of the last error. Instead of virSaveLastError paired up with virSetError and virFreeError, we should use the newer virErrorPreserveLast and virRestoreError. Signed-off-by: John Ferlan <jferlan@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
7fb2d1339a
commit
28805f3d86
@ -229,15 +229,18 @@ daemonStreamEvent(virStreamPtr st, int events, void *opaque)
|
|||||||
int ret;
|
int ret;
|
||||||
virNetMessagePtr msg;
|
virNetMessagePtr msg;
|
||||||
virNetMessageError rerr;
|
virNetMessageError rerr;
|
||||||
virErrorPtr origErr = virSaveLastError();
|
virErrorPtr origErr;
|
||||||
|
|
||||||
|
virErrorPreserveLast(&origErr);
|
||||||
|
|
||||||
memset(&rerr, 0, sizeof(rerr));
|
memset(&rerr, 0, sizeof(rerr));
|
||||||
stream->closed = true;
|
stream->closed = true;
|
||||||
virStreamEventRemoveCallback(stream->st);
|
virStreamEventRemoveCallback(stream->st);
|
||||||
virStreamAbort(stream->st);
|
virStreamAbort(stream->st);
|
||||||
if (origErr && origErr->code != VIR_ERR_OK) {
|
if (origErr && origErr->code != VIR_ERR_OK) {
|
||||||
virSetError(origErr);
|
virErrorRestore(&origErr);
|
||||||
} else {
|
} else {
|
||||||
|
virFreeError(origErr);
|
||||||
if (events & VIR_STREAM_EVENT_HANGUP)
|
if (events & VIR_STREAM_EVENT_HANGUP)
|
||||||
virReportError(VIR_ERR_RPC,
|
virReportError(VIR_ERR_RPC,
|
||||||
"%s", _("stream had unexpected termination"));
|
"%s", _("stream had unexpected termination"));
|
||||||
@ -245,7 +248,6 @@ daemonStreamEvent(virStreamPtr st, int events, void *opaque)
|
|||||||
virReportError(VIR_ERR_RPC,
|
virReportError(VIR_ERR_RPC,
|
||||||
"%s", _("stream had I/O failure"));
|
"%s", _("stream had I/O failure"));
|
||||||
}
|
}
|
||||||
virFreeError(origErr);
|
|
||||||
|
|
||||||
msg = virNetMessageNew(false);
|
msg = virNetMessageNew(false);
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
@ -549,7 +551,9 @@ daemonStreamHandleWriteData(virNetServerClientPtr client,
|
|||||||
return 1;
|
return 1;
|
||||||
} else if (ret < 0) {
|
} else if (ret < 0) {
|
||||||
virNetMessageError rerr;
|
virNetMessageError rerr;
|
||||||
virErrorPtr err = virSaveLastError();
|
virErrorPtr err;
|
||||||
|
|
||||||
|
virErrorPreserveLast(&err);
|
||||||
|
|
||||||
memset(&rerr, 0, sizeof(rerr));
|
memset(&rerr, 0, sizeof(rerr));
|
||||||
|
|
||||||
@ -558,10 +562,7 @@ daemonStreamHandleWriteData(virNetServerClientPtr client,
|
|||||||
virStreamEventRemoveCallback(stream->st);
|
virStreamEventRemoveCallback(stream->st);
|
||||||
virStreamAbort(stream->st);
|
virStreamAbort(stream->st);
|
||||||
|
|
||||||
if (err) {
|
virErrorRestore(&err);
|
||||||
virSetError(err);
|
|
||||||
virFreeError(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
return virNetServerProgramSendReplyError(stream->prog,
|
return virNetServerProgramSendReplyError(stream->prog,
|
||||||
client,
|
client,
|
||||||
|
Loading…
Reference in New Issue
Block a user