Close the underlying file so it cannot be read or written to anymore.
| 210 | |
| 211 | // Close the underlying file so it cannot be read or written to anymore. |
| 212 | void Close() { |
| 213 | // Explicitly hold the lock in write mode to block all readers. This ensures that |
| 214 | // setting 'file_' to NULL and 'allow_append_' to false below is atomic. |
| 215 | std::unique_lock<percpu_rwlock> lock(lock_); |
| 216 | // If the file is already closed, nothing to do. |
| 217 | if (!file_) return; |
| 218 | kudu::Status status = file_->Close(); |
| 219 | if (!status.ok()) { |
| 220 | LOG(WARNING) << Substitute("Failed to close cache file $0: $1", path_, |
| 221 | status.ToString()); |
| 222 | } |
| 223 | file_.reset(); |
| 224 | allow_append_ = false; |
| 225 | } |
| 226 | |
| 227 | // Close the underlying file and delete it from the filesystem. |
| 228 | void DeleteFile() { |
no test coverage detected