Changeset 72547 in vbox for trunk/src/VBox/Main
- Timestamp:
- Jun 13, 2018 3:50:39 PM (7 years ago)
- Location:
- trunk/src/VBox/Main/src-server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/HostDnsService.cpp
r72483 r72547 81 81 Data(bool aThreaded) 82 82 : proxy(NULL), 83 fThreaded(aThreaded), 84 uLastExtraDataPoll(0), 85 fLaxComparison(0) 83 fThreaded(aThreaded) 86 84 {} 87 85 … … 92 90 RTTHREAD hMonitoringThread; 93 91 92 HostDnsInformation info; 93 }; 94 95 struct HostDnsMonitorProxy::Data 96 { 97 Data(HostDnsMonitor *aMonitor, VirtualBox *aParent) 98 : virtualbox(aParent), 99 monitor(aMonitor), 100 uLastExtraDataPoll(0), 101 fLaxComparison(0), 102 info() 103 {} 104 105 VirtualBox *virtualbox; 106 HostDnsMonitor *monitor; 107 94 108 uint64_t uLastExtraDataPoll; 95 109 uint32_t fLaxComparison; 96 110 HostDnsInformation info; 97 };98 99 struct HostDnsMonitorProxy::Data100 {101 Data(HostDnsMonitor *aMonitor, VirtualBox *aParent)102 : virtualbox(aParent),103 monitor(aMonitor),104 info(NULL)105 {}106 107 ~Data()108 {109 if (info)110 {111 delete info;112 info = NULL;113 }114 }115 116 VirtualBox *virtualbox;117 HostDnsMonitor *monitor;118 HostDnsInformation *info;119 111 }; 120 112 … … 169 161 170 162 171 const HostDnsInformation &HostDnsMonitor::getInfo() const172 {173 return m->info;174 }175 176 163 void HostDnsMonitor::setInfo(const HostDnsInformation &info) 177 164 { 178 RTCLock grab(m_LockMtx);179 180 pollGlobalExtraData();181 182 if (info.equals(m->info))183 return;184 185 LogRel(("HostDnsMonitor: old information\n"));186 dumpHostDnsInformation(m->info);187 LogRel(("HostDnsMonitor: new information\n"));188 dumpHostDnsInformation(info);189 190 bool fIgnore = m->fLaxComparison && info.equals(m->info, m->fLaxComparison);191 m->info = info;192 193 if (fIgnore)194 {195 LogRel(("HostDnsMonitor: lax comparison %#x, not notifying\n", m->fLaxComparison));196 return;197 }198 199 165 if (m->proxy != NULL) 200 m->proxy->notify( );166 m->proxy->notify(info); 201 167 } 202 168 … … 204 170 { 205 171 m->proxy = proxy; 206 207 pollGlobalExtraData();208 172 209 173 if (m->fThreaded) … … 223 187 224 188 225 void HostDnsMonitor ::pollGlobalExtraData()226 { 227 VirtualBox *virtualbox = m-> proxy->getVirtualBox();189 void HostDnsMonitorProxy::pollGlobalExtraData() 190 { 191 VirtualBox *virtualbox = m->virtualbox; 228 192 if (RT_UNLIKELY(virtualbox == NULL)) 229 193 return; … … 314 278 HostDnsMonitor *monitor = HostDnsMonitor::createHostDnsMonitor(); 315 279 m = new HostDnsMonitorProxy::Data(monitor, aParent); 316 317 280 m->monitor->init(this); 318 updateInfo(); 319 } 320 321 322 VirtualBox *HostDnsMonitorProxy::getVirtualBox() const 323 { 281 } 282 283 284 void HostDnsMonitorProxy::notify(const HostDnsInformation &info) 285 { 286 bool fNotify = updateInfo(info); 287 if (fNotify) 288 m->virtualbox->i_onHostNameResolutionConfigurationChange(); 289 } 290 291 HRESULT HostDnsMonitorProxy::GetNameServers(std::vector<com::Utf8Str> &aNameServers) 292 { 293 AssertReturn(m != NULL, E_FAIL); 324 294 RTCLock grab(m_LockMtx); 325 return RT_LIKELY(m != NULL) ? m->virtualbox : NULL; 326 } 327 328 329 void HostDnsMonitorProxy::notify() 330 { 331 LogRel(("HostDnsMonitorProxy::notify\n")); 332 updateInfo(); 333 m->virtualbox->i_onHostNameResolutionConfigurationChange(); 334 } 335 336 HRESULT HostDnsMonitorProxy::GetNameServers(std::vector<com::Utf8Str> &aNameServers) 337 { 338 AssertReturn(m && m->info, E_FAIL); 295 296 LogRel(("HostDnsMonitorProxy::GetNameServers:\n")); 297 dumpHostDnsStrVector("name server", m->info.servers); 298 299 detachVectorOfString(m->info.servers, aNameServers); 300 301 return S_OK; 302 } 303 304 HRESULT HostDnsMonitorProxy::GetDomainName(com::Utf8Str *pDomainName) 305 { 306 AssertReturn(m != NULL, E_FAIL); 339 307 RTCLock grab(m_LockMtx); 340 308 341 LogRel(("HostDnsMonitorProxy::Get NameServers:\n"));342 dumpHostDnsStrVector("name server", m->info->servers);343 344 detachVectorOfString(m->info->servers, aNameServers);309 LogRel(("HostDnsMonitorProxy::GetDomainName: %s\n", 310 m->info.domain.empty() ? "no domain set" : m->info.domain.c_str())); 311 312 *pDomainName = m->info.domain.c_str(); 345 313 346 314 return S_OK; 347 315 } 348 316 349 HRESULT HostDnsMonitorProxy::Get DomainName(com::Utf8Str *pDomainName)350 { 351 AssertReturn(m && m->info, E_FAIL);317 HRESULT HostDnsMonitorProxy::GetSearchStrings(std::vector<com::Utf8Str> &aSearchStrings) 318 { 319 AssertReturn(m != NULL, E_FAIL); 352 320 RTCLock grab(m_LockMtx); 353 321 354 LogRel(("HostDnsMonitorProxy::Get DomainName: %s\n",355 m->info->domain.empty() ? "no domain set" : m->info->domain.c_str()));356 357 *pDomainName = m->info->domain.c_str();322 LogRel(("HostDnsMonitorProxy::GetSearchStrings:\n")); 323 dumpHostDnsStrVector("search string", m->info.searchList); 324 325 detachVectorOfString(m->info.searchList, aSearchStrings); 358 326 359 327 return S_OK; 360 328 } 361 329 362 HRESULT HostDnsMonitorProxy::GetSearchStrings(std::vector<com::Utf8Str> &aSearchStrings)363 { 364 AssertReturn(m && m->info, E_FAIL);330 bool HostDnsMonitorProxy::updateInfo(const HostDnsInformation &info) 331 { 332 LogRel(("HostDnsMonitor::updateInfo\n")); 365 333 RTCLock grab(m_LockMtx); 366 334 367 LogRel(("HostDnsMonitorProxy::GetSearchStrings:\n")); 368 dumpHostDnsStrVector("search string", m->info->searchList); 369 370 detachVectorOfString(m->info->searchList, aSearchStrings); 371 372 return S_OK; 373 } 374 375 void HostDnsMonitorProxy::updateInfo() 376 { 377 RTCLock grab(m_LockMtx); 378 379 HostDnsInformation *info = new HostDnsInformation(m->monitor->getInfo()); 380 HostDnsInformation *old = m->info; 381 335 if (info.equals(m->info)) 336 { 337 LogRel(("HostDnsMonitor: unchanged\n")); 338 return false; 339 } 340 341 pollGlobalExtraData(); 342 343 LogRel(("HostDnsMonitor: old information\n")); 344 dumpHostDnsInformation(m->info); 345 LogRel(("HostDnsMonitor: new information\n")); 346 dumpHostDnsInformation(info); 347 348 bool fIgnore = m->fLaxComparison != 0 && info.equals(m->info, m->fLaxComparison); 382 349 m->info = info; 383 if (old) 384 { 385 delete old; 386 } 350 351 if (fIgnore) 352 { 353 LogRel(("HostDnsMonitor: lax comparison %#x, not notifying\n", m->fLaxComparison)); 354 return false; 355 } 356 357 return true; 387 358 } 388 359 -
trunk/src/VBox/Main/src-server/HostDnsService.h
r72483 r72547 62 62 virtual HRESULT init(HostDnsMonitorProxy *proxy); 63 63 64 const HostDnsInformation &getInfo() const;65 66 64 protected: 67 65 explicit HostDnsMonitor(bool fThreaded = false); … … 77 75 private: 78 76 static DECLCALLBACK(int) threadMonitoringRoutine(RTTHREAD, void *); 79 void pollGlobalExtraData();80 77 81 78 protected: … … 96 93 ~HostDnsMonitorProxy(); 97 94 void init(VirtualBox *virtualbox); 98 void notify(); 99 100 VirtualBox *getVirtualBox() const; 95 void notify(const HostDnsInformation &info); 101 96 102 97 HRESULT GetNameServers(std::vector<com::Utf8Str> &aNameServers); … … 104 99 HRESULT GetSearchStrings(std::vector<com::Utf8Str> &aSearchStrings); 105 100 106 private: 107 void updateInfo(); 101 private: 102 void pollGlobalExtraData(); 103 bool updateInfo(const HostDnsInformation &info); 108 104 109 105 private:
Note:
See TracChangeset
for help on using the changeset viewer.