Skip to content

Commit

Permalink
Merge pull request #49 from Toilal/access-denied-file-handle
Browse files Browse the repository at this point in the history
Fix unstable WRITE when first write fails to open file
  • Loading branch information
marcharding authored Aug 30, 2017
2 parents faeee60 + 5fd18b5 commit 26223f9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/NFS3Prog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -731,16 +731,22 @@ nfsstat3 CNFS3Prog::ProcedureWRITE(void)

file_wcc.before.attributes_follow = GetFileAttributesForNFS(path, &file_wcc.before.attributes);

if (stat == NFS3_OK) {
if (stat == NFS3_OK) {

if (stable == UNSTABLE) {
nfs_fh3 handle;
GetFileHandle(path, &handle);
int handleId = *(unsigned int *)handle.contents;

if (unstableStorageFile.count(handleId) == 0){
unstableStorageFile.insert(std::make_pair(handleId, _fsopen(path, "r+b", _SH_DENYWR)));
pFile = _fsopen(path, "r+b", _SH_DENYWR);
if (pFile != NULL) {
unstableStorageFile.insert(std::make_pair(handleId, pFile));
}
} else {
pFile = unstableStorageFile[handleId];
}
pFile = unstableStorageFile[handleId];

if (pFile != NULL) {
_fseeki64(pFile, offset, SEEK_SET);
count = fwrite(data.contents, sizeof(char), data.length, pFile);
Expand Down

0 comments on commit 26223f9

Please sign in to comment.