libvirt/9c77bf04-fix-virnetserver-refcnt.patch

35 lines
997 B
Diff

commit 9c77bf04b03ff026bb37212a195070d8983f530d
Author: Hu Tao <hutao@cn.fujitsu.com>
Date: Fri Jun 22 11:26:03 2012 +0800
fix a bug of ref count in virnetserver.c
The test of ref count is not protected by lock, which is unsafe because
the ref count may have been changed by other threads during the test.
This patch fixes this.
Index: libvirt-0.9.11.4/src/rpc/virnetserver.c
===================================================================
--- libvirt-0.9.11.4.orig/src/rpc/virnetserver.c
+++ libvirt-0.9.11.4/src/rpc/virnetserver.c
@@ -794,15 +794,16 @@ void virNetServerQuit(virNetServerPtr sr
void virNetServerFree(virNetServerPtr srv)
{
int i;
+ int refs;
if (!srv)
return;
virNetServerLock(srv);
VIR_DEBUG("srv=%p refs=%d", srv, srv->refs);
- srv->refs--;
+ refs = --srv->refs;
virNetServerUnlock(srv);
- if (srv->refs > 0)
+ if (refs > 0)
return;
for (i = 0 ; i < srv->nservices ; i++)