[libvirt] [PATCH 4/5] Fix leak of remote driver if final 'CLOSE' RPC call fails

2011-07-08 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

When closing a remote connection we issue a (fairly pointless)
'CLOSE' RPC call to the daemon. If this fails we skip all the
cleanup of private data, but the virConnectPtr object still
gets released as normal. This causes a memory leak. Since the
CLOSE RPC call is pretty pointless, just carry on freeing the
remote driver if it fails.

* src/remote/remote_driver.c: Ignore failure to issue CLOSE
  RPC call
---
 src/remote/remote_driver.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 4eea3a4..da04a93 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -824,10 +824,12 @@ get_transport_from_scheme (char *scheme)
 static int
 doRemoteClose (virConnectPtr conn, struct private_data *priv)
 {
+int ret = 0;
+
 if (call (conn, priv, 0, REMOTE_PROC_CLOSE,
   (xdrproc_t) xdr_void, (char *) NULL,
   (xdrproc_t) xdr_void, (char *) NULL) == -1)
-return -1;
+ret = -1;
 
 virNetTLSContextFree(priv-tls);
 priv-tls = NULL;
@@ -846,7 +848,7 @@ doRemoteClose (virConnectPtr conn, struct private_data 
*priv)
 virDomainEventStateFree(priv-domainEventState);
 priv-domainEventState = NULL;
 
-return 0;
+return ret;
 }
 
 static int
-- 
1.7.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 4/5] Fix leak of remote driver if final 'CLOSE' RPC call fails

2011-07-08 Thread Eric Blake
On 07/08/2011 05:57 AM, Daniel P. Berrange wrote:
 From: Daniel P. Berrange berra...@redhat.com
 
 When closing a remote connection we issue a (fairly pointless)
 'CLOSE' RPC call to the daemon. If this fails we skip all the
 cleanup of private data, but the virConnectPtr object still
 gets released as normal. This causes a memory leak. Since the
 CLOSE RPC call is pretty pointless, just carry on freeing the
 remote driver if it fails.
 
 * src/remote/remote_driver.c: Ignore failure to issue CLOSE
   RPC call
 ---
  src/remote/remote_driver.c |6 --
  1 files changed, 4 insertions(+), 2 deletions(-)

ACK.

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list