mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
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: John Ferlan <jferlan@redhat.com> Reviewed-by: Jim Fehlig <jfehlig@suse.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
52c4ea11c9
commit
464889fff8
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user