Bug 760027 - Attempt to retry moving the installation directory when performing the replace stage of an update 10 times; r=strong

This will hopefully give the applications which might have a handle to some
file in that directory open a chance to close them up so that the replace
operation would finish successfully.
This commit is contained in:
Ehsan Akhgari 2012-05-31 15:40:07 -04:00
parent 741f3aa5e4
commit d98ade3af7

View File

@ -1815,6 +1815,23 @@ ProcessReplaceRequest()
LOG(("Begin moving sourceDir (" LOG_S ") to tmpDir (" LOG_S ")\n",
sourceDir, tmpDir));
int rv = rename_file(sourceDir, tmpDir, true);
#ifdef XP_WIN
// On Windows, if Firefox is launched using the shortcut, it will hold a handle
// to its installation directory open, which might not get released in time.
// Therefore we wait a little bit here to see if the handle is released.
// If it's not released, we just fail to perform the replace request.
const int max_retries = 10;
int retries = 0;
while (rv == WRITE_ERROR && (retries++ < max_retries)) {
LOG(("PerformReplaceRequest: sourceDir rename attempt %d failed. " \
"File: " LOG_S ". Last error: %d, err: %d\n", retries,
sourceDir, GetLastError(), rv));
Sleep(100);
rv = rename_file(sourceDir, tmpDir, true);
}
#endif
if (rv) {
LOG(("Moving sourceDir to tmpDir failed, err: %d\n", rv));
return rv;