[SERVER-23545] Get rid of ON_BLOCK_EXIT in storage layer Created: 05/Apr/16  Updated: 06/Dec/22  Resolved: 11/Apr/16

Status: Closed
Project: Core Server
Component/s: Internal Code, Storage
Affects Version/s: 3.3.4
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Kyle Suarez Assignee: Backlog - Storage Execution Team
Resolution: Won't Fix Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Storage Execution
Backwards Compatibility: Fully Compatible
Participants:

 Description   

It would be nice to get rid of the ON_BLOCK_EXIT macro in favor of using RAII builtins provided by the C++ standard library (up through C++14).

Starter list:

/mongo/src/mongo/db/storage $ git grep ON_BLOCK_EXIT
mmap_v1/repair_database.cpp:        ON_BLOCK_EXIT(&dur::DurableInterface::syncDataAndTruncateJournal, &getDur(), txn);
wiredtiger/wiredtiger_kv_engine.cpp:    ON_BLOCK_EXIT(c->close, c);
wiredtiger/wiredtiger_session_cache.cpp:    ON_BLOCK_EXIT([this] { _shuttingDown.fetchAndSubtract(1); });
wiredtiger/wiredtiger_session_cache.cpp:    ON_BLOCK_EXIT([this] { _shuttingDown.fetchAndSubtract(1); });
wiredtiger/wiredtiger_size_storer.cpp:        ON_BLOCK_EXIT(_cursor->reset, _cursor);
wiredtiger/wiredtiger_util.cpp:    ON_BLOCK_EXIT(cursor->close, cursor);
wiredtiger/wiredtiger_util.cpp:    ON_BLOCK_EXIT(session->close, session, "");
wiredtiger/wiredtiger_util.cpp:    ON_BLOCK_EXIT(c->close, c);



 Comments   
Comment by Andrew Morrow (Inactive) [ 05/Apr/16 ]

For that matter, what are you suggesting we replace it with, exactly. I agree that the ON_BLOCK_EXIT macro is no longer needed, but MakeGuard is still nice:

const auto doCleanup = MakeGuard([]{ ... });

Comment by Eric Milkie [ 05/Apr/16 ]

Why just the storage layer?

Generated at Thu Feb 08 04:03:42 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.