Changeset 25110 in vbox
- Timestamp:
- Nov 30, 2009 2:02:43 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DrvNAT.cpp
r24636 r25110 170 170 /** event to wakeup the guest receive thread */ 171 171 RTSEMEVENT EventRecv; 172 RTCRITSECT csEventRecv; 172 173 /** event to wakeup the guest urgent receive thread */ 173 174 RTSEMEVENT EventUrgRecv; 175 RTCRITSECT csEventUrgRecv; 174 176 /** Receive Req queue (deliver packets to the guest) */ 175 177 PRTREQQUEUE pRecvReqQueue; … … 231 233 { 232 234 PDRVNAT pThis = PDMINS_2_DATA(pDrvIns, PDRVNAT); 235 int rc; 233 236 234 237 if (pThread->enmState == PDMTHREADSTATE_INITIALIZING) … … 237 240 while (pThread->enmState == PDMTHREADSTATE_RUNNING) 238 241 { 242 rc = RTCritSectEnter(&pThis->csEventRecv); 243 AssertReleaseRC(rc); 239 244 RTReqProcess(pThis->pRecvReqQueue, 0); 245 rc = RTCritSectLeave(&pThis->csEventRecv); 246 AssertReleaseRC(rc); 240 247 if (ASMAtomicReadU32(&pThis->cPkt) == 0) 248 { 241 249 RTSemEventWait(pThis->EventRecv, RT_INDEFINITE_WAIT); 250 } 242 251 } 243 252 return VINF_SUCCESS; … … 248 257 { 249 258 PDRVNAT pThis = PDMINS_2_DATA(pDrvIns, PDRVNAT); 250 int rc = RTSemEventSignal(pThis->EventRecv); 259 int rc; 260 if (ASMAtomicReadU32(&pThis->cPkt) > 0) 261 { 262 rc = RTCritSectEnter(&pThis->csEventRecv); 263 AssertReleaseRC(rc); 264 rc = RTSemEventSignal(pThis->EventRecv); 265 AssertReleaseRC(rc); 266 rc = RTCritSectLeave(&pThis->csEventRecv); 267 } 251 268 252 269 STAM_COUNTER_INC(&pThis->StatNATRecvWakeups); 253 AssertReleaseRC(rc);254 270 return VINF_SUCCESS; 255 271 } … … 264 280 while (pThread->enmState == PDMTHREADSTATE_RUNNING) 265 281 { 282 int rc; 283 rc = RTCritSectEnter(&pThis->csEventUrgRecv); 284 AssertReleaseRC(rc); 266 285 RTReqProcess(pThis->pUrgRecvReqQueue, 0); 286 rc = RTCritSectLeave(&pThis->csEventUrgRecv); 287 AssertReleaseRC(rc); 267 288 if (ASMAtomicReadU32(&pThis->cUrgPkt) == 0) 268 RTSemEventWait(pThis->EventUrgRecv, RT_INDEFINITE_WAIT); 289 { 290 rc = RTSemEventWait(pThis->EventUrgRecv, RT_INDEFINITE_WAIT); 291 AssertReleaseRC(rc); 292 } 269 293 } 270 294 return VINF_SUCCESS; … … 273 297 { 274 298 PDRVNAT pThis = PDMINS_2_DATA(pDrvIns, PDRVNAT); 275 int rc = RTSemEventSignal(pThis->EventUrgRecv); 276 277 AssertReleaseRC(rc); 299 if (ASMAtomicReadU32(&pThis->cUrgPkt) > 0) 300 { 301 int rc; 302 rc = RTCritSectEnter(&pThis->csEventUrgRecv); 303 AssertReleaseRC(rc); 304 rc = RTSemEventSignal(pThis->EventUrgRecv); 305 AssertReleaseRC(rc); 306 rc = RTCritSectLeave(&pThis->csEventUrgRecv); 307 AssertReleaseRC(rc); 308 } 309 278 310 return VINF_SUCCESS; 279 311 } … … 317 349 while(ASMAtomicReadU32(&pThis->cUrgPkt) != 0) 318 350 { 351 rc = RTCritSectLeave(&pThis->csEventRecv); 352 AssertReleaseRC(rc); 319 353 rc = RTSemEventWait(pThis->EventRecv, RT_INDEFINITE_WAIT); 320 354 if ( RT_FAILURE(rc) … … 322 356 || rc == VERR_INTERRUPTED)) 323 357 goto done_unlocked; 358 rc = RTCritSectEnter(&pThis->csEventRecv); 359 AssertReleaseRC(rc); 324 360 } 325 361 … … 1135 1171 rc = RTSemEventCreate(&pThis->EventRecv); 1136 1172 rc = RTSemEventCreate(&pThis->EventUrgRecv); 1173 rc = RTCritSectInit(&pThis->csEventRecv); 1174 rc = RTCritSectInit(&pThis->csEventUrgRecv); 1137 1175 rc = RTCritSectInit(&pThis->csDevAccess); 1138 1176 rc = PDMDrvHlpTMTimerCreate(pThis->pDrvIns, TMCLOCK_REAL/*enmClock*/, drvNATSlowTimer,
Note:
See TracChangeset
for help on using the changeset viewer.