-
Notifications
You must be signed in to change notification settings - Fork 511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace MEM_DREAD_CTRL pool with MEMPROXY class pool #1924
base: master
Are you sure you want to change the base?
Conversation
... to a MEMPROXY class pool. Replacing memory allocate and destruct with C++ new/delete and in-class initialization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I adjusted PR title/description to match recent commit ed1a732.
Before advancing this new PR (including fixing build tests) and requesting my re-review, please cooperate to merge PRs awaiting your review for a long time, including these three:
- Upgrade generated parse_line() to accept constant SBuf #1840 opened Jun 11, 2024: "Upgrade generated parse_line() to accept constant SBuf"
- Bug 5363: Handle IP-based X.509 SANs better #1793 opened Apr 25, 2024: "Bug 5363: Handle IP-based X.509 SANs better"
- Bug 5383: handleNegotiationResult() level-2 debugs() crash #1856 opened Jun 30, 2024: "Bug 5383: handleNegotiationResult() level-2 debugs() crash"
DRCB *handler = {}; | ||
void *client_data = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default, please use nullptr to initialize raw pointers.
DRCB *handler = {}; | |
void *client_data = {}; | |
DRCB *handler = nullptr; | |
void *client_data = nullptr; |
Alternatively, do not initialize data members that are supposed to be set by the class constructor. This approach allows the compiler to warn us if we forget to copy constructor parameter to a class data member.
ctrl_dat->end_of_file = 0; | ||
ctrl_dat->handler = handler; | ||
ctrl_dat->client_data = cbdataReference(client_data); | ||
const auto ctrl_dat = new dread_ctrl(fd, offset, req_len, buf, handler, cbdataReference(client_data)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend moving cbdataReference() call inside dread_ctrl constructor and placing the matching cbdataReferenceDone() call inside its destructor. Doing so will lower several red flags:
- Official diskHandleRead() code sometimes does not call cbdataReferenceDone() when deleting ctrl_dat object.
- PR code prohibits dread_ctrl object moving or copying, but there is no obvious reason to do that (now) because the class effectively remains a POD.
I do not insist on this change despite recommending it.
Replacing memory allocate and destruct with C++ new/delete
and in-class initialization.