mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 07:17:44 +00:00
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:
parent
de924ca90a
commit
9c77bf04b0
@ -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++)
|
||||
|
Loading…
Reference in New Issue
Block a user