| 155 | } |
| 156 | |
| 157 | void BufferPool::DestroyPage(ClientHandle* client, PageHandle* handle) { |
| 158 | if (!handle->is_open()) return; // DestroyPage() should be idempotent. |
| 159 | |
| 160 | if (handle->is_pinned()) { |
| 161 | // Cancel the read I/O - we don't need the data any more. |
| 162 | if (handle->page_->pin_in_flight.Load()) { |
| 163 | handle->page_->write_handle->CancelRead(); |
| 164 | handle->page_->pin_in_flight.Store(false); |
| 165 | } |
| 166 | // In the pinned case, delegate to ExtractBuffer() and FreeBuffer() to do the work |
| 167 | // of cleaning up the page, freeing the buffer and updating reservations correctly. |
| 168 | BufferHandle buffer; |
| 169 | Status status = ExtractBuffer(client, handle, &buffer); |
| 170 | DCHECK(status.ok()) << status.msg().msg(); |
| 171 | FreeBuffer(client, &buffer); |
| 172 | } else { |
| 173 | // In the unpinned case, no reservations are used so we just clean up the page. |
| 174 | client->impl_->DestroyPageInternal(handle); |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | Status BufferPool::Pin(ClientHandle* client, PageHandle* handle) { |
| 179 | DCHECK(client->is_registered()); |