#include "assert.h"
struct _XENVIF_FRONTEND {
+ ULONG Magic;
PXENVIF_PDO Pdo;
PCHAR Path;
PCHAR Prefix;
HANDLE Handle;
};
+#define FRONTEND_MAGIC 0xf00ba4ed
+
static const PCHAR
FrontendStateName(
IN XENVIF_FRONTEND_STATE State
UNREFERENCED_PARAMETER(_Row);
UNREFERENCED_PARAMETER(NotificationType);
+ ASSERT3U(Frontend->Magic, ==, FRONTEND_MAGIC);
+
ThreadWake(Frontend->MibThread);
}
Trace("====>\n");
+ ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
+
Name = PdoGetName(Pdo);
Length = sizeof ("devices/vif/") + (ULONG)strlen(Name);
if (!NT_SUCCESS(status))
goto fail11;
+ (*Frontend)->Magic = FRONTEND_MAGIC;
+ _ReadWriteBarrier();
+
status = NotifyUnicastIpAddressChange(AF_UNSPEC,
FrontendIpAddressChange,
*Frontend,
// If IP Helper isn't available (as in Windows PE) then
// NotifyUnicastIpAddressChange will not be supported
Warning("Cannot record or update network info to XAPI %x\n", status);
- (*Frontend)->Handle = NULL;
+ // The documentation states that in the error case, the handle is
+ // always populated with NULL.
+ ASSERT((*Frontend)->Handle == NULL);
+ } else {
+ // By inference the handle should not be NULL in the success case
+ ASSERT((*Frontend)->Handle != NULL);
}
Trace("<====\n");
fail12:
Error("fail12\n");
+ (*Frontend)->Magic = 0;
+
ThreadAlert((*Frontend)->MibThread);
ThreadJoin((*Frontend)->MibThread);
(*Frontend)->MibThread = NULL;
{
Trace("====>\n");
+ ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
+
ASSERT(Frontend->State != FRONTEND_ENABLED);
ASSERT(Frontend->State != FRONTEND_CONNECTED);
if (Frontend->Handle != NULL) {
- CancelMibChangeNotify2(Frontend->Handle);
+ NTSTATUS status;
+
+ status = CancelMibChangeNotify2(Frontend->Handle);
+ ASSERT(NT_SUCCESS(status));
+
Frontend->Handle = NULL;
}
+ _ReadWriteBarrier();
+ Frontend->Magic = 0;
+
if (Frontend->State == FRONTEND_PREPARED) {
ASSERT(Frontend->Watch != NULL);