提交 158ba873 编写于 作者: D Daniel P. Berrange

Merge all returns paths from dispatcher into single path

The dispatcher functions have numerous places where they
return to the caller. This leads to duplicated cleanup
code, often resulting in memory leaks. It makes it harder
to ensure that errors are dispatched before freeing objects,
which may overwrite the original error.

The standard pattern is now

    remoteDispatchXXX(...) {
        int rv = -1;

        ....
        if (XXX < 0)
          goto cleanup;
        ...
        if (XXXX < 0)
          goto cleanup;
        ...

        rv = 0;
    cleanup:
        if (rv < 0)
           remoteDispatchError(rerr);
        ...free all other stuff..
        return rv;
    }

* daemon/remote.c: Centralize all cleanup paths
* daemon/stream.c: s/remoteDispatchConnError/remoteDispatchError/
* daemon/dispatch.c, daemon/dispatch.h: Replace
  remoteDispatchConnError with remoteDispatchError
  removing unused virConnectPtr
上级 16d6b0d8
......@@ -112,8 +112,7 @@ void remoteDispatchOOMError (remote_error *rerr)
}
void remoteDispatchConnError (remote_error *rerr,
virConnectPtr conn ATTRIBUTE_UNUSED)
void remoteDispatchError(remote_error *rerr)
{
virErrorPtr verr = virGetLastError();
......
......@@ -46,8 +46,7 @@ void remoteDispatchFormatError (remote_error *rerr,
void remoteDispatchAuthError (remote_error *rerr);
void remoteDispatchGenericError (remote_error *rerr);
void remoteDispatchOOMError (remote_error *rerr);
void remoteDispatchConnError (remote_error *rerr,
virConnectPtr conn);
void remoteDispatchError(remote_error *rerr);
int
......
此差异已折叠。
......@@ -403,7 +403,7 @@ remoteStreamHandleWriteData(struct qemud_client *client,
} else {
VIR_INFO0("Stream send failed");
stream->closed = 1;
remoteDispatchConnError(&rerr, client->conn);
remoteDispatchError(&rerr);
return remoteSerializeReplyError(client, &rerr, &msg->hdr);
}
......@@ -437,7 +437,7 @@ remoteStreamHandleFinish(struct qemud_client *client,
ret = virStreamFinish(stream->st);
if (ret < 0) {
remoteDispatchConnError(&rerr, client->conn);
remoteDispatchError(&rerr);
return remoteSerializeReplyError(client, &rerr, &msg->hdr);
} else {
/* Send zero-length confirm */
......@@ -569,7 +569,7 @@ remoteStreamHandleRead(struct qemud_client *client,
} else if (ret < 0) {
remote_error rerr;
memset(&rerr, 0, sizeof rerr);
remoteDispatchConnError(&rerr, NULL);
remoteDispatchError(&rerr);
ret = remoteSerializeStreamError(client, &rerr, stream->procedure, stream->serial);
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册