Skip to content
Snippets Groups Projects
Commit 2b20309b authored by Konstantin Osipov's avatar Konstantin Osipov
Browse files

box-switch_mode: fix the memory leak on reload configuration

Fix the memory leak which would occur when
allocating memory for the "status" string,
output by 'show info'. The allocation was done
on each RELOAD CONFIGURATION, and
old memory was never freed.

Fix: use static memory instead of palloc.
parent 32656c43
No related branches found
No related tags found
No related merge requests found
...@@ -53,7 +53,7 @@ static void box_process_rw(u32 op, struct tbuf *request_data); ...@@ -53,7 +53,7 @@ static void box_process_rw(u32 op, struct tbuf *request_data);
const char *mod_name = "Box"; const char *mod_name = "Box";
iproto_callback rw_callback = box_process_ro; iproto_callback rw_callback = box_process_ro;
static char *status = "unknown"; static char status[64] = "unknown";
static int stat_base; static int stat_base;
STRS(messages, MESSAGES); STRS(messages, MESSAGES);
...@@ -1239,8 +1239,7 @@ remote_recovery_restart(struct tarantool_cfg *conf) ...@@ -1239,8 +1239,7 @@ remote_recovery_restart(struct tarantool_cfg *conf)
conf->wal_feeder_port, conf->wal_feeder_port,
default_remote_row_handler); default_remote_row_handler);
status = palloc(eter_pool, 64); snprintf(status, sizeof(status), "replica/%s:%i%s", conf->wal_feeder_ipaddr,
snprintf(status, 64, "replica/%s:%i%s", conf->wal_feeder_ipaddr,
conf->wal_feeder_port, custom_proc_title); conf->wal_feeder_port, custom_proc_title);
title("replica/%s:%i%s", conf->wal_feeder_ipaddr, conf->wal_feeder_port, title("replica/%s:%i%s", conf->wal_feeder_ipaddr, conf->wal_feeder_port,
custom_proc_title); custom_proc_title);
...@@ -1264,10 +1263,10 @@ box_master_or_slave(struct tarantool_cfg *conf) ...@@ -1264,10 +1263,10 @@ box_master_or_slave(struct tarantool_cfg *conf)
} }
rw_callback = box_process_rw; rw_callback = box_process_rw;
say_info("I am primary"); snprintf(status, sizeof(status), "primary");
status = "primary";
title("primary"); title("primary");
say_info("I am primary");
} }
} }
...@@ -1422,7 +1421,7 @@ mod_init(void) ...@@ -1422,7 +1421,7 @@ mod_init(void)
if (cfg.local_hot_standby) { if (cfg.local_hot_standby) {
say_info("starting local hot standby"); say_info("starting local hot standby");
recover_follow(recovery_state, cfg.wal_dir_rescan_delay); recover_follow(recovery_state, cfg.wal_dir_rescan_delay);
status = "hot_standby"; snprintf(status, sizeof(status), "hot_standby");
title("hot_standby"); title("hot_standby");
} }
...@@ -1440,8 +1439,6 @@ mod_init(void) ...@@ -1440,8 +1439,6 @@ mod_init(void)
(fiber_server_callback) iproto_interact, (fiber_server_callback) iproto_interact,
&rw_callback, box_bound_to_primary); &rw_callback, box_bound_to_primary);
} }
say_info("initialized");
} }
int int
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment