提交 464889ff 编写于 作者: D Daniel P. Berrangé

rpc: push ref acquisition into RPC dispatch function

There's no reason why the virNetServerClientDispatchRead method needs to
acquire an extra reference on the "client" object. An extra reference is
only needed if the registered dispatch callback is going to keep hold of
the "client" for work in the background. Thus we can push reference
acquisition into virNetServerDispatchNewMessage.
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
Reviewed-by: NJim Fehlig <jfehlig@suse.com>
Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 52c4ea11
......@@ -217,9 +217,11 @@ static int virNetServerDispatchNewMessage(virNetServerClientPtr client,
priority = virNetServerProgramGetPriority(prog, msg->header.proc);
}
virObjectRef(client);
ret = virThreadPoolSendJob(srv->workers, priority, job);
if (ret < 0) {
virObjectUnref(client);
VIR_FREE(job);
virObjectUnref(prog);
}
......
......@@ -1315,12 +1315,10 @@ static void virNetServerClientDispatchRead(virNetServerClientPtr client)
/* Send off to for normal dispatch to workers */
if (msg) {
virObjectRef(client);
if (!client->dispatchFunc ||
client->dispatchFunc(client, msg, client->dispatchOpaque) < 0) {
virNetMessageFree(msg);
client->wantClose = true;
virObjectUnref(client);
return;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册