[host] initial service framework implemented

This commit is contained in:
Geoffrey McRae
2017-10-31 23:21:05 +11:00
parent 941f0f1c16
commit 3dd205bafc
10 changed files with 274 additions and 8 deletions

View File

@@ -2,7 +2,7 @@
#include <tchar.h>
#include <common\debug.h>
#include "ivshmem.h"
#include "Service.h"
#define SERVICE_NAME "kvm-ivshmem-host"
@@ -146,19 +146,18 @@ VOID WINAPI ServiceCtrlHandler(DWORD CtrlCode)
DWORD WINAPI ServiceWorkerThread(LPVOID lpParam)
{
IVSHMEM * ivshmem = IVSHMEM::Get();
if (!ivshmem->Initialize())
Service *svc = svc->Get();
if (!svc->Initialize())
{
DEBUG_ERROR("Failed to initialize IVSHMEM");
DEBUG_ERROR("Failed to initialize service");
return ERROR;
}
while (WaitForSingleObject(app.serviceStopEvent, 0) != WAIT_OBJECT_0)
{
Sleep(1000);
}
if (!svc->Process(app.serviceStopEvent))
break;
ivshmem->DeInitialize();
svc->DeInitialize();
return ERROR_SUCCESS;
}