VirtualBox

Changeset 8029 in vbox


Ignore:
Timestamp:
Apr 16, 2008 11:36:57 AM (17 years ago)
Author:
vboxsync
Message:

Main: Reverted r29679 (some file access problems).

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/settings.h

    r8020 r8029  
    8181 * Making deep copies or detaching the existing shallow copy from its original
    8282 * is not yet supported.
    83  *
    84  * Note that the Settings File API is not thread-safe. It means that if you
    85  * want to use the same instance of a class from the settings namespace on more
    86  * than one thread at a time, you will have to provide necessary access
    87  * serialization yourself.
    8883 *
    8984 * Due to some (not propely studied) libxml2 limitations, the Settings File
     
    11761171 * regular files.
    11771172 *
    1178  * The File class uses IPRT File API for file operations. Note that IPRT File
    1179  * API is not thread-safe. This means that if you pass the same RTFILE handle to
    1180  * different File instances that may be simultaneously used on different
    1181  * threads, you should care about serialization; otherwise you will get garbage
    1182  * when reading from such File instances.
    1183  *
    1184  * @todo We should duplicate file handles (once this API is in IPRT) passed to
    1185  *       constructors to provide thread-safety.
     1173 * The File class uses IPRT File API for file operations.
    11861174 */
    11871175class VBOXSETTINGS_CLASS File : public Input, public Output
     
    12041192    File (Mode aMode, const char *aFileName);
    12051193
    1206 #if 0
    1207     /// @todo disabled until made thread-safe by using handle duplicates
    12081194    /**
    12091195     * Uses the given file handle to perform file operations. The given file
     
    12181204     * this object destruction.
    12191205     *
    1220      * @note It you pass the same RTFILE handle to more than one File instance,
    1221      *       please make sure you have provided serialization in case if these
    1222      *       instasnces are to be simultaneously used by different threads.
    1223      *       Otherwise you may get garbage when reading or writing.
    1224      *
    12251206     * @param aHandle   Open file handle.
    12261207     * @param aMode     File mode of the open file handle.
    1227      * @param aFileName File name (for reference, may be NULL).
    1228      */
    1229     File (Mode aMode, RTFILE aHandle, const char *aFileName);
    1230 #endif
     1208     * @param aFileName File name (for reference).
     1209     */
     1210    File (Mode aMode, RTFILE aHandle, const char *aFileName = NULL);
    12311211
    12321212    /**
     
    13021282/**
    13031283 * The XmlTreeBackend class uses XML markup to store settings trees.
    1304  *
    1305  * @note libxml2 and libxslt libraries used by the XmlTreeBackend are not
    1306  * fully reentrant. To "fix" this, the XmlTreeBackend backend serializes access
    1307  * to such non-reentrant parts using a global mutex so that only one thread can
    1308  * use non-reentrant code at a time. Currently, this relates to the #rawRead()
    1309  * method (and to #read() as a consequence). This menas that only one thread can
    1310  * parse an XML stream at a time; other threads trying to parse same or
    1311  * different streams using different XmlTreeBackend and Input instances
    1312  * will have to wait.
    1313  *
    1314  * Keep in mind that the above reentrancy fix does not imply thread-safety: it
    1315  * is still the caller's responsibility to provide serialization if the same
    1316  * XmlTreeBackend instnace (as well as instances of other classes from the
    1317  * settings namespace) needs to be used by more than one thread.
    13181284 */
    13191285class VBOXSETTINGS_CLASS XmlTreeBackend : public TreeBackend
  • trunk/src/VBox/Main/MachineImpl.cpp

    r8024 r8029  
    20322032
    20332033        /* load the config file */
    2034 #if 0
    2035         /// @todo disabled until made thread-safe by using handle duplicates
    20362034        File file (File::ReadWrite, mData->mHandleCfgFile,
    20372035                   Utf8Str (mData->mConfigFileFull));
    2038 #else
    2039         File file (File::Read, Utf8Str (mData->mConfigFileFull));
    2040 #endif
    20412036        XmlTreeBackend tree;
    20422037
     
    21392134
    21402135        /* load the config file */
    2141 #if 0
    2142         /// @todo disabled until made thread-safe by using handle duplicates
    21432136        File file (File::ReadWrite, mData->mHandleCfgFile,
    21442137                   Utf8Str (mData->mConfigFileFull));
    2145 #else
    2146         File file (File::Read, Utf8Str (mData->mConfigFileFull));
    2147 #endif
    21482138        XmlTreeBackend tree;
    21492139
     
    22172207
    22182208        /* load the config file */
    2219 #if 0
    2220         /// @todo disabled until made thread-safe by using handle duplicates
    22212209        File file (File::ReadWrite, mData->mHandleCfgFile,
    22222210                   Utf8Str (mData->mConfigFileFull));
    2223 #else
    2224         File file (File::ReadWrite, Utf8Str (mData->mConfigFileFull));
    2225 #endif
    22262211        XmlTreeBackend tree;
    22272212
     
    40204005        using namespace settings;
    40214006
    4022 #if 0
    4023         /// @todo disabled until made thread-safe by using handle duplicates
    40244007        File file (File::Read, mData->mHandleCfgFile,
    40254008                   Utf8Str (mData->mConfigFileFull));
    4026 #else
    4027         File file (File::Read, Utf8Str (mData->mConfigFileFull));
    4028 #endif
    40294009        XmlTreeBackend tree;
    40304010
     
    51615141        using namespace settings;
    51625142
    5163 #if 0
    5164         /// @todo disabled until made thread-safe by using handle duplicates
    51655143        File file (File::ReadWrite, mData->mHandleCfgFile,
    51665144                   Utf8Str (mData->mConfigFileFull));
    5167 #else
    5168         File file (File::ReadWrite, Utf8Str (mData->mConfigFileFull));
    5169 #endif
    51705145        XmlTreeBackend tree;
    51715146
     
    53735348
    53745349        /* load the config file */
    5375 #if 0
    5376         /// @todo disabled until made thread-safe by using handle duplicates
    53775350        File file (File::ReadWrite, mData->mHandleCfgFile,
    53785351                   Utf8Str (mData->mConfigFileFull));
    5379 #else
    5380         File file (File::ReadWrite, Utf8Str (mData->mConfigFileFull));
    5381 #endif
    53825352        XmlTreeBackend tree;
    53835353
     
    59555925
    59565926        /* load the config file */
    5957 #if 0
    5958         /// @todo disabled until made thread-safe by using handle duplicates
    59595927        File file (File::ReadWrite, mData->mHandleCfgFile,
    59605928                   Utf8Str (mData->mConfigFileFull));
    5961 #else
    5962         File file (File::ReadWrite, Utf8Str (mData->mConfigFileFull));
    5963 #endif
    59645929        XmlTreeBackend tree;
    59655930
  • trunk/src/VBox/Main/VirtualBoxImpl.cpp

    r8020 r8029  
    206206            using namespace settings;
    207207
    208 #if 0
    209             /// @todo disabled until made thread-safe by using handle duplicates
    210208            File file (File::ReadWrite, mData.mCfgFile.mHandle, vboxConfigFile);
    211 #else
    212             File file (File::Read, vboxConfigFile);
    213 #endif
    214209            XmlTreeBackend tree;
    215210
     
    17141709
    17151710        /* load the config file */
    1716 #if 0
    1717         /// @todo disabled until made thread-safe by using handle duplicates
    17181711        File file (File::ReadWrite, mData.mCfgFile.mHandle,
    17191712                   Utf8Str (mData.mCfgFile.mName));
    1720 #else
    1721         File file (File::Read, Utf8Str (mData.mCfgFile.mName));
    1722 #endif
    17231713        XmlTreeBackend tree;
    17241714
     
    18171807
    18181808        /* load the config file */
    1819 #if 0
    1820         /// @todo disabled until made thread-safe by using handle duplicates
    18211809        File file (File::ReadWrite, mData.mCfgFile.mHandle,
    18221810                   Utf8Str (mData.mCfgFile.mName));
    1823 #else
    1824         File file (File::Read, Utf8Str (mData.mCfgFile.mName));
    1825 #endif
    18261811        XmlTreeBackend tree;
    18271812
     
    18821867
    18831868        /* load the config file */
    1884 #if 0
    1885         /// @todo disabled until made thread-safe by using handle duplicates
    18861869        File file (File::ReadWrite, mData.mCfgFile.mHandle,
    18871870                   Utf8Str (mData.mCfgFile.mName));
    1888 #else
    1889         File file (File::ReadWrite, Utf8Str (mData.mCfgFile.mName));
    1890 #endif
    18911871        XmlTreeBackend tree;
    18921872
     
    37413721        using namespace settings;
    37423722
    3743 #if 0
    3744         /// @todo disabled until made thread-safe by using handle duplicates
    37453723        File file (File::ReadWrite, mData.mCfgFile.mHandle,
    37463724                   Utf8Str (mData.mCfgFile.mName));
    3747 #else
    3748         File file (File::ReadWrite, Utf8Str (mData.mCfgFile.mName));
    3749 #endif
    37503725        XmlTreeBackend tree;
    37513726
  • trunk/src/VBox/Main/xml/Settings.cpp

    r8020 r8029  
    2121#include <iprt/err.h>
    2222#include <iprt/file.h>
    23 #include <iprt/lock.h>
    2423
    2524#include <libxml/tree.h>
     
    7574    {
    7675        xmlExternalEntityLoader defaultEntityLoader;
    77 
    78         /** Used to provide some thread safety missing in libxml2 (see e.g.
    79          *  XmlTreeBackend::read()) */
    80         RTLockMtx lock;
    8176    }
    8277    xml;
     
    387382}
    388383
    389 #if 0
    390 /// @todo disabled until made thread-safe by using handle duplicates
    391 File::File (Mode aMode, RTFILE aHandle, const char *aFileName)
     384File::File (Mode aMode, RTFILE aHandle, const char *aFileName /* = NULL */ )
    392385    : m (new Data())
    393386{
     
    407400    setPos (0);
    408401}
    409 #endif
    410402
    411403File::~File()
     
    911903    m->trappedErr.reset();
    912904
    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 
     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).*/
    921912    xmlExternalEntityLoader oldEntityLoader = xmlGetExternalEntityLoader();
    922913    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