summaryrefslogtreecommitdiff
path: root/src/plugins/relay
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2013-01-24 08:55:04 +0100
committerSebastien Helleu <flashcode@flashtux.org>2013-01-24 08:55:04 +0100
commit27b539affee5b1d8f6e88565e79e08a45417ac4a (patch)
treec52a55359558ac0637f9cc995d5620c5d6b376af /src/plugins/relay
parent1918bd1d4e90f1540a5c1ebec9a2d4a4daca894c (diff)
downloadweechat-27b539affee5b1d8f6e88565e79e08a45417ac4a.zip
core: display error number and string in some network errors
Error number and string is now displayed when an error is returned by one of these functions: socket, setsockopt, fcntl, pipe, accept, bind, listen, mkfifo.
Diffstat (limited to 'src/plugins/relay')
-rw-r--r--src/plugins/relay/relay-server.c47
1 files changed, 32 insertions, 15 deletions
diff --git a/src/plugins/relay/relay-server.c b/src/plugins/relay/relay-server.c
index 4f4f61b06..baf54df0b 100644
--- a/src/plugins/relay/relay-server.c
+++ b/src/plugins/relay/relay-server.c
@@ -253,9 +253,10 @@ relay_server_sock_cb (void *data, int fd)
if (client_fd < 0)
{
weechat_printf (NULL,
- _("%s%s: cannot accept client on port %d (%s)"),
+ _("%s%s: cannot accept client on port %d (%s): error %d %s"),
weechat_prefix ("error"), RELAY_PLUGIN_NAME,
- server->port, server->protocol_string);
+ server->port, server->protocol_string,
+ errno, strerror (errno));
return WEECHAT_RC_OK;
}
@@ -309,9 +310,10 @@ relay_server_sock_cb (void *data, int fd)
(void *) &set, sizeof (set)) < 0)
{
weechat_printf (NULL,
- _("%s%s: cannot set socket option "
- "\"SO_REUSEADDR\""),
- weechat_prefix ("error"), RELAY_PLUGIN_NAME);
+ _("%s%s: cannot set socket option \"%s\" to %d: "
+ "error %d %s"),
+ weechat_prefix ("error"), RELAY_PLUGIN_NAME,
+ "SO_REUSEADDR", set, errno, strerror (errno));
close (client_fd);
return WEECHAT_RC_OK;
}
@@ -400,10 +402,10 @@ relay_server_create_socket (struct t_relay_server *server)
(void *) &set, sizeof (set)) < 0)
{
weechat_printf (NULL,
- _("%s%s: cannot set socket option \"IPV6_V6ONLY\" "
- "to value %d"),
+ _("%s%s: cannot set socket option \"%s\" "
+ "to %d: error %d %s"),
weechat_prefix ("error"), RELAY_PLUGIN_NAME,
- set);
+ "IPV6_V6ONLY", set, errno, strerror (errno));
close (server->sock);
server->sock = -1;
return 0;
@@ -417,8 +419,10 @@ relay_server_create_socket (struct t_relay_server *server)
(void *) &set, sizeof (set)) < 0)
{
weechat_printf (NULL,
- _("%s%s: cannot set socket option \"SO_REUSEADDR\""),
- weechat_prefix ("error"), RELAY_PLUGIN_NAME);
+ _("%s%s: cannot set socket option \"%s\" to %d: "
+ "error %d %s"),
+ weechat_prefix ("error"), RELAY_PLUGIN_NAME,
+ "SO_REUSEADDR", set, errno, strerror (errno));
close (server->sock);
server->sock = -1;
return 0;
@@ -430,8 +434,10 @@ relay_server_create_socket (struct t_relay_server *server)
(void *) &set, sizeof (set)) < 0)
{
weechat_printf (NULL,
- _("%s%s: cannot set socket option \"SO_KEEPALIVE\""),
- weechat_prefix ("error"), RELAY_PLUGIN_NAME);
+ _("%s%s: cannot set socket option \"%s\" to %d: "
+ "error %d %s"),
+ weechat_prefix ("error"), RELAY_PLUGIN_NAME,
+ "SO_KEEPALIVE", set, errno, strerror (errno));
close (server->sock);
server->sock = -1;
return 0;
@@ -441,9 +447,10 @@ relay_server_create_socket (struct t_relay_server *server)
if (bind (server->sock, (struct sockaddr *)ptr_addr, addr_size) < 0)
{
weechat_printf (NULL,
- _("%s%s: error with \"bind\" on port %d (%s)"),
+ _("%s%s: cannot \"bind\" on port %d (%s): error %d %s"),
weechat_prefix ("error"), RELAY_PLUGIN_NAME,
- server->port, server->protocol_string);
+ server->port, server->protocol_string,
+ errno, strerror (errno));
close (server->sock);
server->sock = -1;
return 0;
@@ -451,7 +458,17 @@ relay_server_create_socket (struct t_relay_server *server)
max_clients = weechat_config_integer (relay_config_network_max_clients);
- listen (server->sock, max_clients);
+ if (listen (server->sock, max_clients) != 0)
+ {
+ weechat_printf (NULL,
+ _("%s%s: cannot \"listen\" on port %d (%s): error %d %s"),
+ weechat_prefix ("error"), RELAY_PLUGIN_NAME,
+ server->port, server->protocol_string,
+ errno, strerror (errno));
+ close (server->sock);
+ server->sock = -1;
+ return 0;
+ }
weechat_printf (NULL,
_("%s: listening on port %d (relay: %s, %s, max %d clients)"),