[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH 2/2] Lock the whole virConnect Object when disposing to avoid the thread race

On 2012年12月06日 00:23, Daniel P. Berrange wrote:
On Wed, Dec 05, 2012 at 10:48:44PM +0800, Osier Yang wrote:

Since the virConnect object is not locked wholely when doing
virConenctDispose, a thread can get the lock and thus might
cause the race.

This patch is to fix it by locking the whole virConnect object when
disposing it.

No, this is wrong. If two threads are using an object, they
must each be holding a reference on the object. virConnectDispose
is the *last* thing to happen to an object. If a 2nd thread is
still using an object when virConnectDipose runs, then by definition,
it has forgotten to hold a reference count.

Er, right.

Locking cannot save you
at this point - the 2nd thread will end up waiting on a mutex that
has been destroyed

Okay, I did the wrong thing, pushed your version. Thanks.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]