summaryrefslogtreecommitdiff
path: root/src/plugins/relay
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2019-06-04 22:54:00 +0200
committerSébastien Helleu <flashcode@flashtux.org>2019-06-04 22:54:00 +0200
commit479d234cedbacde49bdc55e4109286e280933937 (patch)
tree2e52e6b999e68e12ec061350a73a36d2f806da5a /src/plugins/relay
parent86d9cb1e4157845405227f83a0318c912cd40532 (diff)
downloadweechat-479d234cedbacde49bdc55e4109286e280933937.zip
relay: set socket option SO_REUSEADDR only for TCP sockets when creating the socket (issue #733)
Diffstat (limited to 'src/plugins/relay')
-rw-r--r--src/plugins/relay/relay-server.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/plugins/relay/relay-server.c b/src/plugins/relay/relay-server.c
index d130ad5d2..beccb8599 100644
--- a/src/plugins/relay/relay-server.c
+++ b/src/plugins/relay/relay-server.c
@@ -444,7 +444,7 @@ relay_server_sock_cb (const void *pointer, void *data, int fd)
flags = 0;
fcntl (client_fd, F_SETFL, flags | O_NONBLOCK);
- /* set socket option SO_REUSEADDR */
+ /* set socket option SO_REUSEADDR (only for TCP socket) */
if (!server->unix_socket)
{
set = 1;
@@ -621,19 +621,22 @@ relay_server_create_socket (struct t_relay_server *server)
}
#endif
- /* set option SO_REUSEADDR to 1 */
- set = 1;
- if (setsockopt (server->sock, SOL_SOCKET, SO_REUSEADDR,
- (void *) &set, sizeof (set)) < 0)
+ /* set option SO_REUSEADDR to 1 (only for TCP socket) */
+ if (!server->unix_socket)
{
- weechat_printf (NULL,
- _("%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;
+ set = 1;
+ if (setsockopt (server->sock, SOL_SOCKET, SO_REUSEADDR,
+ (void *) &set, sizeof (set)) < 0)
+ {
+ weechat_printf (NULL,
+ _("%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;
+ }
}
/* set option SO_KEEPALIVE to 1 */