lib/nfs/FileReader: postpone the nfs_close_async() call
If an async opertion is in progress, nfs_close_async() will make libnfs crash because the RPC callback will dereference an object that was freed by nfs_close_async().
This commit is contained in:
@@ -57,11 +57,18 @@ NfsFileReader::Close()
|
||||
|
||||
connection->RemoveLease(*this);
|
||||
|
||||
if (state > State::MOUNT && state != State::IDLE)
|
||||
connection->Cancel(*this);
|
||||
|
||||
if (state > State::OPEN)
|
||||
if (state == State::IDLE)
|
||||
/* no async operation in progress: can close
|
||||
immediately */
|
||||
connection->Close(fh);
|
||||
else if (state > State::OPEN)
|
||||
/* one async operation in progress: cancel it and
|
||||
defer the nfs_close_async() call */
|
||||
connection->CancelAndClose(fh, *this);
|
||||
else if (state > State::MOUNT)
|
||||
/* we don't have a file handle yet - just cancel the
|
||||
async operation */
|
||||
connection->Cancel(*this);
|
||||
|
||||
state = State::INITIAL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user