HostDnsServiceLinux.cpp revision 3f2299591cfeb8a37a3578bef9c44c1790860948
/* $Id$ */
/** @file
* Linux specific DNS information fetching.
*/
/*
* Copyright (C) 2013 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 <iprt/initterm.h>
#include <iprt/semaphore.h>
#include <errno.h>
#include <poll.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <string>
#include <vector>
#include "../HostDnsService.h"
static RTTHREAD g_DnsMonitoringThread;
static RTSEMEVENT g_DnsInitEvent;
static int g_DnsMonitorStop[2];
class FileDescriptor
{
public:
virtual ~FileDescriptor() {
if (fd != -1)
}
int fileDescriptor() const {return fd;}
protected:
int fd;
};
class AutoNotify:public FileDescriptor
{
public:
{
}
};
class AutoWatcher:public FileDescriptor
{
public:
AutoWatcher(const AutoNotify& notifier, const std::string& filename, uint32_t mask = IN_CLOSE_WRITE)
{
opt |= O_NONBLOCK;
}
~AutoWatcher()
{
}
private:
int nfd;
};
{
}
{
AutoNotify a;
while(true)
{
if (rc == -1)
continue;
("Debug Me"), VERR_INTERNAL_ERROR);
return VINF_SUCCESS; /* time to shutdown */
{
dns->readResolvConf();
/* notifyAll() takes required locks */
}
}
}
{
return S_OK;
}