summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2013-02-16 10:00:28 +0100
committerSebastien Helleu <flashcode@flashtux.org>2013-02-16 10:00:28 +0100
commitc1bc23b052e47dd2b2994f971384fdc7cacd327b (patch)
tree944d3242d030e7e4ff6bb7be84b7f325804710ed /src
parent47e1caa91ff5492aea359a37c671b904290f6020 (diff)
downloadweechat-c1bc23b052e47dd2b2994f971384fdc7cacd327b.zip
irc: fix memory leak in purge of hashtables with joins (it was done only for the first server in the list)
Diffstat (limited to 'src')
-rw-r--r--src/plugins/irc/irc-server.c16
-rw-r--r--src/plugins/irc/irc-server.h1
-rw-r--r--src/plugins/irc/irc-upgrade.c1
3 files changed, 10 insertions, 8 deletions
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index cd0c20b9c..ff80397bf 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -105,8 +105,6 @@ char *irc_server_chanmodes_default = "beI,k,l";
const char *irc_server_send_default_tags = NULL; /* default tags when */
/* sending a message */
-time_t irc_server_last_check_join_channels = 0;
-
void irc_server_reconnect (struct t_irc_server *server);
void irc_server_free_data (struct t_irc_server *server);
@@ -949,6 +947,7 @@ irc_server_alloc (const char *name)
new_server->cmd_list_regexp = NULL;
new_server->last_user_message = 0;
new_server->last_away_check = 0;
+ new_server->last_data_purge = 0;
for (i = 0; i < IRC_SERVER_NUM_OUTQUEUES_PRIO; i++)
{
new_server->outqueue[i] = NULL;
@@ -2831,11 +2830,8 @@ irc_server_timer_cb (void *data, int remaining_calls)
ptr_redirect = ptr_next_redirect;
}
- /*
- * remove old channels in "join_manual" and "join_noswitch"
- * (every 5 minutes)
- */
- if (current_time > irc_server_last_check_join_channels + (60 * 5))
+ /* purge some data (every 10 minutes) */
+ if (current_time > ptr_server->last_data_purge + (60 * 10))
{
weechat_hashtable_map (ptr_server->join_manual,
&irc_server_check_join_manual_cb,
@@ -2843,7 +2839,7 @@ irc_server_timer_cb (void *data, int remaining_calls)
weechat_hashtable_map (ptr_server->join_noswitch,
&irc_server_check_join_noswitch_cb,
ptr_server);
- irc_server_last_check_join_channels = current_time;
+ ptr_server->last_data_purge = current_time;
}
}
}
@@ -4525,6 +4521,7 @@ irc_server_hdata_server_cb (void *data, const char *hdata_name)
WEECHAT_HDATA_VAR(struct t_irc_server, cmd_list_regexp, POINTER, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_server, last_user_message, TIME, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_server, last_away_check, TIME, 0, NULL, NULL);
+ WEECHAT_HDATA_VAR(struct t_irc_server, last_data_purge, TIME, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_server, outqueue, POINTER, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_server, last_outqueue, POINTER, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_server, redirects, POINTER, 0, NULL, "irc_redirect");
@@ -4745,6 +4742,8 @@ irc_server_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!weechat_infolist_new_var_time (ptr_item, "last_away_check", server->last_away_check))
return 0;
+ if (!weechat_infolist_new_var_time (ptr_item, "last_data_purge", server->last_data_purge))
+ return 0;
return 1;
}
@@ -5052,6 +5051,7 @@ irc_server_print_log ()
weechat_log_printf (" cmd_list_regexp. . . : 0x%lx", ptr_server->cmd_list_regexp);
weechat_log_printf (" last_user_message. . : %ld", ptr_server->last_user_message);
weechat_log_printf (" last_away_check. . . : %ld", ptr_server->last_away_check);
+ weechat_log_printf (" last_data_purge. . . : %ld", ptr_server->last_data_purge);
for (i = 0; i < IRC_SERVER_NUM_OUTQUEUES_PRIO; i++)
{
weechat_log_printf (" outqueue[%02d] . . . . : 0x%lx", i, ptr_server->outqueue[i]);
diff --git a/src/plugins/irc/irc-server.h b/src/plugins/irc/irc-server.h
index 4a9438b63..cb1124dfe 100644
--- a/src/plugins/irc/irc-server.h
+++ b/src/plugins/irc/irc-server.h
@@ -194,6 +194,7 @@ struct t_irc_server
regex_t *cmd_list_regexp; /* compiled Regular Expression for /list */
time_t last_user_message; /* time of last user message (anti flood)*/
time_t last_away_check; /* time of last away check on server */
+ time_t last_data_purge; /* time of last purge (some hashtables) */
struct t_irc_outqueue *outqueue[2]; /* queue for outgoing messages */
/* with 2 priorities (high/low) */
struct t_irc_outqueue *last_outqueue[2]; /* last outgoing message */
diff --git a/src/plugins/irc/irc-upgrade.c b/src/plugins/irc/irc-upgrade.c
index da99dbc96..e262c88de 100644
--- a/src/plugins/irc/irc-upgrade.c
+++ b/src/plugins/irc/irc-upgrade.c
@@ -418,6 +418,7 @@ irc_upgrade_read_cb (void *data,
irc_upgrade_current_server->lag_last_refresh = weechat_infolist_time (infolist, "lag_last_refresh");
irc_upgrade_current_server->last_user_message = weechat_infolist_time (infolist, "last_user_message");
irc_upgrade_current_server->last_away_check = weechat_infolist_time (infolist, "last_away_check");
+ irc_upgrade_current_server->last_data_purge = weechat_infolist_time (infolist, "last_data_purge");
}
break;
case IRC_UPGRADE_TYPE_CHANNEL: