Changeset 8055 in vbox for trunk/src/VBox/Main/xml/Settings.cpp
- Timestamp:
- Apr 16, 2008 5:50:24 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/xml/Settings.cpp
r8029 r8055 21 21 #include <iprt/err.h> 22 22 #include <iprt/file.h> 23 #include <iprt/lock.h> 23 24 24 25 #include <libxml/tree.h> … … 74 75 { 75 76 xmlExternalEntityLoader defaultEntityLoader; 77 78 /** Used to provide some thread safety missing in libxml2 (see e.g. 79 * XmlTreeBackend::read()) */ 80 RTLockMtx lock; 76 81 } 77 82 xml; … … 347 352 : fileName (NULL), handle (NIL_RTFILE), opened (false) {} 348 353 349 Mode mode;350 354 char *fileName; 351 355 RTFILE handle; … … 356 360 : m (new Data()) 357 361 { 358 m->mode = aMode;359 360 362 m->fileName = RTStrDup (aFileName); 361 363 if (m->fileName == NULL) … … 365 367 switch (aMode) 366 368 { 367 case Read:369 case Mode_Read: 368 370 flags = RTFILE_O_READ; 369 371 break; 370 case Write:372 case Mode_Write: 371 373 flags = RTFILE_O_WRITE | RTFILE_O_CREATE; 372 374 break; 373 case ReadWrite:375 case Mode_ReadWrite: 374 376 flags = RTFILE_O_READ | RTFILE_O_WRITE; 375 377 } … … 382 384 } 383 385 384 File::File ( Mode aMode, RTFILE aHandle, const char *aFileName /* = NULL */)386 File::File (RTFILE aHandle, const char *aFileName /* = NULL */) 385 387 : m (new Data()) 386 388 { … … 388 390 throw EInvalidArg (RT_SRC_POS); 389 391 390 m->mode = aMode;391 392 m->handle = aHandle; 392 393 … … 903 904 m->trappedErr.reset(); 904 905 905 /* Set up the external entity resolver. Note that we do it in a 906 * thread-unsafe fashion because this stuff is not thread-safe in libxml2. 907 * Making it thread-safe would require a) guarding this method with a 908 * mutex and b) requiring our API caller not to use libxml2 on some other 909 * thread (which is not practically possible). So, our API is not 910 * thread-safe for now (note that there are more thread-unsafe assumptions 911 * below like xsltGenericError which is also a libxslt limitation).*/ 906 /* We use the global lock for the whole duration of this method to serialize 907 * access to thread-unsafe xmlGetExternalEntityLoader() and some other 908 * calls. It means that only one thread is able to parse an XML stream at a 909 * time but another choice would be to patch libxml2/libxslt which is 910 * unwanted now for several reasons. Search for "thread-safe" to find all 911 * unsafe cases. */ 912 RTLock alock (gGlobal.xml.lock); 913 912 914 xmlExternalEntityLoader oldEntityLoader = xmlGetExternalEntityLoader(); 913 915 sThat = this;
Note:
See TracChangeset
for help on using the changeset viewer.