Skip to main content
Homepage
Explore
Search or go to…
/
Sign in
Explore
Primary navigation
Project
L
libwebsockets
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Collapse sidebar
Snippets
Groups
Projects
Show more breadcrumbs
Fork
libwebsockets
Commits
abc2a5cd
This project is archived. Its data is
read-only
.
Commit
abc2a5cd
authored
Jun 23, 2017
by
Andy Green
Browse files
Options
Downloads
Patches
Plain Diff
windows: SO_EXCLUSIVEADDRUSE
https://github.com/warmcat/libwebsockets/issues/942
parent
d6394b6d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/libwebsockets.h
+6
-0
6 additions, 0 deletions
lib/libwebsockets.h
lib/server.c
+32
-7
32 additions, 7 deletions
lib/server.c
with
38 additions
and
7 deletions
lib/libwebsockets.h
+
6
−
0
View file @
abc2a5cd
...
...
@@ -1800,6 +1800,12 @@ enum lws_context_options {
/**< (VH) All connections to this vhost / port are RAW as soon as
* the connection is accepted, no HTTP is going to be coming.
*/
LWS_SERVER_OPTION_ALLOW_LISTEN_SHARE
=
(
1
<<
23
),
/**< (VH) Set to allow multiple listen sockets on one interface +
* address + port. The default is to strictly allow only one
* listen socket at a time. This is automatically selected if you
* have multiple service threads.
*/
/****** add new things just above ---^ ******/
};
...
...
...
...
This diff is collapsed.
Click to expand it.
lib/server.c
+
32
−
7
View file @
abc2a5cd
...
...
@@ -65,6 +65,7 @@ lws_context_init_server(struct lws_context_creation_info *info,
}
#if LWS_POSIX
(
void
)
n
;
#if defined(__linux__)
limit
=
vhost
->
context
->
count_threads
;
#endif
...
...
@@ -93,6 +94,24 @@ lws_context_init_server(struct lws_context_creation_info *info,
return
1
;
}
#if LWS_POSIX && !defined(LWS_WITH_ESP32)
#if (defined(WIN32) || defined(_WIN32)) && defined(SO_EXCLUSIVEADDRUSE)
/*
* only accept that we are the only listener on the port
* https://msdn.microsoft.com/zh-tw/library/windows/desktop/ms740621(v=vs.85).aspx
*
* for lws, to match Linux, we default to exclusive listen
*/
if
(
!
lws_check_opt
(
vhost
->
options
,
LWS_SERVER_OPTION_ALLOW_LISTEN_SHARE
))
{
if
(
setsockopt
(
sockfd
,
SOL_SOCKET
,
SO_EXCLUSIVEADDRUSE
,
(
const
void
*
)
&
opt
,
sizeof
(
opt
))
<
0
)
{
lwsl_err
(
"reuseaddr failed
\n
"
);
compatible_close
(
sockfd
);
return
1
;
}
}
else
#endif
/*
* allow us to restart even if old sockets in TIME_WAIT
*/
...
...
@@ -116,7 +135,13 @@ lws_context_init_server(struct lws_context_creation_info *info,
}
#endif
#if defined(__linux__) && defined(SO_REUSEPORT) && LWS_MAX_SMP > 1
#if defined(__linux__) && defined(SO_REUSEPORT)
n
=
lws_check_opt
(
vhost
->
options
,
LWS_SERVER_OPTION_ALLOW_LISTEN_SHARE
);
#if LWS_MAX_SMP > 1
n
=
1
;
#endif
if
(
n
)
if
(
vhost
->
context
->
count_threads
>
1
)
if
(
setsockopt
(
sockfd
,
SOL_SOCKET
,
SO_REUSEPORT
,
(
const
void
*
)
&
opt
,
sizeof
(
opt
))
<
0
)
{
...
...
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment