diff options
Diffstat (limited to 'src/VBox/Main/src-server/VirtualBoxImpl.cpp')
-rw-r--r-- | src/VBox/Main/src-server/VirtualBoxImpl.cpp | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/src/VBox/Main/src-server/VirtualBoxImpl.cpp b/src/VBox/Main/src-server/VirtualBoxImpl.cpp index 6af42a0e5..43207ef5f 100644 --- a/src/VBox/Main/src-server/VirtualBoxImpl.cpp +++ b/src/VBox/Main/src-server/VirtualBoxImpl.cpp @@ -1,4 +1,4 @@ -/* $Id: VirtualBoxImpl.cpp 38211 2011-07-28 09:26:31Z vboxsync $ */ +/* $Id: VirtualBoxImpl.cpp $ */ /** @file * Implementation of IVirtualBox in VBoxSVC. @@ -3931,30 +3931,38 @@ HRESULT VirtualBox::saveRegistries(const GuidList &llRegistriesThatNeedSaving) } /** - * Creates the path to the specified file according to the path information - * present in the file name. + * Checks if the path to the specified file exists, according to the path + * information present in the file name. Optionally the path is created. * * Note that the given file name must contain the full path otherwise the * extracted relative path will be created based on the current working * directory which is normally unknown. * - * @param aFileName Full file name which path needs to be created. + * @param aFileName Full file name which path is checked/created. + * @param aCreate Flag if the path should be created if it doesn't exist. * - * @return Extended error information on failure to create the path. + * @return Extended error information on failure to check/create the path. */ /* static */ -HRESULT VirtualBox::ensureFilePathExists(const Utf8Str &strFileName) +HRESULT VirtualBox::ensureFilePathExists(const Utf8Str &strFileName, bool fCreate) { Utf8Str strDir(strFileName); strDir.stripFilename(); if (!RTDirExists(strDir.c_str())) { - int vrc = RTDirCreateFullPath(strDir.c_str(), 0777); - if (RT_FAILURE(vrc)) - return setErrorStatic(E_FAIL, - Utf8StrFmt(tr("Could not create the directory '%s' (%Rrc)"), - strDir.c_str(), - vrc)); + if (fCreate) + { + int vrc = RTDirCreateFullPath(strDir.c_str(), 0777); + if (RT_FAILURE(vrc)) + return setErrorStatic(VBOX_E_IPRT_ERROR, + Utf8StrFmt(tr("Could not create the directory '%s' (%Rrc)"), + strDir.c_str(), + vrc)); + } + else + return setErrorStatic(VBOX_E_IPRT_ERROR, + Utf8StrFmt(tr("Directory '%s' does not exist"), + strDir.c_str())); } return S_OK; @@ -4538,7 +4546,13 @@ DECLCALLBACK(int) VirtualBox::AsyncEventHandler(RTTHREAD thread, void *pvUser) // signal that we're ready RTThreadUserSignal(thread); - while (RT_SUCCESS(eventQ->processEventQueue(RT_INDEFINITE_WAIT))) + /* + * In case of spurious wakeups causing VERR_TIMEOUTs and/or other return codes + * we must not stop processing events and delete the "eventQ" object. This must + * be done ONLY when we stop this loop via interruptEventQueueProcessing(). + * See #5724. + */ + while (eventQ->processEventQueue(RT_INDEFINITE_WAIT) != VERR_INTERRUPTED) /* nothing */ ; delete eventQ; |