VBoxCredProvPoller.cpp revision fd5ba2cc6df7af715b45b9b93c1badef52765c8c
/* $Id$ */
/** @file
* VBoxCredPoller - Thread for querying / retrieving user credentials.
*/
/*
* Copyright (C) 2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#include <windows.h>
#include <VBox/VBoxGuest.h>
#include <VBox/VBoxGuestLib.h>
#include "VBoxCredProvProvider.h"
#include "VBoxCredProvCredential.h"
#include "VBoxCredProvPoller.h"
#include "VBoxCredProvUtils.h"
VBoxCredProvPoller::VBoxCredProvPoller(void) :
{
}
VBoxCredProvPoller::~VBoxCredProvPoller(void)
{
Shutdown();
}
{
VBoxCredProvVerbose(0, "VBoxCredProvPoller: Initializing\n");
/* Don't create more than one of them. */
if (m_hThreadPoller != NIL_RTTHREAD)
{
VBoxCredProvVerbose(0, "VBoxCredProvPoller: Thread already running, returning!\n");
return VINF_SUCCESS;
}
/* Create the poller thread. */
int rc = RTThreadCreate(&m_hThreadPoller, VBoxCredProvPoller::threadPoller, this, 0, RTTHREADTYPE_INFREQUENT_POLLER,
RTTHREADFLAGS_WAITABLE, "credpoll");
if (RT_FAILURE(rc))
return rc;
}
int VBoxCredProvPoller::Shutdown(void)
{
VBoxCredProvVerbose(0, "VBoxCredProvPoller: Shutdown\n");
if (m_hThreadPoller == NIL_RTTHREAD)
return VINF_SUCCESS;
/* Post termination event semaphore. */
if (RT_SUCCESS(rc))
{
VBoxCredProvVerbose(0, "VBoxCredProvPoller: Waiting for thread to terminate\n");
/* Wait until the thread has terminated. */
}
else
{
/* Failed to signal the thread - very unlikely - so no point in waiting long. */
}
return rc;
}
{
for (;;)
{
int rc;
if (RT_FAILURE(rc))
{
if (rc != VERR_NOT_FOUND)
}
else
{
VBoxCredProvVerbose(0, "VBoxCredProvPoller: Credentials available, notifying provider\n");
}
/* Wait a bit. */
{
VBoxCredProvVerbose(0, "VBoxCredProvPoller: Terminating\n");
break;
}
}
return VINF_SUCCESS;
}