Changeset 55085 in vbox for trunk/src/VBox/Main/src-server/win
- Timestamp:
- Apr 2, 2015 12:17:22 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/win/HostDnsServiceWin.cpp
r54662 r55085 35 35 { 36 36 HKEY hKeyTcpipParameters; 37 bool fTimerArmed; 37 38 38 39 #define DATA_SHUTDOWN_EVENT 0 39 40 #define DATA_DNS_UPDATE_EVENT 1 40 #define DATA_MAX_EVENT 2 41 #define DATA_TIMER 2 42 #define DATA_MAX_EVENT 3 41 43 HANDLE haDataEvent[DATA_MAX_EVENT]; 42 44 … … 44 46 { 45 47 hKeyTcpipParameters = NULL; 48 fTimerArmed = false; 46 49 47 50 for (size_t i = 0; i < DATA_MAX_EVENT; ++i) … … 81 84 for (size_t i = 0; i < DATA_MAX_EVENT; ++i) 82 85 { 83 data->haDataEvent[i] = CreateEvent(NULL, TRUE, FALSE, NULL); 84 if (data->haDataEvent[i] == NULL) 86 HANDLE h; 87 88 if (i == DATA_TIMER) 89 h = CreateWaitableTimer(NULL, FALSE, NULL); 90 else 91 h = CreateEvent(NULL, TRUE, FALSE, NULL); 92 93 if (h == NULL) 85 94 { 86 95 LogRel(("HostDnsServiceWin: failed to create event (error %d)\n", GetLastError())); 87 96 return; 88 97 } 98 99 data->haDataEvent[i] = h; 89 100 } 90 101 … … 156 167 if (dwReady == WAIT_OBJECT_0 + DATA_DNS_UPDATE_EVENT) 157 168 { 158 updateInfo(); 169 /* 170 * Registry updates for multiple values are not atomic, so 171 * wait a bit to avoid racing and reading partial update. 172 */ 173 if (!m->fTimerArmed) 174 { 175 LARGE_INTEGER delay; /* in 100ns units */ 176 delay.QuadPart = -2 * 1000 * 1000 * 10LL; /* relative: 2s */ 177 178 BOOL ok = SetWaitableTimer(m->haDataEvent[DATA_TIMER], &delay, 179 0, NULL, NULL, TRUE); 180 if (ok) 181 { 182 m->fTimerArmed = true; 183 } 184 else 185 { 186 LogRel(("HostDnsServiceWin: failed to arm timer (error %d)\n", GetLastError())); 187 updateInfo(); 188 } 189 } 159 190 160 191 ResetEvent(m->haDataEvent[DATA_DNS_UPDATE_EVENT]); 161 192 registerNotification(m->hKeyTcpipParameters, 162 193 m->haDataEvent[DATA_DNS_UPDATE_EVENT]); 163 194 } 195 else if (dwReady == WAIT_OBJECT_0 + DATA_TIMER) 196 { 197 m->fTimerArmed = false; 198 updateInfo(); 199 } 200 else if (dwReady == WAIT_FAILED) 201 { 202 LogRel(("HostDnsServiceWin: WaitForMultipleObjects failed: error %d\n", GetLastError())); 203 return VERR_INTERNAL_ERROR; 164 204 } 165 205 else 166 206 { 167 if (dwReady == WAIT_FAILED) 168 LogRel(("HostDnsServiceWin: WaitForMultipleObjects failed: error %d\n", GetLastError())); 169 else 170 LogRel(("HostDnsServiceWin: WaitForMultipleObjects unexpected return value %d\n", dwReady)); 207 LogRel(("HostDnsServiceWin: WaitForMultipleObjects unexpected return value %d\n", dwReady)); 171 208 return VERR_INTERNAL_ERROR; 172 209 }
Note:
See TracChangeset
for help on using the changeset viewer.