|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v2 02/10] granter: Correct the accounting of Current
Current serves as an upper bound on the number of taken grants and must
be 0 on GranterDisconnect. We must increment Current before calling
PermitForeignAccess, and decrement it again on failure.
Assisted-by: LLM
Signed-off-by: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
---
src/xenvbd/granter.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/xenvbd/granter.c b/src/xenvbd/granter.c
index fd90965..eddcdcf 100644
--- a/src/xenvbd/granter.c
+++ b/src/xenvbd/granter.c
@@ -319,7 +319,9 @@ GranterGet(
if (Granter->Connected == FALSE)
goto fail1;
- status = XENBUS_GNTTAB(PermitForeignAccess,
+ Value = InterlockedIncrement(&Granter->Current);
+
+ status = XENBUS_GNTTAB(PermitForeignAccess,
&Granter->GnttabInterface,
Granter->Cache,
FALSE,
@@ -329,8 +331,7 @@ GranterGet(
&Entry);
if (!NT_SUCCESS(status))
goto fail2;
-
- Value = InterlockedIncrement(&Granter->Current);
+
if (Value > Granter->Maximum)
Granter->Maximum = Value;
@@ -339,6 +340,7 @@ GranterGet(
fail2:
Error("fail2\n");
+ InterlockedDecrement(&Granter->Current);
fail1:
Error("fail1 %08x\n", status);
return status;
--
2.56.0.windows.4
--
Ngoc Tu Dinh | Vates XCP-ng Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |