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.
This commit is contained in:
Hu Tao 2012-06-22 11:26:03 +08:00 committed by Jim Fehlig
parent de924ca90a
commit 9c77bf04b0

View File

@ -759,15 +759,16 @@ void virNetServerQuit(virNetServerPtr srv)
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++)