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.
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++)