Changeset 698 in vbox for trunk/src/VBox/Devices/Network
- Timestamp:
- Feb 6, 2007 10:53:20 AM (18 years ago)
- Location:
- trunk/src/VBox/Devices/Network
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DevPCNet.cpp
r652 r698 3780 3780 pData->Led.Asserted.s.fError = pData->Led.Actual.s.fError = 1; 3781 3781 } 3782 Assert(!PDMCritSectIsOwner(&pData->CritSect)); 3782 3783 pData->pDrv->pfnNotifyLinkChanged(pData->pDrv, enmState); 3783 3784 } -
trunk/src/VBox/Devices/Network/DrvNAT.cpp
r587 r698 36 36 #include <iprt/file.h> 37 37 #include <iprt/string.h> 38 #include <iprt/critsect.h> 38 39 39 40 #include "Builtins.h" … … 54 55 /** Pointer to the driver instance. */ 55 56 PPDMDRVINS pDrvIns; 56 57 /** Slirp critical section. */ 58 RTCRITSECT CritSect; 57 59 } DRVNAT, *PDRVNAT; 58 60 … … 73 75 /** The thread id of the select thread (drvNATSelectThread()). */ 74 76 static RTTHREAD g_ThreadSelect; 75 76 static RTCRITSECT g_CritSectSlirp;77 77 #endif 78 78 … … 89 89 static DECLCALLBACK(int) drvNATSend(PPDMINETWORKCONNECTOR pInterface, const void *pvBuf, size_t cb) 90 90 { 91 PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface); 92 PDRVNAT pData = PDMINS2DATA(pDrvIns, PDRVNAT); 93 91 94 LogFlow(("drvNATSend: pvBuf=%p cb=%#x\n", pvBuf, cb)); 92 95 Log2(("drvNATSend: pvBuf=%p cb=%#x\n" 93 96 "%.*Vhxd\n", 94 97 pvBuf, cb, cb, pvBuf)); 98 99 int rc = RTCritSectEnter(&pData->CritSect); 100 AssertReleaseRC(rc); 101 95 102 slirp_input((uint8_t *)pvBuf, cb); 103 RTCritSectLeave(&pData->CritSect); 96 104 return VINF_SUCCESS; 97 105 } … … 124 132 static DECLCALLBACK(void) drvNATNotifyLinkChanged(PPDMINETWORKCONNECTOR pInterface, PDMNETWORKLINKSTATE enmLinkState) 125 133 { 134 PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface); 135 PDRVNAT pData = PDMINS2DATA(pDrvIns, PDRVNAT); 136 126 137 LogFlow(("drvNATNotifyLinkChanged: enmLinkState=%d\n", enmLinkState)); 138 139 int rc = RTCritSectEnter(&pData->CritSect); 140 AssertReleaseRC(rc); 127 141 switch (enmLinkState) 128 142 { … … 131 145 slirp_link_up(); 132 146 break; 147 133 148 case PDMNETWORKLINKSTATE_DOWN: 134 149 case PDMNETWORKLINKSTATE_DOWN_RESUME: … … 136 151 slirp_link_down(); 137 152 break; 153 138 154 default: 139 155 AssertMsgFailed(("drvNATNotifyLinkChanged: unexpected link state %d\n", enmLinkState)); 140 156 } 157 RTCritSectLeave(&pData->CritSect); 141 158 } 142 159 … … 162 179 static DECLCALLBACK(void) drvNATPoller(PPDMDRVINS pDrvIns) 163 180 { 181 PDRVNAT pData = PDMINS2DATA(pDrvIns, PDRVNAT); 164 182 fd_set ReadFDs; 165 183 fd_set WriteFDs; … … 169 187 FD_ZERO(&WriteFDs); 170 188 FD_ZERO(&XcptFDs); 189 190 int rc = RTCritSectEnter(&pData->CritSect); 191 AssertReleaseRC(rc); 192 171 193 slirp_select_fill(&cFDs, &ReadFDs, &WriteFDs, &XcptFDs); 172 194 … … 175 197 if (cReadFDs >= 0) 176 198 slirp_select_poll(&ReadFDs, &WriteFDs, &XcptFDs); 199 200 RTCritSectLeave(&pData->CritSect); 177 201 } 178 202 … … 185 209 int slirp_can_output(void) 186 210 { 211 int rcCanSend = 0; 212 213 Assert(RTCritSectIsOwner(&g_pDrv->CritSect)); 214 RTCritSectLeave(&g_pDrv->CritSect); 215 187 216 if (g_pDrv) 188 return g_pDrv->pPort->pfnCanReceive(g_pDrv->pPort); 189 return 0; 217 rcCanSend = g_pDrv->pPort->pfnCanReceive(g_pDrv->pPort); 218 219 int rc = RTCritSectEnter(&g_pDrv->CritSect); 220 AssertReleaseRC(rc); 221 222 return rcCanSend; 190 223 } 191 224 … … 202 235 if (g_pDrv) 203 236 { 237 Assert(RTCritSectIsOwner(&g_pDrv->CritSect)); 238 RTCritSectLeave(&g_pDrv->CritSect); 239 204 240 int rc = g_pDrv->pPort->pfnReceive(g_pDrv->pPort, pu8Buf, cb); 205 AssertRC(rc); NOREF(rc); 241 AssertRC(rc); 242 243 rc = RTCritSectEnter(&g_pDrv->CritSect); 244 AssertReleaseRC(rc); 206 245 } 207 246 } … … 242 281 static DECLCALLBACK(void) drvNATDestruct(PPDMDRVINS pDrvIns) 243 282 { 283 PDRVNAT pData = PDMINS2DATA(pDrvIns, PDRVNAT); 284 244 285 LogFlow(("drvNATDestruct:\n")); 286 245 287 #if ARCH_BITS == 64 246 288 LogRel(("NAT: g_cpvHashUsed=%RU32 g_cpvHashCollisions=%RU32 g_cpvHashInserts=%RU64 g_cpvHashDone=%RU64\n", … … 248 290 #endif 249 291 slirp_term(); 292 RTCritSectDelete(&pData->CritSect); 250 293 g_pDrv = NULL; 251 294 } … … 368 411 N_("Configuration error: the above device/driver didn't export the network port interface!\n")); 369 412 370 #if 0371 413 /* 372 * The slirp lock and thread sem.414 * The slirp lock.. 373 415 */ 374 int rc = RTCritSectInit(& g_CritSectSlirp);416 int rc = RTCritSectInit(&pData->CritSect); 375 417 if (VBOX_FAILURE(rc)) 376 418 return rc; 419 #if 0 377 420 rc = RTSemEventCreate(&g_EventSem); 378 421 if (VBOX_SUCCESS(rc)) … … 386 429 { 387 430 #endif 388 int rc;389 431 /* 390 432 * Initialize slirp. … … 428 470 g_EventSem = NULL; 429 471 } 430 RTCritSectDelete(&g_CritSectSlirp);431 472 #endif 473 RTCritSectDelete(&pData->CritSect); 432 474 return rc; 433 475 }
Note:
See TracChangeset
for help on using the changeset viewer.