VirtualBox

Ignore:
Timestamp:
Apr 2, 2019 2:06:13 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
129752
Message:

Main/HostDnsService: Renaming and cleanup (no functional changes).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/HostDnsService.cpp

    r77666 r77984  
    7878}
    7979
    80 struct HostDnsMonitor::Data
     80struct HostDnsServiceBase::Data
    8181{
    8282    Data(bool aThreaded)
    83       : proxy(NULL),
    84         fThreaded(aThreaded)
     83        : pProxy(NULL)
     84        , fThreaded(aThreaded)
    8585    {}
    8686
    87     HostDnsMonitorProxy *proxy;
    88 
    89     const bool fThreaded;
    90     RTSEMEVENT hDnsInitEvent;
    91     RTTHREAD hMonitoringThread;
    92 
    93     HostDnsInformation info;
     87    /** Weak pointer to parent proxy object. */
     88    HostDnsMonitorProxy *pProxy;
     89    /** Whether the DNS monitor implementation has a dedicated monitoring thread. Optional. */
     90    const bool           fThreaded;
     91    /** Event for the monitor thread, if any. */
     92    RTSEMEVENT           hMonitorThreadEvent;
     93    /** Handle of the monitor thread, if any. */
     94    RTTHREAD             hMonitorThread;
     95    /** Generic host DNS information. */
     96    HostDnsInformation   info;
    9497};
    9598
    9699struct HostDnsMonitorProxy::Data
    97100{
    98     Data(HostDnsMonitor *aMonitor, VirtualBox *aParent)
    99       : virtualbox(aParent),
    100         monitor(aMonitor),
    101         uLastExtraDataPoll(0),
    102         fLaxComparison(0),
    103         info()
     101    Data(HostDnsServiceBase *aMonitor, VirtualBox *aParent)
     102        : pVirtualBox(aParent)
     103        , pMonitorImpl(aMonitor)
     104        , uLastExtraDataPoll(0)
     105        , fLaxComparison(0)
     106        , info()
    104107    {}
    105108
    106     VirtualBox *virtualbox;
    107     HostDnsMonitor *monitor;
     109    VirtualBox *pVirtualBox;
     110    HostDnsServiceBase *pMonitorImpl;
    108111
    109112    uint64_t uLastExtraDataPoll;
     
    113116
    114117
    115 HostDnsMonitor::HostDnsMonitor(bool fThreaded)
    116   : m(NULL)
    117 {
    118    m = new HostDnsMonitor::Data(fThreaded);
    119 }
    120 
    121 HostDnsMonitor::~HostDnsMonitor()
     118HostDnsServiceBase::HostDnsServiceBase(bool fThreaded)
     119    : m(NULL)
     120{
     121    m = new HostDnsServiceBase::Data(fThreaded);
     122}
     123
     124HostDnsServiceBase::~HostDnsServiceBase()
    122125{
    123126    if (m)
     
    128131}
    129132
    130 HostDnsMonitor *HostDnsMonitor::createHostDnsMonitor()
    131 {
    132     HostDnsMonitor *monitor = NULL;
     133HostDnsServiceBase *HostDnsServiceBase::createHostDnsMonitor(void)
     134{
     135    HostDnsServiceBase *pMonitor = NULL;
    133136
    134137#if defined (RT_OS_DARWIN)
    135     monitor = new HostDnsServiceDarwin();
     138    pMonitor = new HostDnsServiceDarwin();
    136139#elif defined(RT_OS_WINDOWS)
    137     monitor = new HostDnsServiceWin();
     140    pMonitor = new HostDnsServiceWin();
    138141#elif defined(RT_OS_LINUX)
    139     monitor = new HostDnsServiceLinux();
     142    pMonitor = new HostDnsServiceLinux();
    140143#elif defined(RT_OS_SOLARIS)
    141     monitor =  new HostDnsServiceSolaris();
     144    pMonitor =  new HostDnsServiceSolaris();
    142145#elif defined(RT_OS_FREEBSD)
    143     monitor = new HostDnsServiceFreebsd();
     146    pMonitor = new HostDnsServiceFreebsd();
    144147#elif defined(RT_OS_OS2)
    145     monitor = new HostDnsServiceOs2();
     148    pMonitor = new HostDnsServiceOs2();
    146149#else
    147     monitor = new HostDnsService();
     150    pMonitor = new HostDnsServiceBase();
    148151#endif
    149152
    150     return monitor;
    151 }
    152 
    153 
    154 void HostDnsMonitor::shutdown()
     153    return pMonitor;
     154}
     155
     156void HostDnsServiceBase::shutdown(void)
    155157{
    156158    monitorThreadShutdown();
    157     int rc = RTThreadWait(m->hMonitoringThread, 5000, NULL);
     159    int rc = RTThreadWait(m->hMonitorThread, 5000, NULL);
    158160    AssertRCSuccess(rc);
    159161}
    160162
    161163
    162 void HostDnsMonitor::setInfo(const HostDnsInformation &info)
    163 {
    164     if (m->proxy != NULL)
    165         m->proxy->notify(info);
    166 }
    167 
    168 HRESULT HostDnsMonitor::init(HostDnsMonitorProxy *proxy)
    169 {
    170     m->proxy = proxy;
     164void HostDnsServiceBase::setInfo(const HostDnsInformation &info)
     165{
     166    if (m->pProxy != NULL)
     167        m->pProxy->notify(info);
     168}
     169
     170HRESULT HostDnsServiceBase::init(HostDnsMonitorProxy *pProxy)
     171{
     172    m->pProxy = pProxy;
    171173
    172174    if (m->fThreaded)
    173175    {
    174         int rc = RTSemEventCreate(&m->hDnsInitEvent);
     176        int rc = RTSemEventCreate(&m->hMonitorThreadEvent);
    175177        AssertRCReturn(rc, E_FAIL);
    176178
    177         rc = RTThreadCreate(&m->hMonitoringThread,
    178                             HostDnsMonitor::threadMonitoringRoutine,
     179        rc = RTThreadCreate(&m->hMonitorThread,
     180                            HostDnsServiceBase::threadMonitoringRoutine,
    179181                            this, 128 * _1K, RTTHREADTYPE_IO,
    180182                            RTTHREADFLAGS_WAITABLE, "dns-monitor");
    181183        AssertRCReturn(rc, E_FAIL);
    182184
    183         RTSemEventWait(m->hDnsInitEvent, RT_INDEFINITE_WAIT);
     185        RTSemEventWait(m->hMonitorThreadEvent, RT_INDEFINITE_WAIT);
    184186    }
    185187    return S_OK;
    186188}
    187189
    188 
    189 void HostDnsMonitorProxy::pollGlobalExtraData()
    190 {
    191     VirtualBox *virtualbox = m->virtualbox;
    192     if (RT_UNLIKELY(virtualbox == NULL))
     190void HostDnsMonitorProxy::pollGlobalExtraData(void)
     191{
     192    VirtualBox *pVirtualBox = m->pVirtualBox;
     193    if (RT_UNLIKELY(pVirtualBox == NULL))
    193194        return;
    194195
     
    203204        const com::Bstr bstrHostDNSOrderIgnoreKey("VBoxInternal2/HostDNSOrderIgnore");
    204205        com::Bstr bstrHostDNSOrderIgnore;
    205         virtualbox->GetExtraData(bstrHostDNSOrderIgnoreKey.raw(),
     206        pVirtualBox->GetExtraData(bstrHostDNSOrderIgnoreKey.raw(),
    206207                                 bstrHostDNSOrderIgnore.asOutParam());
    207208        uint32_t fDNSOrderIgnore = 0;
     
    226227        const com::Bstr bstrHostDNSSuffixesIgnoreKey("VBoxInternal2/HostDNSSuffixesIgnore");
    227228        com::Bstr bstrHostDNSSuffixesIgnore;
    228         virtualbox->GetExtraData(bstrHostDNSSuffixesIgnoreKey.raw(),
     229        pVirtualBox->GetExtraData(bstrHostDNSSuffixesIgnoreKey.raw(),
    229230                                 bstrHostDNSSuffixesIgnore.asOutParam());
    230231        uint32_t fDNSSuffixesIgnore = 0;
     
    246247}
    247248
    248 void HostDnsMonitor::monitorThreadInitializationDone()
    249 {
    250     RTSemEventSignal(m->hDnsInitEvent);
    251 }
    252 
    253 
    254 DECLCALLBACK(int) HostDnsMonitor::threadMonitoringRoutine(RTTHREAD, void *pvUser)
    255 {
    256     HostDnsMonitor *pThis = static_cast<HostDnsMonitor *>(pvUser);
     249void HostDnsServiceBase::monitorThreadInitializationDone(void)
     250{
     251    RTSemEventSignal(m->hMonitorThreadEvent);
     252}
     253
     254DECLCALLBACK(int) HostDnsServiceBase::threadMonitoringRoutine(RTTHREAD, void *pvUser)
     255{
     256    HostDnsServiceBase *pThis = static_cast<HostDnsServiceBase *>(pvUser);
    257257    return pThis->monitorWorker();
    258258}
     
    271271void HostDnsMonitorProxy::init(VirtualBox* aParent)
    272272{
    273     HostDnsMonitor *monitor = HostDnsMonitor::createHostDnsMonitor();
    274     m = new HostDnsMonitorProxy::Data(monitor, aParent);
    275     m->monitor->init(this);
    276 }
    277 
    278 
    279 void HostDnsMonitorProxy::uninit()
     273    HostDnsServiceBase *pMonitor = HostDnsServiceBase::createHostDnsMonitor();
     274    m = new HostDnsMonitorProxy::Data(pMonitor, aParent);
     275    m->pMonitorImpl->init(this);
     276}
     277
     278void HostDnsMonitorProxy::uninit(void)
    280279{
    281280    if (m)
    282281    {
    283         m->monitor->shutdown();
     282        m->pMonitorImpl->shutdown();
    284283        delete m;
    285284        m = NULL;
     
    291290    bool fNotify = updateInfo(info);
    292291    if (fNotify)
    293         m->virtualbox->i_onHostNameResolutionConfigurationChange();
     292        m->pVirtualBox->i_onHostNameResolutionConfigurationChange();
    294293}
    295294
     
    362361    return true;
    363362}
    364 
    365363
    366364static void dumpHostDnsInformation(const HostDnsInformation& info)
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette