Changeset 101915 in vbox
- Timestamp:
- Nov 7, 2023 9:13:04 AM (15 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/ipc/ipcd/client/src/ipcdclient.cpp
r86374 r101915 59 59 #include "pratom.h" 60 60 61 #ifdef VBOX 62 # include <iprt/critsect.h> 63 # define VBOX_WITH_IPCCLIENT_RW_CS 64 #endif 61 #include <iprt/critsect.h> 65 62 66 63 /* ------------------------------------------------------------------------- */ … … 152 149 ~ipcClientState() 153 150 { 154 #ifndef VBOX_WITH_IPCCLIENT_RW_CS155 if (monitor)156 nsAutoMonitor::DestroyMonitor(monitor);157 #else158 151 RTCritSectRwDelete(&critSect); 159 #endif 160 } 161 162 #ifndef VBOX_WITH_IPCCLIENT_RW_CS 163 // 164 // the monitor protects the targetMap and the connected and shutdown flags. 165 // 166 // NOTE: we use a PRMonitor for this instead of a PRLock because we need 167 // the lock to be re-entrant. since we don't ever need to wait on 168 // this monitor, it might be worth it to implement a re-entrant 169 // wrapper for PRLock. 170 // 171 PRMonitor *monitor; 172 #else /* VBOX_WITH_IPCCLIENT_RW_CS */ 152 } 153 173 154 RTCRITSECTRW critSect; 174 #endif /* VBOX_WITH_IPCCLIENT_RW_CS */175 155 ipcTargetMap targetMap; 176 156 PRBool connected; … … 185 165 186 166 ipcClientState() 187 #ifndef VBOX_WITH_IPCCLIENT_RW_CS188 : monitor(nsAutoMonitor::NewMonitor("ipcClientState"))189 , connected(PR_FALSE)190 #else191 167 : connected(PR_FALSE) 192 #endif193 168 , shutdown(PR_FALSE) 194 169 , selfID(0) 195 170 { 196 #ifdef VBOX_WITH_IPCCLIENT_RW_CS197 171 /* Not employing the lock validator here to keep performance up in debug builds. */ 198 172 RTCritSectRwInitEx(&critSect, RTCRITSECT_FLAGS_NO_LOCK_VAL, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, NULL); 199 #endif200 173 } 201 174 }; … … 208 181 return NULL; 209 182 210 #ifndef VBOX_WITH_IPCCLIENT_RW_CS211 if (!cs->monitor || !cs->targetMap.Init())212 #else213 183 if (!RTCritSectRwIsInitialized(&cs->critSect) || !cs->targetMap.Init()) 214 #endif215 184 { 216 185 delete cs; … … 228 197 GetTarget(const nsID &aTarget, ipcTargetData **td) 229 198 { 230 #ifndef VBOX_WITH_IPCCLIENT_RW_CS231 nsAutoMonitor mon(gClientState->monitor);232 return gClientState->targetMap.Get(nsIDHashKey(&aTarget).GetKey(), td);233 #else234 199 RTCritSectRwEnterShared(&gClientState->critSect); 235 200 PRBool fRc = gClientState->targetMap.Get(nsIDHashKey(&aTarget).GetKey(), td); 236 201 RTCritSectRwLeaveShared(&gClientState->critSect); 237 202 return fRc; 238 #endif239 203 } 240 204 … … 242 206 PutTarget(const nsID &aTarget, ipcTargetData *td) 243 207 { 244 #ifndef VBOX_WITH_IPCCLIENT_RW_CS245 nsAutoMonitor mon(gClientState->monitor);246 return gClientState->targetMap.Put(nsIDHashKey(&aTarget).GetKey(), td);247 #else248 208 RTCritSectRwEnterExcl(&gClientState->critSect); 249 209 PRBool fRc = gClientState->targetMap.Put(nsIDHashKey(&aTarget).GetKey(), td); 250 210 RTCritSectRwLeaveExcl(&gClientState->critSect); 251 211 return fRc; 252 #endif253 212 } 254 213 … … 256 215 DelTarget(const nsID &aTarget) 257 216 { 258 #ifndef VBOX_WITH_IPCCLIENT_RW_CS259 nsAutoMonitor mon(gClientState->monitor);260 gClientState->targetMap.Remove(nsIDHashKey(&aTarget).GetKey());261 #else262 217 RTCritSectRwEnterExcl(&gClientState->critSect); 263 218 gClientState->targetMap.Remove(nsIDHashKey(&aTarget).GetKey()); 264 219 RTCritSectRwLeaveExcl(&gClientState->critSect); 265 #endif266 220 } 267 221 … … 857 811 // all targets but IPCM will not be able to use WaitTarget any more. 858 812 859 #ifndef VBOX_WITH_IPCCLIENT_RW_CS860 nsAutoMonitor mon(gClientState->monitor);861 #else862 813 RTCritSectRwEnterExcl(&gClientState->critSect); 863 #endif864 865 814 gClientState->shutdown = PR_TRUE; 866 815 gClientState->targetMap.EnumerateRead(EnumerateTargetMapAndNotify, nsnull); 867 868 #ifdef VBOX_WITH_IPCCLIENT_RW_CS869 816 RTCritSectRwLeaveExcl(&gClientState->critSect); 870 #endif871 817 } 872 818 … … 1357 1303 // unblock any calls to WaitTarget. 1358 1304 1359 #ifndef VBOX_WITH_IPCCLIENT_RW_CS1360 nsAutoMonitor mon(gClientState->monitor);1361 #else1362 1305 RTCritSectRwEnterExcl(&gClientState->critSect); 1363 #endif1364 1365 1306 gClientState->connected = PR_FALSE; 1366 1307 gClientState->targetMap.EnumerateRead(EnumerateTargetMapAndNotify, nsnull); 1367 1368 #ifdef VBOX_WITH_IPCCLIENT_RW_CS1369 1308 RTCritSectRwLeaveExcl(&gClientState->critSect); 1370 #endif1371 1309 } 1372 1310 … … 1469 1407 // targets) giving them an opportuninty to finish wait cycle because of 1470 1408 // the peer client death, when appropriate. 1471 #ifndef VBOX_WITH_IPCCLIENT_RW_CS1472 nsAutoMonitor mon(gClientState->monitor);1473 #else1474 1409 RTCritSectRwEnterShared(&gClientState->critSect); 1475 #endif1476 1477 1410 gClientState->targetMap.EnumerateRead(EnumerateTargetMapAndPlaceMsg, msg); 1478 1479 #ifdef VBOX_WITH_IPCCLIENT_RW_CS1480 1411 RTCritSectRwLeaveShared(&gClientState->critSect); 1481 #endif 1412 1482 1413 delete msg; 1483 1484 1414 return; 1485 1415 }
Note:
See TracChangeset
for help on using the changeset viewer.