diff options
author | 2012-07-11 14:35:52 +0100 | |
---|---|---|
committer | 2012-08-07 11:47:55 +0100 | |
commit | 958499b0c12072e36d20effeddf4a400d9919bb8 (patch) | |
tree | bc6693bd9b1288f0c80ec6e6800c6c905c362113 /daemon | |
parent | Turn virSocket into a virObject (diff) | |
download | libvirt-958499b0c12072e36d20effeddf4a400d9919bb8.tar.gz libvirt-958499b0c12072e36d20effeddf4a400d9919bb8.tar.bz2 libvirt-958499b0c12072e36d20effeddf4a400d9919bb8.zip |
Turn virNetServer* into virObject instances
Make all the virNetServer* objects use the virObject APIs
for reference counting
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/libvirtd.c | 22 | ||||
-rw-r--r-- | daemon/stream.c | 19 |
2 files changed, 16 insertions, 25 deletions
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index 7dd7d5cdc..fa9e7e8e9 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -568,10 +568,10 @@ static int daemonSetupNetworking(virNetServerPtr srv, return 0; error: - virNetServerServiceFree(svcTLS); - virNetServerServiceFree(svcTCP); - virNetServerServiceFree(svc); - virNetServerServiceFree(svcRO); + virObjectUnref(svcTLS); + virObjectUnref(svcTCP); + virObjectUnref(svc); + virObjectUnref(svcRO); return -1; } @@ -759,21 +759,21 @@ static void daemonRunStateInit(void *opaque) VIR_ERROR(_("Driver state initialization failed")); /* Ensure the main event loop quits */ kill(getpid(), SIGTERM); - virNetServerFree(srv); + virObjectUnref(srv); return; } /* Only now accept clients from network */ virNetServerUpdateServices(srv, true); - virNetServerFree(srv); + virObjectUnref(srv); } static int daemonStateInit(virNetServerPtr srv) { virThread thr; - virNetServerRef(srv); + virObjectRef(srv); if (virThreadCreate(&thr, false, daemonRunStateInit, srv) < 0) { - virNetServerFree(srv); + virObjectUnref(srv); return -1; } return 0; @@ -1325,10 +1325,10 @@ int main(int argc, char **argv) { cleanup: virNetlinkEventServiceStop(); - virNetServerProgramFree(remoteProgram); - virNetServerProgramFree(qemuProgram); + virObjectUnref(remoteProgram); + virObjectUnref(qemuProgram); virNetServerClose(srv); - virNetServerFree(srv); + virObjectUnref(srv); virNetlinkShutdown(); if (statuswrite != -1) { if (ret != 0) { diff --git a/daemon/stream.c b/daemon/stream.c index 6f26ee5e4..fe5cae504 100644 --- a/daemon/stream.c +++ b/daemon/stream.c @@ -104,14 +104,6 @@ daemonStreamMessageFinished(virNetMessagePtr msg ATTRIBUTE_UNUSED, } -static void -daemonStreamEventFreeFunc(void *opaque) -{ - virNetServerClientPtr client = opaque; - - virNetServerClientFree(client); -} - /* * Callback that gets invoked when a stream becomes writable/readable */ @@ -332,14 +324,12 @@ daemonCreateClientStream(virNetServerClientPtr client, stream->refs = 1; stream->priv = priv; - stream->prog = prog; + stream->prog = virObjectRef(prog); stream->procedure = header->proc; stream->serial = header->serial; stream->filterID = -1; stream->st = st; - virNetServerProgramRef(prog); - return stream; } @@ -365,7 +355,7 @@ int daemonFreeClientStream(virNetServerClientPtr client, VIR_DEBUG("client=%p, proc=%d, serial=%d", client, stream->procedure, stream->serial); - virNetServerProgramFree(stream->prog); + virObjectUnref(stream->prog); msg = stream->rx; while (msg) { @@ -411,10 +401,11 @@ int daemonAddClientStream(virNetServerClientPtr client, if (virStreamEventAddCallback(stream->st, 0, daemonStreamEvent, client, - daemonStreamEventFreeFunc) < 0) + virObjectFreeCallback) < 0) return -1; - virNetServerClientRef(client); + virObjectRef(client); + if ((stream->filterID = virNetServerClientAddFilter(client, daemonStreamFilter, stream)) < 0) { |