void Inode::Close(int openMode, file_cookie* cookie) { TRACE("Inode %p::Close(openMode = %d)\n", this, openMode); MutexLocker locker(RequestLock()); // Notify all currently reading file descriptors ReadRequestList::Iterator iterator = fReadRequests.GetIterator(); while (ReadRequest* request = iterator.Next()) { if (request->Cookie() == cookie) request->Notify(B_FILE_ERROR); } if ((openMode & O_ACCMODE) == O_WRONLY && --fWriterCount == 0) NotifyEndClosed(true); if ((openMode & O_ACCMODE) == O_RDONLY || (openMode & O_ACCMODE) == O_RDWR) { if (--fReaderCount == 0) NotifyEndClosed(false); } if (fWriterCount == 0) { // Notify any still reading writers to stop // TODO: This only works reliable if there is only one writer - we could // do the same thing done for the read requests. fWriteCondition.NotifyAll(B_FILE_ERROR); } if (fReaderCount == 0 && fWriterCount == 0) { fActive = false; fBuffer.DeleteBuffer(); } }