diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2014-02-23 20:32:42 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2014-02-23 20:32:42 +0100 |
commit | fdfee08cf83f5547cdf07bda1f3745073056caa0 (patch) | |
tree | b4c9a3e3f9b640c576210ffa05c4f22c08ea8b63 /src/plugins | |
parent | 897bb0950cd1a2ecf6dd42394419efc40ac69460 (diff) | |
download | weechat-fdfee08cf83f5547cdf07bda1f3745073056caa0.zip |
relay: add option relay.network.clients_purge_delay
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/relay/relay-client.c | 28 | ||||
-rw-r--r-- | src/plugins/relay/relay-config.c | 8 | ||||
-rw-r--r-- | src/plugins/relay/relay-config.h | 1 |
3 files changed, 32 insertions, 5 deletions
diff --git a/src/plugins/relay/relay-client.c b/src/plugins/relay/relay-client.c index dd5a58582..2584fd4d2 100644 --- a/src/plugins/relay/relay-client.c +++ b/src/plugins/relay/relay-client.c @@ -822,18 +822,34 @@ relay_client_send (struct t_relay_client *client, const char *data, int relay_client_timer_cb (void *data, int remaining_calls) { - struct t_relay_client *ptr_client; - int num_sent, i; + struct t_relay_client *ptr_client, *ptr_next_client; + int num_sent, i, purge_delay; char *buf; + time_t current_time; /* make C compiler happy */ (void) data; (void) remaining_calls; - for (ptr_client = relay_clients; ptr_client; - ptr_client = ptr_client->next_client) + purge_delay = weechat_config_integer (relay_config_network_clients_purge_delay); + + current_time = time (NULL); + + ptr_client = relay_clients; + while (ptr_client) { - if (ptr_client->sock >= 0) + ptr_next_client = ptr_client->next_client; + + if (RELAY_CLIENT_HAS_ENDED(ptr_client)) + { + if ((purge_delay >= 0) + && (current_time >= ptr_client->end_time + (purge_delay * 60))) + { + relay_client_free (ptr_client); + relay_buffer_refresh (NULL); + } + } + else if (ptr_client->sock >= 0) { while (ptr_client->outqueue) { @@ -960,6 +976,8 @@ relay_client_timer_cb (void *data, int remaining_calls) } } } + + ptr_client = ptr_next_client; } return WEECHAT_RC_OK; diff --git a/src/plugins/relay/relay-config.c b/src/plugins/relay/relay-config.c index e0e46cbe1..0ca6c4fa0 100644 --- a/src/plugins/relay/relay-config.c +++ b/src/plugins/relay/relay-config.c @@ -52,6 +52,7 @@ struct t_config_option *relay_config_color_text_selected; struct t_config_option *relay_config_network_allowed_ips; struct t_config_option *relay_config_network_bind_address; +struct t_config_option *relay_config_network_clients_purge_delay; struct t_config_option *relay_config_network_compression_level; struct t_config_option *relay_config_network_ipv6; struct t_config_option *relay_config_network_max_clients; @@ -604,6 +605,13 @@ relay_config_init () "local machine only)"), NULL, 0, 0, "", NULL, 0, NULL, NULL, &relay_config_change_network_bind_address_cb, NULL, NULL, NULL); + relay_config_network_clients_purge_delay = weechat_config_new_option ( + relay_config_file, ptr_section, + "clients_purge_delay", "integer", + N_("delay for purging disconnected clients (in minutes, 0 = purge " + "clients immediately, -1 = never purge)"), + NULL, -1, 60 * 24 * 30, "0", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL); relay_config_network_compression_level = weechat_config_new_option ( relay_config_file, ptr_section, "compression_level", "integer", diff --git a/src/plugins/relay/relay-config.h b/src/plugins/relay/relay-config.h index a26cd9023..7cda6a25b 100644 --- a/src/plugins/relay/relay-config.h +++ b/src/plugins/relay/relay-config.h @@ -38,6 +38,7 @@ extern struct t_config_option *relay_config_color_text_selected; extern struct t_config_option *relay_config_network_allowed_ips; extern struct t_config_option *relay_config_network_bind_address; +extern struct t_config_option *relay_config_network_clients_purge_delay; extern struct t_config_option *relay_config_network_compression_level; extern struct t_config_option *relay_config_network_ipv6; extern struct t_config_option *relay_config_network_max_clients; |