VirtualBox

Changeset 55223 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
Apr 13, 2015 6:06:30 PM (10 years ago)
Author:
vboxsync
Message:

Main/HostDnsService: if VBoxInternal2/HostDNSOrderIgnore global
extradata is set to a value other than "0", don't send notification
when only the order of nameservers changed.

Location:
trunk/src/VBox/Main/src-server
Files:
4 edited

Legend:

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

    r55200 r55223  
    2929
    3030#include <algorithm>
     31#include <set>
    3132#include <string>
    3233#include "HostDnsService.h"
     
    3940
    4041
    41 bool HostDnsInformation::equals(const HostDnsInformation &info) const
    42 {
    43     return    (servers == info.servers)
    44            && (domain == info.domain)
    45            && (searchList == info.searchList);
     42bool HostDnsInformation::equals(const HostDnsInformation &info, bool fDNSOrderIgnore) const
     43{
     44    if (fDNSOrderIgnore)
     45    {
     46        std::set<std::string> l(servers.begin(), servers.end());
     47        std::set<std::string> r(info.servers.begin(), info.servers.end());
     48
     49        return (l == r)
     50            && (domain == info.domain)
     51            && (searchList == info.searchList); // XXX: also ignore order?
     52    }
     53    else
     54    {
     55        return (servers == info.servers)
     56            && (domain == info.domain)
     57            && (searchList == info.searchList);
     58    }
    4659}
    4760
     
    5770struct HostDnsMonitor::Data
    5871{
    59     Data(bool aThreaded) :
     72    Data(bool aThreaded)
     73      : fDNSOrderIgnore(false),
    6074        fThreaded(aThreaded)
    6175    {}
     
    6377    std::vector<PCHostDnsMonitorProxy> proxies;
    6478    HostDnsInformation info;
     79    bool fDNSOrderIgnore;
    6580    const bool fThreaded;
    6681    RTTHREAD hMonitoringThread;
     
    108123}
    109124
    110 const HostDnsMonitor *HostDnsMonitor::getHostDnsMonitor()
     125const HostDnsMonitor *HostDnsMonitor::getHostDnsMonitor(VirtualBox *aParent)
    111126{
    112127    /* XXX: Moved initialization from HostImpl.cpp */
     
    128143        g_monitor = new HostDnsService();
    129144# endif
    130         g_monitor->init();
     145        g_monitor->init(aParent);
    131146    }
    132147
     
    179194    dumpHostDnsInformation(info);
    180195
     196    bool fIgnore = m->fDNSOrderIgnore && info.equals(m->info, m->fDNSOrderIgnore);
    181197    m->info = info;
     198
     199    if (fIgnore)
     200    {
     201        LogRel(("HostDnsMonitor: order change only, not notifying\n"));
     202        return;
     203    }
    182204
    183205    std::vector<PCHostDnsMonitorProxy>::const_iterator it;
     
    186208}
    187209
    188 HRESULT HostDnsMonitor::init()
    189 {
     210HRESULT HostDnsMonitor::init(VirtualBox *virtualbox)
     211{
     212    const com::Bstr bstrHostDNSOrderIgnoreKey("VBoxInternal2/HostDNSOrderIgnore");
     213    com::Bstr bstrHostDNSOrderIgnore;
     214    virtualbox->GetExtraData(bstrHostDNSOrderIgnoreKey.raw(),
     215                             bstrHostDNSOrderIgnore.asOutParam());
     216
     217    if (bstrHostDNSOrderIgnore.isNotEmpty())
     218    {
     219        LogRel(("HostDnsMonitor: %ls=%ls\n",
     220                bstrHostDNSOrderIgnoreKey.raw(),
     221                bstrHostDNSOrderIgnore.raw()));
     222
     223        if (bstrHostDNSOrderIgnore != "0")
     224            m->fDNSOrderIgnore = true;
     225    }
     226
    190227    if (m->fThreaded)
    191228    {
  • trunk/src/VBox/Main/src-server/HostDnsService.h

    r55200 r55223  
    3939    std::string domain;
    4040    std::vector<std::string> searchList;
    41     bool equals(const HostDnsInformation &) const;
     41    bool equals(const HostDnsInformation &, bool fDNSOrderIgnore = false) const;
    4242};
    4343
     
    4949{
    5050  public:
    51     static const HostDnsMonitor *getHostDnsMonitor();
     51    static const HostDnsMonitor *getHostDnsMonitor(VirtualBox *virtualbox);
    5252    static void shutdown();
    5353
     
    5757    /* @note: method will wait till client call
    5858       HostDnsService::monitorThreadInitializationDone() */
    59     virtual HRESULT init();
     59    virtual HRESULT init(VirtualBox *virtualbox);
    6060
    6161  protected:
     
    9191    HostDnsMonitorProxy();
    9292    ~HostDnsMonitorProxy();
    93     void init(const HostDnsMonitor *aMonitor, VirtualBox *aParent);
     93    void init(const HostDnsMonitor *aMonitor, VirtualBox *virtualbox);
    9494    void notify() const;
    9595
     
    117117    HostDnsServiceDarwin();
    118118    ~HostDnsServiceDarwin();
    119     HRESULT init();
     119    virtual HRESULT init(VirtualBox *virtualbox);
    120120
    121121    protected:
     
    136136    HostDnsServiceWin();
    137137    ~HostDnsServiceWin();
    138     HRESULT init();
     138    virtual HRESULT init(VirtualBox *virtualbox);
    139139
    140140    protected:
     
    156156    explicit HostDnsServiceResolvConf(bool fThreaded = false) : HostDnsMonitor(fThreaded), m(NULL) {}
    157157    virtual ~HostDnsServiceResolvConf();
    158     virtual HRESULT init(const char *aResolvConfFileName);
     158    virtual HRESULT init(VirtualBox *virtualbox, const char *aResolvConfFileName);
    159159    const std::string& resolvConf() const;
    160160
     
    180180    HostDnsServiceSolaris(){}
    181181    ~HostDnsServiceSolaris(){}
    182     HRESULT init(){ return HostDnsServiceResolvConf::init("/etc/resolv.conf");}
     182    virtual HRESULT init(VirtualBox *virtualbox) {
     183        return HostDnsServiceResolvConf::init(virtualbox, "/etc/resolv.conf");
     184    }
    183185};
    184186
     
    189191    HostDnsServiceLinux():HostDnsServiceResolvConf(true){}
    190192    virtual ~HostDnsServiceLinux();
    191     virtual HRESULT init(){ return HostDnsServiceResolvConf::init("/etc/resolv.conf");}
     193    virtual HRESULT init(VirtualBox *virtualbox) {
     194        return HostDnsServiceResolvConf::init(virtualbox, "/etc/resolv.conf");
     195    }
    192196
    193197  protected:
     
    202206    HostDnsServiceFreebsd(){}
    203207    ~HostDnsServiceFreebsd(){}
    204     HRESULT init(){ return HostDnsServiceResolvConf::init("/etc/resolv.conf");}
     208    virtual HRESULT init(VirtualBox *virtualbox) {
     209        return HostDnsServiceResolvConf::init(virtualbox, "/etc/resolv.conf");
     210    }
    205211};
    206212
     
    212218    ~HostDnsServiceOs2(){}
    213219    /* XXX: \\MPTN\\ETC should be taken from environment variable ETC  */
    214     HRESULT init(){ return init("\\MPTN\\ETC\\RESOLV2");}
     220    virtual HRESULT init(VirtualBox *virtualbox) {
     221        return HostDnsServiceResolvConf::init(virtualbox, "\\MPTN\\ETC\\RESOLV2");
     222    }
    215223};
    216224
  • trunk/src/VBox/Main/src-server/HostDnsServiceResolvConf.cpp

    r53624 r55223  
    6767}
    6868
    69 HRESULT HostDnsServiceResolvConf::init(const char *aResolvConfFileName)
     69HRESULT HostDnsServiceResolvConf::init(VirtualBox *virtualbox, const char *aResolvConfFileName)
    7070{
    7171    m = new Data(aResolvConfFileName);
    7272
    73     HostDnsMonitor::init();
     73    HostDnsMonitor::init(virtualbox);
    7474
    7575    readResolvConf();
  • trunk/src/VBox/Main/src-server/HostImpl.cpp

    r53815 r55223  
    300300    i_updateNetIfList();
    301301
    302     m->hostDnsMonitorProxy.init(HostDnsMonitor::getHostDnsMonitor(), m->pParent);
     302    m->hostDnsMonitorProxy.init(HostDnsMonitor::getHostDnsMonitor(m->pParent), m->pParent);
    303303
    304304#if defined(RT_OS_WINDOWS)
Note: See TracChangeset for help on using the changeset viewer.

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