restrict SO_REUSEPORT to multithreading only so no unexpected change otherwise
SO_REUSEPORT means you don't get any error any more if another server instance is already running, this will be quite unexpected for singlethreaded users. Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
parent
6dd7e86f23
commit
4bcbfe1ad4
1 changed files with 8 additions and 7 deletions
15
lib/server.c
15
lib/server.c
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* libwebsockets - small server side websockets and web server implementation
|
||||
*
|
||||
* Copyright (C) 2010-2015 Andy Green <andy@warmcat.com>
|
||||
* Copyright (C) 2010-2016 Andy Green <andy@warmcat.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -75,12 +75,13 @@ int lws_context_init_server(struct lws_context_creation_info *info,
|
|||
compatible_close(sockfd);
|
||||
return 1;
|
||||
}
|
||||
#if defined(__linux__) && defined(SO_REUSEPORT)
|
||||
if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEPORT,
|
||||
(const void *)&opt, sizeof(opt)) < 0) {
|
||||
compatible_close(sockfd);
|
||||
return 1;
|
||||
}
|
||||
#if defined(__linux__) && defined(SO_REUSEPORT) && LWS_MAX_SMP > 1
|
||||
if (context->count_threads > 1)
|
||||
if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEPORT,
|
||||
(const void *)&opt, sizeof(opt)) < 0) {
|
||||
compatible_close(sockfd);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
lws_plat_set_socket_options(context, sockfd);
|
||||
|
|
Loading…
Add table
Reference in a new issue