VirtualBox

Changeset 8020 in vbox for trunk/src/VBox/Main/xml


Ignore:
Timestamp:
Apr 16, 2008 10:14:39 AM (17 years ago)
Author:
vboxsync
Message:

Main/Settigs: Disabled File (..., RTFILE aHandle, ...) constructor since it is not thread-safe when the handle is shared across different File instances (needs a handle duplicate operation in the IPRT File API).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/xml/Settings.cpp

    r7387 r8020  
    2121#include <iprt/err.h>
    2222#include <iprt/file.h>
     23#include <iprt/lock.h>
    2324
    2425#include <libxml/tree.h>
     
    7475    {
    7576        xmlExternalEntityLoader defaultEntityLoader;
     77
     78        /** Used to provide some thread safety missing in libxml2 (see e.g.
     79         *  XmlTreeBackend::read()) */
     80        RTLockMtx lock;
    7681    }
    7782    xml;
     
    382387}
    383388
    384 File::File (Mode aMode, RTFILE aHandle, const char *aFileName /* = NULL */ )
     389#if 0
     390/// @todo disabled until made thread-safe by using handle duplicates
     391File::File (Mode aMode, RTFILE aHandle, const char *aFileName)
    385392    : m (new Data())
    386393{
     
    400407    setPos (0);
    401408}
     409#endif
    402410
    403411File::~File()
     
    903911    m->trappedErr.reset();
    904912
    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).*/
     913    /* We use the global lock for the whole duration of this method to serialize
     914     * access to thread-unsafe xmlGetExternalEntityLoader() and some other
     915     * calls. It means that only one thread is able to parse an XML stream at a
     916     * time but another choice would be to patch libxml2/libxslt which is
     917     * unwanted now for several reasons. Search for "thread-safe" to find all
     918     * unsafe cases. */
     919    RTLock alock (gGlobal.xml.lock);
     920
    912921    xmlExternalEntityLoader oldEntityLoader = xmlGetExternalEntityLoader();
    913922    sThat = this;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette