Commit effa06ec authored by John Esmet's avatar John Esmet

Clean up toku_ft_handle_close

parent 5a18a1b0
...@@ -3250,34 +3250,31 @@ ft_remove_handle_ref_callback(FT UU(ft), void *extra) { ...@@ -3250,34 +3250,31 @@ ft_remove_handle_ref_callback(FT UU(ft), void *extra) {
toku_list_remove(&handle->live_ft_handle_link); toku_list_remove(&handle->live_ft_handle_link);
} }
// close an ft handle during normal operation. the underlying ft may or may not close, static void ft_handle_close(FT_HANDLE ft_handle, bool oplsn_valid, LSN oplsn) {
// depending if there are still references. an lsn for this close will come from the logger.
void
toku_ft_handle_close(FT_HANDLE ft_handle) {
// There are error paths in the ft_handle_open that end with ft_handle->ft==NULL.
FT ft = ft_handle->ft; FT ft = ft_handle->ft;
if (ft) { // There are error paths in the ft_handle_open that end with ft_handle->ft == nullptr.
const bool oplsn_valid = false; if (ft != nullptr) {
toku_ft_remove_reference(ft, oplsn_valid, ZERO_LSN, ft_remove_handle_ref_callback, ft_handle); toku_ft_remove_reference(ft, oplsn_valid, oplsn, ft_remove_handle_ref_callback, ft_handle);
} }
toku_free(ft_handle); toku_free(ft_handle);
} }
// close an ft handle during normal operation. the underlying ft may or may not close,
// depending if there are still references. an lsn for this close will come from the logger.
void toku_ft_handle_close(FT_HANDLE ft_handle) {
ft_handle_close(ft_handle, false, ZERO_LSN);
}
// close an ft handle during recovery. the underlying ft must close, and will use the given lsn. // close an ft handle during recovery. the underlying ft must close, and will use the given lsn.
void void toku_ft_handle_close_recovery(FT_HANDLE ft_handle, LSN oplsn) {
toku_ft_handle_close_recovery(FT_HANDLE ft_handle, LSN oplsn) {
FT ft = ft_handle->ft;
// the ft must exist if closing during recovery. error paths during // the ft must exist if closing during recovery. error paths during
// open for recovery should close handles using toku_ft_handle_close() // open for recovery should close handles using toku_ft_handle_close()
assert(ft); invariant_notnull(ft_handle->ft);
const bool oplsn_valid = true; ft_handle_close(ft_handle, true, oplsn);
toku_ft_remove_reference(ft, oplsn_valid, oplsn, ft_remove_handle_ref_callback, ft_handle);
toku_free(ft_handle);
} }
// TODO: remove this, callers should instead just use toku_ft_handle_close() // TODO: remove this, callers should instead just use toku_ft_handle_close()
int int toku_close_ft_handle_nolsn(FT_HANDLE ft_handle, char **UU(error_string)) {
toku_close_ft_handle_nolsn (FT_HANDLE ft_handle, char** UU(error_string)) {
toku_ft_handle_close(ft_handle); toku_ft_handle_close(ft_handle);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment