Changeset 48486 in vbox for trunk/src/VBox/Main/src-server
- Timestamp:
- Sep 16, 2013 2:57:58 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/darwin/HostDnsServiceDarwin.cpp
r48346 r48486 22 22 23 23 #include <iprt/err.h> 24 #include <iprt/thread.h> 25 #include <iprt/semaphore.h> 24 26 25 27 #include <CoreFoundation/CoreFoundation.h> … … 30 32 SCDynamicStoreRef g_store; 31 33 CFRunLoopSourceRef g_DnsWatcher; 34 CFRunLoopRef g_RunLoopRef; 35 RTTHREAD g_DnsMonitoringThread; 36 RTSEMEVENT g_DnsInitEvent; 32 37 33 38 static const CFStringRef kStateNetworkGlobalDNSKey = CFSTR("State:/Network/Global/DNS"); 39 40 static int hostMonitoringRoutine(RTTHREAD ThreadSelf, void *pvUser) 41 { 42 g_RunLoopRef = CFRunLoopGetCurrent(); 43 AssertReturn(g_RunLoopRef, VERR_INTERNAL_ERROR); 44 45 CFRetain(g_RunLoopRef); 46 47 CFArrayRef watchingArrayRef = CFArrayCreate(NULL, 48 (const void **)&kStateNetworkGlobalDNSKey, 49 1, &kCFTypeArrayCallBacks); 50 if (!watchingArrayRef) 51 { 52 CFRelease(g_DnsWatcher); 53 return E_OUTOFMEMORY; 54 } 55 56 if(SCDynamicStoreSetNotificationKeys(g_store, watchingArrayRef, NULL)) 57 CFRunLoopAddSource(CFRunLoopGetCurrent(), g_DnsWatcher, kCFRunLoopCommonModes); 58 59 CFRelease(watchingArrayRef); 60 61 RTSemEventSignal(g_DnsInitEvent); 62 63 CFRunLoopRun(); 64 65 CFRelease(g_RunLoopRef); 66 } 34 67 35 68 HostDnsServiceDarwin::HostDnsServiceDarwin(){} … … 68 101 return E_OUTOFMEMORY; 69 102 70 CFArrayRef watchingArrayRef = CFArrayCreate(NULL,71 (const void **)&kStateNetworkGlobalDNSKey,72 1, &kCFTypeArrayCallBacks);73 if (!watchingArrayRef)74 {75 CFRelease(g_DnsWatcher);76 return E_OUTOFMEMORY;77 }78 79 if(SCDynamicStoreSetNotificationKeys(g_store, watchingArrayRef, NULL))80 CFRunLoopAddSource(CFRunLoopGetMain(), g_DnsWatcher, kCFRunLoopCommonModes);81 82 CFRelease(watchingArrayRef);83 84 103 HRESULT hrc = HostDnsService::init(); 85 104 AssertComRCReturn(hrc, hrc); 105 106 int rc = RTSemEventCreate(&g_DnsInitEvent); 107 AssertRCReturn(rc, E_FAIL); 86 108 87 109 return update(); … … 92 114 HRESULT HostDnsServiceDarwin::start() 93 115 { 116 int rc = RTThreadCreate(&g_DnsMonitoringThread, hostMonitoringRoutine, 117 this, 128 * _1K, RTTHREADTYPE_IO, 0, "dns-monitor"); 118 AssertRCReturn(rc, E_FAIL); 119 120 RTSemEventWait(g_DnsInitEvent, RT_INDEFINITE_WAIT); 121 94 122 return S_OK; 95 123 } … … 98 126 void HostDnsServiceDarwin::stop() 99 127 { 128 129 if (g_RunLoopRef) 130 CFRunLoopStop(g_RunLoopRef); 100 131 } 101 132
Note:
See TracChangeset
for help on using the changeset viewer.