提交 9c77bf04 编写于 作者: H Hu Tao 提交者: Jim Fehlig

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.
上级 de924ca9
......@@ -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++)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册