mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 14:35:26 +00:00
Replace usage of isc_mem_put+isc_mem_detach with isc_mem_putanddetach
Using isc_mem_put(mctx, ...) + isc_mem_detach(mctx) required juggling with the local variables when mctx was part of the freed object. The isc_mem_putanddetach function can handle this case internally, but it wasn't used everywhere. This commit apply the semantic patching plus bit of manual work to replace all such occurrences with proper usage of isc_mem_putanddetach().
This commit is contained in:
@@ -2537,8 +2537,6 @@ isc_socketmgr_setstats(isc_socketmgr_t *manager, isc_stats_t *stats) {
|
||||
void
|
||||
isc_socketmgr_destroy(isc_socketmgr_t **managerp) {
|
||||
isc_socketmgr_t *manager;
|
||||
int i;
|
||||
isc_mem_t *mctx;
|
||||
|
||||
/*
|
||||
* Destroy a socket manager.
|
||||
@@ -2570,7 +2568,7 @@ isc_socketmgr_destroy(isc_socketmgr_t **managerp) {
|
||||
/*
|
||||
* Wait for threads to exit.
|
||||
*/
|
||||
for (i = 0; i < manager->maxIOCPThreads; i++) {
|
||||
for (int i = 0; i < manager->maxIOCPThreads; i++) {
|
||||
if (isc_thread_join((isc_thread_t) manager->hIOCPThreads[i],
|
||||
NULL) != ISC_R_SUCCESS)
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
@@ -2585,13 +2583,11 @@ isc_socketmgr_destroy(isc_socketmgr_t **managerp) {
|
||||
(void)isc_condition_destroy(&manager->shutdown_ok);
|
||||
|
||||
isc_mutex_destroy(&manager->lock);
|
||||
if (manager->stats != NULL)
|
||||
if (manager->stats != NULL) {
|
||||
isc_stats_detach(&manager->stats);
|
||||
}
|
||||
manager->magic = 0;
|
||||
mctx= manager->mctx;
|
||||
isc_mem_put(mctx, manager, sizeof(*manager));
|
||||
|
||||
isc_mem_detach(&mctx);
|
||||
isc_mem_putanddetach(&manager->mctx, manager, sizeof(*manager));
|
||||
|
||||
*managerp = NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user