Skip to content

Commit

Permalink
take throw out of critical section (was dead-locked)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethatron committed Dec 1, 2011
1 parent 1cdebc2 commit 8662171
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
19 changes: 11 additions & 8 deletions bsaopt-bsa.C
Expand Up @@ -1647,23 +1647,26 @@ public:
compressedoubytes += file->ous;
}

char *fail = NULL;
if (file->ous > (~OB_BSAFILE_FLAG_ALLFLAGS))
throw runtime_error("The file-record exceeds 1GiB!");

fail = "The file-record exceeds 1GiB!";
/* the order of the files in our temporary blob is irrelevant
* no need to make it ordered, just prevent overlapping writes
*/
ioblock(); {
else { ioblock(); {
file->oinfo.sizeFlags = file->ous;
file->oinfo.offset = ftell(obsa);
if (file->oinfo.offset > 0x7FFFFFFF)
throw runtime_error("The temporary file exceeds 2GiB!");

/* check sanity */
if (file->oinfo.offset > 0x7FFFFFFF)
fail = "The temporary file exceeds 2GiB!";
/* write to temporary file */
if ((ret = fwrite(file->oup, 1, file->ous, obsa)) != file->ous)
throw runtime_error("Writing BSA failed!");
}; iorelease();
else if ((ret = fwrite(file->oup, 1, file->ous, obsa)) != file->ous)
fail = "Writing BSA failed!";
}; iorelease(); }

if (fail)
throw runtime_error(fail);
if (zlb)
file->oinfo.sizeFlags |= OB_BSAFILE_FLAG_COMPRESS;

Expand Down
4 changes: 2 additions & 2 deletions bsaopt.C
Expand Up @@ -1223,8 +1223,8 @@ public:

/* ioopen/fopen is synchronous, only close is
* asynchronous, which means even non-yet-written
* files exist in the folder and we don't nee to wait for
* completition to check if a folder is empty/non-empty
* files exist in the folder and we don't need to wait for
* completion to check if a folder is empty/non-empty
*
* no lock/synchronization necessary
*/
Expand Down

0 comments on commit 8662171

Please sign in to comment.