[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [win-pv-devel] [PATCH] Don't get XENBUS_SUSPEND callback registration on AdapterCount
Instances will not necessarily come and go in order so we can't know that the last instance to go will be the one the registered the callback. Instead register a callback for every instance and just use AdapterCount to decide which instance writes distribution information to xenstore. Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx> --- src/xennet/adapter.c | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/src/xennet/adapter.c b/src/xennet/adapter.c index f105724..0b262d5 100644 --- a/src/xennet/adapter.c +++ b/src/xennet/adapter.c @@ -1380,8 +1380,15 @@ AdapterSuspendCallbackLate( ) { PXENNET_ADAPTER Adapter = Argument; + LONG Count; + + (VOID) InterlockedDecrement(&AdapterCount); + + Count = InterlockedIncrement(&AdapterCount); + ASSERT(Count != 0); - (VOID) __AdapterSetDistribution(Adapter); + if (Count == 1) + (VOID) __AdapterSetDistribution(Adapter); } static NTSTATUS @@ -1397,12 +1404,8 @@ AdapterSetDistribution( Count = InterlockedIncrement(&AdapterCount); ASSERT(Count != 0); - if (Count != 1) - goto done; - - status = __AdapterSetDistribution(Adapter); - if (!NT_SUCCESS(status)) - goto fail1; + if (Count == 1) + (VOID) __AdapterSetDistribution(Adapter); status = XENBUS_SUSPEND(Register, &Adapter->SuspendInterface, @@ -1411,20 +1414,19 @@ AdapterSetDistribution( Adapter, &Adapter->SuspendCallbackLate); if (!NT_SUCCESS(status)) - goto fail2; + goto fail1; -done: Trace("<====\n"); return STATUS_SUCCESS; -fail2: - Error("fail2\n"); - - __AdapterClearDistribution(Adapter); - fail1: Error("fail1 (%08x)\n", status); + Count = InterlockedDecrement(&AdapterCount); + + if (Count == 0) + __AdapterClearDistribution(Adapter); + return status; } @@ -1437,19 +1439,16 @@ AdapterClearDistribution( Trace("====>\n"); - Count = InterlockedDecrement(&AdapterCount); - - if (Count != 0) - goto done; - XENBUS_SUSPEND(Deregister, &Adapter->SuspendInterface, Adapter->SuspendCallbackLate); Adapter->SuspendCallbackLate = NULL; - __AdapterClearDistribution(Adapter); + Count = InterlockedDecrement(&AdapterCount); + + if (Count == 0) + __AdapterClearDistribution(Adapter); -done: Trace("<====\n"); } @@ -1472,14 +1471,16 @@ AdapterEnable( if (!NT_SUCCESS(status)) goto fail2; - (VOID) AdapterSetDistribution(Adapter); + status = AdapterSetDistribution(Adapter); + if (!NT_SUCCESS(status)) + goto fail3; status = XENVIF_VIF(Enable, &Adapter->VifInterface, AdapterVifCallback, Adapter); if (!NT_SUCCESS(status)) - goto fail3; + goto fail4; AdapterMediaStateChange(Adapter); @@ -1487,9 +1488,10 @@ AdapterEnable( return NDIS_STATUS_SUCCESS; -fail3: +fail4: AdapterClearDistribution(Adapter); +fail3: XENBUS_SUSPEND(Release, &Adapter->SuspendInterface); fail2: -- 2.1.1 _______________________________________________ win-pv-devel mailing list win-pv-devel@xxxxxxxxxxxxxxxxxxxx http://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |