From 21b905c2aa607b8155cf998328d99e8e4ad68ac7 Mon Sep 17 00:00:00 2001 From: alexzzh Date: Thu, 17 Oct 2024 16:09:48 +0800 Subject: [PATCH 1/4] fix memory leak on master process --- ngx_health_detect_common.h | 1 + ngx_http_health_detect_module.c | 34 +++++++++++++------ ngx_http_health_detect_module.h | 2 +- .../nginx_healthdetect_for_nginx_1.12+.patch | 4 +-- .../nginx_healthdetect_for_nginx_1.16+.patch | 4 +-- .../nginx_healthdetect_for_nginx_1.18+.patch | 4 +-- .../nginx_healthdetect_for_nginx_1.24+.patch | 4 +-- .../nginx_healthdetect_for_nginx_1.26+.patch | 4 +-- 8 files changed, 35 insertions(+), 22 deletions(-) diff --git a/ngx_health_detect_common.h b/ngx_health_detect_common.h index 74e8514..aaef691 100644 --- a/ngx_health_detect_common.h +++ b/ngx_health_detect_common.h @@ -119,6 +119,7 @@ typedef struct { ngx_peer_connection_t pc; ngx_health_detect_detect_policy_t *policy; ngx_pool_t *temp_pool; + ngx_uint_t using_cf_pool; ngx_health_detect_default_detect_policy_t *default_policy; void *check_data; diff --git a/ngx_http_health_detect_module.c b/ngx_http_health_detect_module.c index 71a7850..974f836 100644 --- a/ngx_http_health_detect_module.c +++ b/ngx_http_health_detect_module.c @@ -1310,7 +1310,7 @@ ngx_http_health_detect_add_or_update_node_on_shm( static ngx_int_t ngx_http_health_detect_add_or_update_node_on_local( - ngx_health_detect_detect_policy_t *policy, ngx_uint_t start_detect_timer) + ngx_pool_t *pool, ngx_health_detect_detect_policy_t *policy, ngx_uint_t start_detect_timer) { uint32_t hash; ngx_health_detect_peer_t *opeer; @@ -1352,13 +1352,17 @@ ngx_http_health_detect_add_or_update_node_on_local( 1 /*type*/ + PEER_NAME_LEN_MAX_VALUE /*peer_name*/ + MAX_SEND_CONTENT_LEN_MAX_VALUE /*send_content*/ + sizeof("syslog") - 1 /*alert method*/; - - temp_pool = ngx_create_pool( + + if(pool == NULL){ + temp_pool = ngx_create_pool( ngx_align(peer_size + peer_policy_max_size, ngx_cacheline_size), ngx_cycle->log); - if (temp_pool == NULL) { - ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, 0, + if (temp_pool == NULL) { + ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, 0, "on local: op(add/update) create pool error"); + } + } else { + temp_pool = pool; } node = ngx_pcalloc(temp_pool, peer_size); @@ -1373,6 +1377,12 @@ ngx_http_health_detect_add_or_update_node_on_local( peer = (ngx_health_detect_peer_t *) &node->color; peer->temp_pool = temp_pool; + if(pool == NULL){ + peer->using_cf_pool = 0; + } else { + peer->using_cf_pool = 1; + } + peer->default_policy = ngx_http_health_detect_get_default_detect_policy(policy->data.type); @@ -1450,7 +1460,7 @@ ngx_http_health_detect_add_or_update_node_on_local( ngx_int_t ngx_http_health_detect_add_or_update_node( - ngx_health_detect_detect_policy_t *policy) + ngx_pool_t *pool,ngx_health_detect_detect_policy_t *policy) { ngx_int_t rc; @@ -1459,7 +1469,7 @@ ngx_http_health_detect_add_or_update_node( return rc; } - return ngx_http_health_detect_add_or_update_node_on_local(policy, 1); + return ngx_http_health_detect_add_or_update_node_on_local(pool,policy, 1); } static void @@ -1477,7 +1487,9 @@ ngx_http_health_detect_free_node(ngx_rbtree_node_t *node) ngx_rbtree_delete(&peers_manager_ctx->peers->rbtree, node); - if (peer->temp_pool != NULL) { + if (peer->temp_pool != NULL && !peer->using_cf_pool) { + ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, 0, + "free pool"); ngx_destroy_pool(peer->temp_pool); } } @@ -2086,7 +2098,7 @@ ngx_http_health_detect_construct_policy(ngx_pool_t *temp_pool, ngx_uint_t ngx_http_health_detect_upstream_add_peer( - ngx_http_upstream_srv_conf_t *us, ngx_str_t *server, ngx_addr_t *peer_addr) + ngx_pool_t *pool, ngx_http_upstream_srv_conf_t *us, ngx_str_t *server, ngx_addr_t *peer_addr) { ngx_int_t rc; ngx_pool_t *temp_pool; @@ -2117,9 +2129,9 @@ ngx_http_health_detect_upstream_add_peer( } if (ngx_process == NGX_PROCESS_WORKER) { - rc = ngx_http_health_detect_add_or_update_node(policy); + rc = ngx_http_health_detect_add_or_update_node(NULL, policy); } else { - rc = ngx_http_health_detect_add_or_update_node_on_local(policy, 0); + rc = ngx_http_health_detect_add_or_update_node_on_local(pool,policy, 0); } if (rc == NGX_OK) { diff --git a/ngx_http_health_detect_module.h b/ngx_http_health_detect_module.h index e6ac7d4..0028186 100644 --- a/ngx_http_health_detect_module.h +++ b/ngx_http_health_detect_module.h @@ -6,7 +6,7 @@ #include ngx_uint_t ngx_http_health_detect_upstream_add_peer( - ngx_http_upstream_srv_conf_t *us, ngx_str_t *server, ngx_addr_t *peer_addr); + ngx_pool_t *pool, ngx_http_upstream_srv_conf_t *us, ngx_str_t *server, ngx_addr_t *peer_addr); void ngx_http_health_detect_upstream_delete_peer( ngx_str_t *upstream_name, ngx_str_t *server_name, ngx_addr_t *peer_addr); diff --git a/patch/nginx_healthdetect_for_nginx_1.12+.patch b/patch/nginx_healthdetect_for_nginx_1.12+.patch index 429d44b..fd06875 100644 --- a/patch/nginx_healthdetect_for_nginx_1.12+.patch +++ b/patch/nginx_healthdetect_for_nginx_1.12+.patch @@ -125,7 +125,7 @@ index f6051ae5..e1bbae35 100644 +#if (NGX_HTTP_HEALTH_DETECT) + if (!server[i].down) { -+ ngx_http_health_detect_upstream_add_peer(us, &server[i].name, &server[i].addrs[j]); ++ ngx_http_health_detect_upstream_add_peer(cf->pool, us, &server[i].name, &server[i].addrs[j]); + } +#endif + @@ -138,7 +138,7 @@ index f6051ae5..e1bbae35 100644 +#if (NGX_HTTP_HEALTH_DETECT) + if (!server[i].down) { -+ ngx_http_health_detect_upstream_add_peer(us, &server[i].name, &server[i].addrs[j]); ++ ngx_http_health_detect_upstream_add_peer(cf->pool,us, &server[i].name, &server[i].addrs[j]); + } +#endif + diff --git a/patch/nginx_healthdetect_for_nginx_1.16+.patch b/patch/nginx_healthdetect_for_nginx_1.16+.patch index fbd8b20..90a3549 100644 --- a/patch/nginx_healthdetect_for_nginx_1.16+.patch +++ b/patch/nginx_healthdetect_for_nginx_1.16+.patch @@ -125,7 +125,7 @@ index f72de3ee..bce1740c 100644 +#if (NGX_HTTP_HEALTH_DETECT) + if (!server[i].down) { -+ ngx_http_health_detect_upstream_add_peer(us, &server[i].name, &server[i].addrs[j]); ++ ngx_http_health_detect_upstream_add_peer(cf->pool,us, &server[i].name, &server[i].addrs[j]); + } +#endif + @@ -138,7 +138,7 @@ index f72de3ee..bce1740c 100644 +#if (NGX_HTTP_HEALTH_DETECT) + if (!server[i].down) { -+ ngx_http_health_detect_upstream_add_peer(us, &server[i].name, &server[i].addrs[j]); ++ ngx_http_health_detect_upstream_add_peer(cf->pool,us, &server[i].name, &server[i].addrs[j]); + } +#endif + diff --git a/patch/nginx_healthdetect_for_nginx_1.18+.patch b/patch/nginx_healthdetect_for_nginx_1.18+.patch index f87f9b6..85a4bdc 100644 --- a/patch/nginx_healthdetect_for_nginx_1.18+.patch +++ b/patch/nginx_healthdetect_for_nginx_1.18+.patch @@ -125,7 +125,7 @@ index 8e7b4ea8..79c6f879 100644 +#if (NGX_HTTP_HEALTH_DETECT) + if (!server[i].down) { -+ ngx_http_health_detect_upstream_add_peer(us, &server[i].name, &server[i].addrs[j]); ++ ngx_http_health_detect_upstream_add_peer(cf->pool,us, &server[i].name, &server[i].addrs[j]); + } +#endif + @@ -138,7 +138,7 @@ index 8e7b4ea8..79c6f879 100644 +#if (NGX_HTTP_HEALTH_DETECT) + if (!server[i].down) { -+ ngx_http_health_detect_upstream_add_peer(us, &server[i].name, &server[i].addrs[j]); ++ ngx_http_health_detect_upstream_add_peer(cf->pool,us, &server[i].name, &server[i].addrs[j]); + } +#endif + diff --git a/patch/nginx_healthdetect_for_nginx_1.24+.patch b/patch/nginx_healthdetect_for_nginx_1.24+.patch index 7d999b8..40611bc 100644 --- a/patch/nginx_healthdetect_for_nginx_1.24+.patch +++ b/patch/nginx_healthdetect_for_nginx_1.24+.patch @@ -129,7 +129,7 @@ index 1f15fae5..de81d9f9 100644 +#if (NGX_HTTP_HEALTH_DETECT) + if (!server[i].down) { -+ ngx_http_health_detect_upstream_add_peer(us, &server[i].name, &server[i].addrs[j]); ++ ngx_http_health_detect_upstream_add_peer(cf->pool,us, &server[i].name, &server[i].addrs[j]); + } +#endif + @@ -142,7 +142,7 @@ index 1f15fae5..de81d9f9 100644 +#if (NGX_HTTP_HEALTH_DETECT) + if (!server[i].down) { -+ ngx_http_health_detect_upstream_add_peer(us, &server[i].name, &server[i].addrs[j]); ++ ngx_http_health_detect_upstream_add_peer(cf->pool,us, &server[i].name, &server[i].addrs[j]); + } +#endif + diff --git a/patch/nginx_healthdetect_for_nginx_1.26+.patch b/patch/nginx_healthdetect_for_nginx_1.26+.patch index 7363f1d..172ac87 100644 --- a/patch/nginx_healthdetect_for_nginx_1.26+.patch +++ b/patch/nginx_healthdetect_for_nginx_1.26+.patch @@ -125,7 +125,7 @@ index 1f15fae50..11d88d165 100644 +#if (NGX_HTTP_HEALTH_DETECT) + if (!server[i].down) { -+ ngx_http_health_detect_upstream_add_peer(us, &server[i].name, &server[i].addrs[j]); ++ ngx_http_health_detect_upstream_add_peer(cf->pool,us, &server[i].name, &server[i].addrs[j]); + } +#endif + @@ -138,7 +138,7 @@ index 1f15fae50..11d88d165 100644 +#if (NGX_HTTP_HEALTH_DETECT) + if (!server[i].down) { -+ ngx_http_health_detect_upstream_add_peer(us, &server[i].name, &server[i].addrs[j]); ++ ngx_http_health_detect_upstream_add_peer(cf->pool,us, &server[i].name, &server[i].addrs[j]); + } +#endif + From 479401b6131d3b30e34a1cd1932fc0b19b1f5a32 Mon Sep 17 00:00:00 2001 From: alexzzh Date: Thu, 17 Oct 2024 17:07:48 +0800 Subject: [PATCH 2/4] fix mem leack problem --- ngx_http_health_detect_module.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ngx_http_health_detect_module.c b/ngx_http_health_detect_module.c index 974f836..f063dcf 100644 --- a/ngx_http_health_detect_module.c +++ b/ngx_http_health_detect_module.c @@ -38,7 +38,7 @@ static ngx_rbtree_node_t *ngx_http_health_detect_peers_rbtree_lookup( ngx_rbtree_node_t *ngx_http_health_detect_peers_shm_rbtree_lookup( uint32_t hash, ngx_str_t *key); ngx_int_t ngx_http_health_detect_add_or_update_node( - ngx_health_detect_detect_policy_t *policy); + ngx_pool_t * pool,ngx_health_detect_detect_policy_t *policy); static ngx_int_t ngx_http_health_detect_add_or_update_node_on_shm( ngx_health_detect_detect_policy_t *policy); ngx_int_t ngx_http_health_detect_delete_node(ngx_str_t *key); @@ -2436,7 +2436,7 @@ ngx_http_health_detect_sync_peers_shm_to_peers() peer_name, ngx_pid); ngx_http_health_detect_add_or_update_node_on_local( - &peer_shm->policy, 1); + NULL, &peer_shm->policy, 1); } } } From 88fdf3921e7dae27a3f421c0393da03d48bbfa23 Mon Sep 17 00:00:00 2001 From: alexzzh Date: Thu, 17 Oct 2024 17:57:29 +0800 Subject: [PATCH 3/4] fix memory leak --- ngx_health_detect_api.c | 4 ++-- ngx_http_health_detect_module.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ngx_health_detect_api.c b/ngx_health_detect_api.c index 30b47bb..cd02afe 100644 --- a/ngx_health_detect_api.c +++ b/ngx_health_detect_api.c @@ -46,7 +46,7 @@ ngx_rbtree_node_t *ngx_http_health_detect_peers_shm_rbtree_lookup( ngx_health_detect_default_detect_policy_t * ngx_http_health_detect_get_default_detect_policy(ngx_uint_t type); ngx_int_t ngx_http_health_detect_add_or_update_node( - ngx_health_detect_detect_policy_t *policy); + ngx_pool_t * pool, ngx_health_detect_detect_policy_t *policy); ngx_int_t ngx_http_health_detect_delete_node(ngx_str_t *key); ngx_int_t ngx_http_health_detect_delete_all_node(); ngx_uint_t ngx_http_health_detect_get_down_count(); @@ -774,7 +774,7 @@ ngx_health_detect_add_or_update_node(ngx_http_request_t *r, void *data) apicf = ngx_http_get_module_loc_conf(r, ngx_health_detect_api_module); if (apicf->used_module & NGX_HEALTH_DETECT_API_ON_HTTP) { - rc = ngx_http_health_detect_add_or_update_node(policy); + rc = ngx_http_health_detect_add_or_update_node(NULL,policy); } else { rc = ngx_stream_health_detect_add_or_update_node(policy); } diff --git a/ngx_http_health_detect_module.c b/ngx_http_health_detect_module.c index f063dcf..7fac0a0 100644 --- a/ngx_http_health_detect_module.c +++ b/ngx_http_health_detect_module.c @@ -1362,7 +1362,7 @@ ngx_http_health_detect_add_or_update_node_on_local( "on local: op(add/update) create pool error"); } } else { - temp_pool = pool; + temp_pool = pool; } node = ngx_pcalloc(temp_pool, peer_size); From 5ff50251b2eaa48099336ed432e2531cf9e18df8 Mon Sep 17 00:00:00 2001 From: alexzzh Date: Thu, 17 Oct 2024 18:17:10 +0800 Subject: [PATCH 4/4] adjust stream module --- ngx_health_detect_api.c | 4 +-- ngx_http_health_detect_module.c | 2 -- ngx_stream_health_detect_module.c | 34 ++++++++++++------- ngx_stream_health_detect_module.h | 2 +- .../nginx_healthdetect_for_nginx_1.12+.patch | 4 +-- .../nginx_healthdetect_for_nginx_1.16+.patch | 4 +-- .../nginx_healthdetect_for_nginx_1.18+.patch | 4 +-- .../nginx_healthdetect_for_nginx_1.24+.patch | 4 +-- .../nginx_healthdetect_for_nginx_1.26+.patch | 4 +-- 9 files changed, 35 insertions(+), 27 deletions(-) diff --git a/ngx_health_detect_api.c b/ngx_health_detect_api.c index cd02afe..1881d1c 100644 --- a/ngx_health_detect_api.c +++ b/ngx_health_detect_api.c @@ -58,7 +58,7 @@ ngx_rbtree_node_t *ngx_stream_health_detect_peers_shm_rbtree_lookup( ngx_health_detect_default_detect_policy_t * ngx_stream_health_detect_get_default_detect_policy(ngx_uint_t type); ngx_int_t ngx_stream_health_detect_add_or_update_node( - ngx_health_detect_detect_policy_t *policy); + ngx_pool_t * pool, ngx_health_detect_detect_policy_t *policy); ngx_int_t ngx_stream_health_detect_delete_node(ngx_str_t *key); ngx_int_t ngx_stream_health_detect_delete_all_node(); ngx_uint_t ngx_stream_health_detect_get_down_count(); @@ -776,7 +776,7 @@ ngx_health_detect_add_or_update_node(ngx_http_request_t *r, void *data) if (apicf->used_module & NGX_HEALTH_DETECT_API_ON_HTTP) { rc = ngx_http_health_detect_add_or_update_node(NULL,policy); } else { - rc = ngx_stream_health_detect_add_or_update_node(policy); + rc = ngx_stream_health_detect_add_or_update_node(NULL,policy); } return rc; diff --git a/ngx_http_health_detect_module.c b/ngx_http_health_detect_module.c index 7fac0a0..05eb398 100644 --- a/ngx_http_health_detect_module.c +++ b/ngx_http_health_detect_module.c @@ -1488,8 +1488,6 @@ ngx_http_health_detect_free_node(ngx_rbtree_node_t *node) ngx_rbtree_delete(&peers_manager_ctx->peers->rbtree, node); if (peer->temp_pool != NULL && !peer->using_cf_pool) { - ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, 0, - "free pool"); ngx_destroy_pool(peer->temp_pool); } } diff --git a/ngx_stream_health_detect_module.c b/ngx_stream_health_detect_module.c index 26b96fc..f8e3ad5 100644 --- a/ngx_stream_health_detect_module.c +++ b/ngx_stream_health_detect_module.c @@ -39,7 +39,7 @@ static ngx_rbtree_node_t *ngx_stream_health_detect_peers_rbtree_lookup( ngx_rbtree_node_t *ngx_stream_health_detect_peers_shm_rbtree_lookup( uint32_t hash, ngx_str_t *key); ngx_int_t ngx_stream_health_detect_add_or_update_node( - ngx_health_detect_detect_policy_t *policy); + ngx_pool_t * pool, ngx_health_detect_detect_policy_t *policy); static ngx_int_t ngx_stream_health_detect_add_or_update_node_on_shm( ngx_health_detect_detect_policy_t *policy); ngx_int_t ngx_stream_health_detect_delete_node(ngx_str_t *key); @@ -1308,7 +1308,7 @@ ngx_stream_health_detect_add_or_update_node_on_shm( static ngx_int_t ngx_stream_health_detect_add_or_update_node_on_local( - ngx_health_detect_detect_policy_t *policy, ngx_uint_t start_detect_timer) + ngx_pool_t *pool, ngx_health_detect_detect_policy_t *policy, ngx_uint_t start_detect_timer) { uint32_t hash; ngx_health_detect_peer_t *opeer; @@ -1352,12 +1352,16 @@ ngx_stream_health_detect_add_or_update_node_on_local( MAX_SEND_CONTENT_LEN_MAX_VALUE /*send_content*/ + sizeof("syslog") - 1 /*alert method*/; - temp_pool = ngx_create_pool( + if(pool == NULL){ + temp_pool = ngx_create_pool( ngx_align(peer_size + peer_policy_max_size, ngx_cacheline_size), ngx_cycle->log); - if (temp_pool == NULL) { - ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, 0, + if (temp_pool == NULL) { + ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, 0, "on local: op(add/update) create pool error"); + } + } else { + temp_pool = pool; } node = ngx_pcalloc(temp_pool, peer_size); @@ -1372,6 +1376,12 @@ ngx_stream_health_detect_add_or_update_node_on_local( peer = (ngx_health_detect_peer_t *) &node->color; peer->temp_pool = temp_pool; + if(pool == NULL){ + peer->using_cf_pool = 0; + } else { + peer->using_cf_pool = 1; + } + peer->default_policy = ngx_stream_health_detect_get_default_detect_policy(policy->data.type); @@ -1449,7 +1459,7 @@ ngx_stream_health_detect_add_or_update_node_on_local( ngx_int_t ngx_stream_health_detect_add_or_update_node( - ngx_health_detect_detect_policy_t *policy) + ngx_pool_t *pool, ngx_health_detect_detect_policy_t *policy) { ngx_int_t rc; @@ -1458,7 +1468,7 @@ ngx_stream_health_detect_add_or_update_node( return rc; } - return ngx_stream_health_detect_add_or_update_node_on_local(policy, 1); + return ngx_stream_health_detect_add_or_update_node_on_local(pool, policy, 1); } static void @@ -1476,7 +1486,7 @@ ngx_stream_health_detect_free_node(ngx_rbtree_node_t *node) ngx_rbtree_delete(&peers_manager_ctx->peers->rbtree, node); - if (peer->temp_pool != NULL) { + if (peer->temp_pool != NULL && !peer->using_cf_pool) { ngx_destroy_pool(peer->temp_pool); } } @@ -2096,7 +2106,7 @@ ngx_stream_health_detect_construct_policy(ngx_pool_t *temp_pool, ngx_uint_t ngx_stream_health_detect_upstream_add_peer(ngx_stream_upstream_srv_conf_t *us, - ngx_str_t *server, ngx_addr_t *peer_addr) + ngx_pool_t *pool, ngx_str_t *server, ngx_addr_t *peer_addr) { ngx_int_t rc; ngx_pool_t *temp_pool; @@ -2128,9 +2138,9 @@ ngx_stream_health_detect_upstream_add_peer(ngx_stream_upstream_srv_conf_t *us, } if (ngx_process == NGX_PROCESS_WORKER) { - rc = ngx_stream_health_detect_add_or_update_node(policy); + rc = ngx_stream_health_detect_add_or_update_node(NULL, policy); } else { - rc = ngx_stream_health_detect_add_or_update_node_on_local(policy, 0); + rc = ngx_stream_health_detect_add_or_update_node_on_local(NULL, policy, 0); } if (rc == NGX_OK) { @@ -2441,7 +2451,7 @@ ngx_stream_health_detect_sync_peers_shm_to_peers() "process(%P)", peer_name, ngx_pid); ngx_stream_health_detect_add_or_update_node_on_local( - &peer_shm->policy, 1); + NULL, &peer_shm->policy, 1); } } } diff --git a/ngx_stream_health_detect_module.h b/ngx_stream_health_detect_module.h index 60180c9..d62a46a 100644 --- a/ngx_stream_health_detect_module.h +++ b/ngx_stream_health_detect_module.h @@ -6,7 +6,7 @@ #include ngx_uint_t ngx_stream_health_detect_upstream_add_peer( - ngx_stream_upstream_srv_conf_t *us, ngx_str_t *server, + ngx_pool_t *pool, ngx_stream_upstream_srv_conf_t *us, ngx_str_t *server, ngx_addr_t *peer_addr); void ngx_stream_health_detect_upstream_delete_peer( diff --git a/patch/nginx_healthdetect_for_nginx_1.12+.patch b/patch/nginx_healthdetect_for_nginx_1.12+.patch index fd06875..2da8431 100644 --- a/patch/nginx_healthdetect_for_nginx_1.12+.patch +++ b/patch/nginx_healthdetect_for_nginx_1.12+.patch @@ -271,7 +271,7 @@ index 526de3a8..d9e289f3 100644 +#if (NGX_STREAM_HEALTH_DETECT) + if (!server[i].down) { -+ ngx_stream_health_detect_upstream_add_peer(us, &server[i].name, &server[i].addrs[j]); ++ ngx_stream_health_detect_upstream_add_peer(cf->pool, us, &server[i].name, &server[i].addrs[j]); + } +#endif + @@ -284,7 +284,7 @@ index 526de3a8..d9e289f3 100644 +#if (NGX_STREAM_HEALTH_DETECT) + if (!server[i].down) { -+ ngx_stream_health_detect_upstream_add_peer(us, &server[i].name, &server[i].addrs[j]); ++ ngx_stream_health_detect_upstream_add_peer(cf->pool, us, &server[i].name, &server[i].addrs[j]); + } +#endif + diff --git a/patch/nginx_healthdetect_for_nginx_1.16+.patch b/patch/nginx_healthdetect_for_nginx_1.16+.patch index 90a3549..1be6741 100644 --- a/patch/nginx_healthdetect_for_nginx_1.16+.patch +++ b/patch/nginx_healthdetect_for_nginx_1.16+.patch @@ -271,7 +271,7 @@ index 36e2ec5c..5dadd1cb 100644 +#if (NGX_STREAM_HEALTH_DETECT) + if (!server[i].down) { -+ ngx_stream_health_detect_upstream_add_peer(us, &server[i].name, &server[i].addrs[j]); ++ ngx_stream_health_detect_upstream_add_peer(cf->pool, us, &server[i].name, &server[i].addrs[j]); + } +#endif + @@ -284,7 +284,7 @@ index 36e2ec5c..5dadd1cb 100644 +#if (NGX_STREAM_HEALTH_DETECT) + if (!server[i].down) { -+ ngx_stream_health_detect_upstream_add_peer(us, &server[i].name, &server[i].addrs[j]); ++ ngx_stream_health_detect_upstream_add_peer(cf->pool, us, &server[i].name, &server[i].addrs[j]); + } +#endif + diff --git a/patch/nginx_healthdetect_for_nginx_1.18+.patch b/patch/nginx_healthdetect_for_nginx_1.18+.patch index 85a4bdc..6c195e7 100644 --- a/patch/nginx_healthdetect_for_nginx_1.18+.patch +++ b/patch/nginx_healthdetect_for_nginx_1.18+.patch @@ -271,7 +271,7 @@ index c2076673..bd458852 100644 +#if (NGX_STREAM_HEALTH_DETECT) + if (!server[i].down) { -+ ngx_stream_health_detect_upstream_add_peer(us, &server[i].name, &server[i].addrs[j]); ++ ngx_stream_health_detect_upstream_add_peer(cf->pool, us, &server[i].name, &server[i].addrs[j]); + } +#endif + @@ -284,7 +284,7 @@ index c2076673..bd458852 100644 +#if (NGX_STREAM_HEALTH_DETECT) + if (!server[i].down) { -+ ngx_stream_health_detect_upstream_add_peer(us, &server[i].name, &server[i].addrs[j]); ++ ngx_stream_health_detect_upstream_add_peer(cf->pool, us, &server[i].name, &server[i].addrs[j]); + } +#endif + diff --git a/patch/nginx_healthdetect_for_nginx_1.24+.patch b/patch/nginx_healthdetect_for_nginx_1.24+.patch index 40611bc..602382b 100644 --- a/patch/nginx_healthdetect_for_nginx_1.24+.patch +++ b/patch/nginx_healthdetect_for_nginx_1.24+.patch @@ -278,7 +278,7 @@ index ae3bf37a..88ee5d89 100644 +#if (NGX_STREAM_HEALTH_DETECT) + if (!server[i].down) { -+ ngx_stream_health_detect_upstream_add_peer(us, &server[i].name, &server[i].addrs[j]); ++ ngx_stream_health_detect_upstream_add_peer(cf->pool, us, &server[i].name, &server[i].addrs[j]); + } +#endif + @@ -291,7 +291,7 @@ index ae3bf37a..88ee5d89 100644 +#if (NGX_STREAM_HEALTH_DETECT) + if (!server[i].down) { -+ ngx_stream_health_detect_upstream_add_peer(us, &server[i].name, &server[i].addrs[j]); ++ ngx_stream_health_detect_upstream_add_peer(cf->pool, us, &server[i].name, &server[i].addrs[j]); + } +#endif + diff --git a/patch/nginx_healthdetect_for_nginx_1.26+.patch b/patch/nginx_healthdetect_for_nginx_1.26+.patch index 172ac87..96dc512 100644 --- a/patch/nginx_healthdetect_for_nginx_1.26+.patch +++ b/patch/nginx_healthdetect_for_nginx_1.26+.patch @@ -271,7 +271,7 @@ index ae3bf37a6..9fdde0243 100644 +#if (NGX_STREAM_HEALTH_DETECT) + if (!server[i].down) { -+ ngx_stream_health_detect_upstream_add_peer(us, &server[i].name, &server[i].addrs[j]); ++ ngx_stream_health_detect_upstream_add_peer(cf->pool, us, &server[i].name, &server[i].addrs[j]); + } +#endif + @@ -284,7 +284,7 @@ index ae3bf37a6..9fdde0243 100644 +#if (NGX_STREAM_HEALTH_DETECT) + if (!server[i].down) { -+ ngx_stream_health_detect_upstream_add_peer(us, &server[i].name, &server[i].addrs[j]); ++ ngx_stream_health_detect_upstream_add_peer(cf->pool, us, &server[i].name, &server[i].addrs[j]); + } +#endif +