mirror of
https://github.com/weechat/weechat.git
synced 2026-06-29 22:36:38 +02:00
Fix problem when removing relay server (socket was closed, but option relay.port.xxx not removed)
This commit is contained in:
@@ -151,12 +151,13 @@ relay_command_relay (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
char **argv, char **argv_eol)
|
||||
{
|
||||
struct t_relay_server *ptr_server;
|
||||
struct t_config_option *ptr_option;
|
||||
int port;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
(void) argv_eol;
|
||||
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
if (weechat_strcasecmp (argv[1], "list") == 0)
|
||||
@@ -180,19 +181,25 @@ relay_command_relay (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
{
|
||||
if (argc >= 4)
|
||||
{
|
||||
relay_config_create_option_port (NULL,
|
||||
relay_config_file,
|
||||
relay_config_section_port,
|
||||
argv[2],
|
||||
argv_eol[3]);
|
||||
if (relay_config_create_option_port (NULL,
|
||||
relay_config_file,
|
||||
relay_config_section_port,
|
||||
argv[2],
|
||||
argv_eol[3]) != WEECHAT_CONFIG_OPTION_SET_ERROR)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
_("%s: relay \"%s\" (port %s) added"),
|
||||
RELAY_PLUGIN_NAME,
|
||||
argv[2], argv_eol[3]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: missing arguments for \"%s\" "
|
||||
"command"),
|
||||
weechat_prefix ("error"), RELAY_PLUGIN_NAME,
|
||||
"relay add");
|
||||
_("%s%s: missing arguments for \"%s\" "
|
||||
"command"),
|
||||
weechat_prefix ("error"), RELAY_PLUGIN_NAME,
|
||||
"relay add");
|
||||
}
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
@@ -203,7 +210,17 @@ relay_command_relay (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
ptr_server = relay_server_search (argv_eol[2]);
|
||||
if (ptr_server)
|
||||
{
|
||||
port = ptr_server->port;
|
||||
relay_server_free (ptr_server);
|
||||
ptr_option = weechat_config_search_option (relay_config_file,
|
||||
relay_config_section_port,
|
||||
argv_eol[2]);
|
||||
if (ptr_option)
|
||||
weechat_config_option_free (ptr_option);
|
||||
weechat_printf (NULL,
|
||||
_("%s: relay \"%s\" (port %d) removed"),
|
||||
RELAY_PLUGIN_NAME,
|
||||
argv[2], port);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -200,6 +200,14 @@ relay_config_create_option_port (void *data,
|
||||
RELAY_PLUGIN_NAME, protocol);
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
}
|
||||
|
||||
if (weechat_config_search_option (config_file, section, option_name))
|
||||
{
|
||||
weechat_printf (NULL, _("%s%s: error: relay for \"%s\" already exists"),
|
||||
weechat_prefix ("error"),
|
||||
RELAY_PLUGIN_NAME, option_name);
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
}
|
||||
|
||||
if (rc != WEECHAT_CONFIG_OPTION_SET_ERROR)
|
||||
{
|
||||
@@ -226,9 +234,10 @@ relay_config_create_option_port (void *data,
|
||||
&relay_config_change_port_cb, NULL,
|
||||
&relay_config_delete_port_cb, NULL);
|
||||
|
||||
relay_server_new (protocol_number, protocol_string, port);
|
||||
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
if (relay_server_new (protocol_number, protocol_string, port))
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
else
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
}
|
||||
|
||||
if (protocol)
|
||||
|
||||
Reference in New Issue
Block a user