@@ -191,46 +191,87 @@ void free_server_rules(struct list *srules)
191191 }
192192}
193193
194+ /* Frees proxy members that are common to all proxy types (either regular or
195+ * default ones) for a proxy that's about to be destroyed.
196+ * This is a subset of the complete proxy or default proxy deinit code.
197+ */
198+ static inline void proxy_free_common (struct proxy * px )
199+ {
200+ struct acl * acl , * aclb ;
201+ struct logger * log , * logb ;
202+
203+ ha_free (& px -> id );
204+ ha_free (& px -> conf .file );
205+ ha_free (& px -> check_command );
206+ ha_free (& px -> check_path );
207+ ha_free (& px -> cookie_name );
208+ ha_free (& px -> rdp_cookie_name );
209+ ha_free (& px -> dyncookie_key );
210+ ha_free (& px -> cookie_domain );
211+ ha_free (& px -> cookie_attrs );
212+ ha_free (& px -> lbprm .arg_str );
213+ ha_free (& px -> capture_name );
214+ istfree (& px -> monitor_uri );
215+ ha_free (& px -> conn_src .iface_name );
216+ #if defined(CONFIG_HAP_TRANSPARENT )
217+ ha_free (& px -> conn_src .bind_hdr_name );
218+ #endif
219+ istfree (& px -> server_id_hdr_name );
220+ istfree (& px -> header_unique_id );
221+
222+ http_ext_clean (px );
223+
224+ list_for_each_entry_safe (acl , aclb , & px -> acl , list ) {
225+ LIST_DELETE (& acl -> list );
226+ prune_acl (acl );
227+ free (acl );
228+ }
229+
230+ free_act_rules (& px -> tcp_req .inspect_rules );
231+ free_act_rules (& px -> tcp_rep .inspect_rules );
232+ free_act_rules (& px -> tcp_req .l4_rules );
233+ free_act_rules (& px -> tcp_req .l5_rules );
234+ free_act_rules (& px -> http_req_rules );
235+ free_act_rules (& px -> http_res_rules );
236+ free_act_rules (& px -> http_after_res_rules );
237+
238+ lf_expr_deinit (& px -> logformat );
239+ lf_expr_deinit (& px -> logformat_sd );
240+ lf_expr_deinit (& px -> logformat_error );
241+ lf_expr_deinit (& px -> format_unique_id );
242+
243+ list_for_each_entry_safe (log , logb , & px -> loggers , list ) {
244+ LIST_DEL_INIT (& log -> list );
245+ free_logger (log );
246+ }
247+
248+ chunk_destroy (& px -> log_tag );
249+
250+ free_email_alert (px );
251+ }
252+
194253void free_proxy (struct proxy * p )
195254{
196255 struct server * s ;
197256 struct cap_hdr * h ,* h_next ;
198257 struct listener * l ,* l_next ;
199258 struct bind_conf * bind_conf , * bind_back ;
200259 struct acl_cond * cond , * condb ;
201- struct acl * acl , * aclb ;
202260 struct switching_rule * rule , * ruleb ;
203261 struct redirect_rule * rdr , * rdrb ;
204- struct logger * log , * logb ;
205262 struct proxy_deinit_fct * pxdf ;
206263 struct server_deinit_fct * srvdf ;
207264
208265 if (!p )
209266 return ;
210267
211- free (p -> conf .file );
212- free (p -> id );
213- free (p -> cookie_name );
214- free (p -> cookie_domain );
215- free (p -> cookie_attrs );
216- free (p -> lbprm .arg_str );
268+ proxy_free_common (p );
269+
270+ /* regular proxy specific cleanup */
217271 release_sample_expr (p -> lbprm .expr );
218272 free (p -> server_state_file_name );
219- free (p -> capture_name );
220- istfree (& p -> monitor_uri );
221- istfree (& p -> server_id_hdr_name );
222- ha_free (& p -> check_command );
223- ha_free (& p -> check_path );
224- ha_free (& p -> dyncookie_key );
225- free (p -> rdp_cookie_name );
226- free_email_alert (p );
227273 free (p -> invalid_rep );
228274 free (p -> invalid_req );
229- ha_free (& p -> conn_src .iface_name );
230- #if defined(CONFIG_HAP_TRANSPARENT )
231- free (p -> conn_src .bind_hdr_name );
232- #endif
233- istfree (& p -> header_unique_id );
234275 if ((p -> lbprm .algo & BE_LB_LKUP ) == BE_LB_LKUP_MAP )
235276 free (p -> lbprm .map .srv );
236277
@@ -244,12 +285,6 @@ void free_proxy(struct proxy *p)
244285 EXTRA_COUNTERS_FREE (p -> extra_counters_fe );
245286 EXTRA_COUNTERS_FREE (p -> extra_counters_be );
246287
247- list_for_each_entry_safe (acl , aclb , & p -> acl , list ) {
248- LIST_DELETE (& acl -> list );
249- prune_acl (acl );
250- free (acl );
251- }
252-
253288 free_server_rules (& p -> server_rules );
254289
255290 list_for_each_entry_safe (rule , ruleb , & p -> switching_rules , list ) {
@@ -266,26 +301,6 @@ void free_proxy(struct proxy *p)
266301 http_free_redirect_rule (rdr );
267302 }
268303
269- list_for_each_entry_safe (log , logb , & p -> loggers , list ) {
270- LIST_DEL_INIT (& log -> list );
271- free_logger (log );
272- }
273-
274- chunk_destroy (& p -> log_tag );
275-
276- lf_expr_deinit (& p -> logformat );
277- lf_expr_deinit (& p -> logformat_sd );
278- lf_expr_deinit (& p -> format_unique_id );
279- lf_expr_deinit (& p -> logformat_error );
280-
281- free_act_rules (& p -> tcp_req .inspect_rules );
282- free_act_rules (& p -> tcp_rep .inspect_rules );
283- free_act_rules (& p -> tcp_req .l4_rules );
284- free_act_rules (& p -> tcp_req .l5_rules );
285- free_act_rules (& p -> http_req_rules );
286- free_act_rules (& p -> http_res_rules );
287- free_act_rules (& p -> http_after_res_rules );
288-
289304 free_stick_rules (& p -> storersp_rules );
290305 free_stick_rules (& p -> sticking_rules );
291306
@@ -356,8 +371,6 @@ void free_proxy(struct proxy *p)
356371
357372 free (p -> desc );
358373
359- http_ext_clean (p );
360-
361374 task_destroy (p -> task );
362375
363376 pool_destroy (p -> req_cap_pool );
@@ -1429,53 +1442,19 @@ void proxy_preset_defaults(struct proxy *defproxy)
14291442}
14301443
14311444/* Frees all dynamic settings allocated on a default proxy that's about to be
1432- * destroyed. This is a subset of the complete proxy deinit code, but these
1433- * should probably be merged ultimately. Note that most of the fields are not
1434- * even reset, so extreme care is required here, and calling
1435- * proxy_preset_defaults() afterwards would be safer.
1445+ * destroyed. Note that most of the fields are not even reset, so extreme care
1446+ * is required here, and calling proxy_preset_defaults() afterwards would be
1447+ * safer.
14361448 */
14371449void proxy_free_defaults (struct proxy * defproxy )
14381450{
1439- struct acl * acl , * aclb ;
1440- struct logger * log , * logb ;
14411451 struct cap_hdr * h ,* h_next ;
14421452
1443- ha_free (& defproxy -> id );
1444- ha_free (& defproxy -> conf .file );
1453+ proxy_free_common (defproxy );
1454+
1455+ /* default proxy specific cleanup */
14451456 ha_free ((char * * )& defproxy -> defsrv .conf .file );
1446- ha_free (& defproxy -> check_command );
1447- ha_free (& defproxy -> check_path );
1448- ha_free (& defproxy -> cookie_name );
1449- ha_free (& defproxy -> rdp_cookie_name );
1450- ha_free (& defproxy -> dyncookie_key );
1451- ha_free (& defproxy -> cookie_domain );
1452- ha_free (& defproxy -> cookie_attrs );
1453- ha_free (& defproxy -> lbprm .arg_str );
1454- ha_free (& defproxy -> capture_name );
1455- istfree (& defproxy -> monitor_uri );
14561457 ha_free (& defproxy -> defbe .name );
1457- ha_free (& defproxy -> conn_src .iface_name );
1458- #if defined(CONFIG_HAP_TRANSPARENT )
1459- ha_free (& defproxy -> conn_src .bind_hdr_name );
1460- #endif
1461- istfree (& defproxy -> header_unique_id );
1462- istfree (& defproxy -> server_id_hdr_name );
1463-
1464- http_ext_clean (defproxy );
1465-
1466- list_for_each_entry_safe (acl , aclb , & defproxy -> acl , list ) {
1467- LIST_DELETE (& acl -> list );
1468- prune_acl (acl );
1469- free (acl );
1470- }
1471-
1472- free_act_rules (& defproxy -> tcp_req .inspect_rules );
1473- free_act_rules (& defproxy -> tcp_rep .inspect_rules );
1474- free_act_rules (& defproxy -> tcp_req .l4_rules );
1475- free_act_rules (& defproxy -> tcp_req .l5_rules );
1476- free_act_rules (& defproxy -> http_req_rules );
1477- free_act_rules (& defproxy -> http_res_rules );
1478- free_act_rules (& defproxy -> http_after_res_rules );
14791458
14801459 h = defproxy -> req_cap ;
14811460 while (h ) {
@@ -1495,19 +1474,6 @@ void proxy_free_defaults(struct proxy *defproxy)
14951474 h = h_next ;
14961475 }
14971476
1498- lf_expr_deinit (& defproxy -> logformat );
1499- lf_expr_deinit (& defproxy -> logformat_sd );
1500- lf_expr_deinit (& defproxy -> logformat_error );
1501- lf_expr_deinit (& defproxy -> format_unique_id );
1502-
1503- list_for_each_entry_safe (log , logb , & defproxy -> loggers , list ) {
1504- LIST_DEL_INIT (& log -> list );
1505- free_logger (log );
1506- }
1507-
1508- chunk_destroy (& defproxy -> log_tag );
1509-
1510- free_email_alert (defproxy );
15111477 proxy_release_conf_errors (defproxy );
15121478 deinit_proxy_tcpcheck (defproxy );
15131479
0 commit comments