Changeset 77993 in vbox for trunk/src/VBox/Main/src-server/HostDnsService.cpp
- Timestamp:
- Apr 3, 2019 3:11:36 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 129765
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/HostDnsService.cpp
r77984 r77993 131 131 } 132 132 133 /* static */ 133 134 HostDnsServiceBase *HostDnsServiceBase::createHostDnsMonitor(void) 134 135 { … … 154 155 } 155 156 156 void HostDnsServiceBase::shutdown(void)157 {158 monitorThreadShutdown();159 int rc = RTThreadWait(m->hMonitorThread, 5000, NULL);160 AssertRCSuccess(rc);161 }162 163 164 void HostDnsServiceBase::setInfo(const HostDnsInformation &info)165 {166 if (m->pProxy != NULL)167 m->pProxy->notify(info);168 }169 170 157 HRESULT HostDnsServiceBase::init(HostDnsMonitorProxy *pProxy) 171 158 { 159 LogRel(("HostDnsMonitor: initializing\n")); 160 161 AssertPtrReturn(pProxy, E_POINTER); 172 162 m->pProxy = pProxy; 173 163 174 164 if (m->fThreaded) 175 165 { 166 LogRel2(("HostDnsMonitor: starting thread ...\n")); 167 176 168 int rc = RTSemEventCreate(&m->hMonitorThreadEvent); 177 169 AssertRCReturn(rc, E_FAIL); 178 170 179 171 rc = RTThreadCreate(&m->hMonitorThread, 180 HostDnsServiceBase::threadMonitor ingRoutine,172 HostDnsServiceBase::threadMonitorProc, 181 173 this, 128 * _1K, RTTHREADTYPE_IO, 182 174 RTTHREADFLAGS_WAITABLE, "dns-monitor"); … … 184 176 185 177 RTSemEventWait(m->hMonitorThreadEvent, RT_INDEFINITE_WAIT); 186 } 178 179 LogRel2(("HostDnsMonitor: thread started\n")); 180 } 181 187 182 return S_OK; 183 } 184 185 void HostDnsServiceBase::uninit(void) 186 { 187 LogRel(("HostDnsMonitor: shutting down ...\n")); 188 189 if (m->fThreaded) 190 { 191 LogRel2(("HostDnsMonitor: waiting for thread ...\n")); 192 193 const RTMSINTERVAL uTimeoutMs = 30 * 1000; /* 30s */ 194 195 monitorThreadShutdown(uTimeoutMs); 196 197 int rc = RTThreadWait(m->hMonitorThread, uTimeoutMs, NULL); 198 if (RT_FAILURE(rc)) 199 LogRel(("HostDnsMonitor: waiting for thread failed with rc=%Rrc\n", rc)); 200 } 201 202 LogRel(("HostDnsMonitor: shut down\n")); 203 } 204 205 void HostDnsServiceBase::setInfo(const HostDnsInformation &info) 206 { 207 if (m->pProxy != NULL) 208 m->pProxy->notify(info); 188 209 } 189 210 … … 247 268 } 248 269 249 void HostDnsServiceBase::monitorThreadInitializationDone(void) 250 { 270 void HostDnsServiceBase::onMonitorThreadInitDone(void) 271 { 272 if (!m->fThreaded) /* If non-threaded, bail out, nothing to do here. */ 273 return; 274 251 275 RTSemEventSignal(m->hMonitorThreadEvent); 252 276 } 253 277 254 DECLCALLBACK(int) HostDnsServiceBase::threadMonitor ingRoutine(RTTHREAD, void *pvUser)278 DECLCALLBACK(int) HostDnsServiceBase::threadMonitorProc(RTTHREAD, void *pvUser) 255 279 { 256 280 HostDnsServiceBase *pThis = static_cast<HostDnsServiceBase *>(pvUser); 257 return pThis->monitorWorker(); 281 AssertPtrReturn(pThis, VERR_INVALID_POINTER); 282 return pThis->monitorThreadProc(); 258 283 } 259 284 260 285 /* HostDnsMonitorProxy */ 261 286 HostDnsMonitorProxy::HostDnsMonitorProxy() 262 : m(NULL)287 : m(NULL) 263 288 { 264 289 } … … 266 291 HostDnsMonitorProxy::~HostDnsMonitorProxy() 267 292 { 268 Assert(!m); 269 } 270 271 void HostDnsMonitorProxy::init(VirtualBox* aParent) 272 { 273 HostDnsServiceBase *pMonitor = HostDnsServiceBase::createHostDnsMonitor(); 274 m = new HostDnsMonitorProxy::Data(pMonitor, aParent); 275 m->pMonitorImpl->init(this); 293 uninit(); 294 } 295 296 HRESULT HostDnsMonitorProxy::init(VirtualBox* aParent) 297 { 298 AssertMsgReturn(m == NULL, ("DNS monitor proxy already initialized\n"), E_FAIL); 299 300 HostDnsServiceBase *pMonitorImpl = HostDnsServiceBase::createHostDnsMonitor(); 301 AssertPtrReturn(pMonitorImpl, E_OUTOFMEMORY); 302 303 Assert(m == NULL); /* Paranoia. */ 304 m = new HostDnsMonitorProxy::Data(pMonitorImpl, aParent); 305 AssertPtrReturn(m, E_OUTOFMEMORY); 306 307 return m->pMonitorImpl->init(this); 276 308 } 277 309 … … 280 312 if (m) 281 313 { 282 m->pMonitorImpl->shutdown(); 314 m->pMonitorImpl->uninit(); 315 283 316 delete m; 284 317 m = NULL; … … 288 321 void HostDnsMonitorProxy::notify(const HostDnsInformation &info) 289 322 { 290 bool fNotify = updateInfo(info);323 const bool fNotify = updateInfo(info); 291 324 if (fNotify) 292 325 m->pVirtualBox->i_onHostNameResolutionConfigurationChange(); … … 334 367 bool HostDnsMonitorProxy::updateInfo(const HostDnsInformation &info) 335 368 { 336 LogRel(("HostDnsMonitor: :updateInfo\n"));369 LogRel(("HostDnsMonitor: updating information\n")); 337 370 RTCLock grab(m_LockMtx); 338 371
Note:
See TracChangeset
for help on using the changeset viewer.