Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Fork
libwebsockets
Commits
609ec858
Commit
609ec858
authored
10 years ago
by
Andy Green
Browse files
Options
Downloads
Patches
Plain Diff
ssl optimize poll when buffered ssl read data
Signed-off-by:
Andy Green
<
andy.green@linaro.org
>
parent
1f5c9f0c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
lib/lws-plat-unix.c
+19
-0
19 additions, 0 deletions
lib/lws-plat-unix.c
lib/private-libwebsockets.h
+1
-0
1 addition, 0 deletions
lib/private-libwebsockets.h
lib/service.c
+1
-1
1 addition, 1 deletion
lib/service.c
lib/ssl.c
+3
-1
3 additions, 1 deletion
lib/ssl.c
with
24 additions
and
2 deletions
lib/lws-plat-unix.c
+
19
−
0
View file @
609ec858
...
...
@@ -108,13 +108,27 @@ lws_plat_service(struct libwebsocket_context *context, int timeout_ms)
context
->
service_tid
=
context
->
protocols
[
0
].
callback
(
context
,
NULL
,
LWS_CALLBACK_GET_THREAD_ID
,
NULL
,
NULL
,
0
);
#ifdef LWS_OPENSSL_SUPPORT
/* if we know we have non-network pending data, do not wait in poll */
if
(
context
->
ssl_flag_buffered_reads
)
timeout_ms
=
0
;
#endif
n
=
poll
(
context
->
fds
,
context
->
fds_count
,
timeout_ms
);
context
->
service_tid
=
0
;
#ifdef LWS_OPENSSL_SUPPORT
if
(
!
context
->
ssl_flag_buffered_reads
&&
n
==
0
)
{
#else
if
(
n
==
0
)
/* poll timeout */
{
#endif
libwebsocket_service_fd
(
context
,
NULL
);
return
0
;
}
#ifdef LWS_OPENSSL_SUPPORT
/* any more will have to set it fresh this time around */
context
->
ssl_flag_buffered_reads
=
0
;
#endif
if
(
n
<
0
)
{
if
(
LWS_ERRNO
!=
LWS_EINTR
)
...
...
@@ -138,6 +152,11 @@ lws_plat_service(struct libwebsocket_context *context, int timeout_ms)
if
(
wsi
->
ssl
&&
wsi
->
buffered_reads_pending
)
{
lwsl_debug
(
"wsi %p: forcing POLLIN
\n
"
,
wsi
);
context
->
fds
[
n
].
revents
|=
context
->
fds
[
n
].
events
&
POLLIN
;
if
(
context
->
fds
[
n
].
revents
&
POLLIN
)
wsi
->
buffered_reads_pending
=
0
;
else
/* somebody left with pending SSL read data */
context
->
ssl_flag_buffered_reads
=
1
;
}
#endif
if
(
!
context
->
fds
[
n
].
revents
)
...
...
This diff is collapsed.
Click to expand it.
lib/private-libwebsockets.h
+
1
−
0
View file @
609ec858
...
...
@@ -464,6 +464,7 @@ struct libwebsocket_context {
int
allow_non_ssl_on_ssl_port
;
SSL_CTX
*
ssl_ctx
;
SSL_CTX
*
ssl_client_ctx
;
unsigned
int
ssl_flag_buffered_reads
:
1
;
#endif
struct
libwebsocket_protocols
*
protocols
;
int
count_protocols
;
...
...
This diff is collapsed.
Click to expand it.
lib/service.c
+
1
−
1
View file @
609ec858
...
...
@@ -436,7 +436,7 @@ libwebsocket_service_fd(struct libwebsocket_context *context,
if
(
!
(
pollfd
->
revents
&
LWS_POLLIN
))
break
;
eff_buf
.
token_len
=
lws_ssl_capable_read
(
context
->
wsi
,
eff_buf
.
token_len
=
lws_ssl_capable_read
(
context
,
wsi
,
context
->
service_buffer
,
sizeof
(
context
->
service_buffer
));
switch
(
eff_buf
.
token_len
)
{
...
...
This diff is collapsed.
Click to expand it.
lib/ssl.c
+
3
−
1
View file @
609ec858
...
...
@@ -374,8 +374,10 @@ lws_ssl_capable_read(struct libwebsocket_context *context,
* Because these won't signal at the network layer with POLLIN
* and if we don't realize, this data will sit there forever
*/
if
(
n
==
len
&&
wsi
->
ssl
&&
SSL_pending
(
wsi
->
ssl
))
if
(
n
==
len
&&
wsi
->
ssl
&&
SSL_pending
(
wsi
->
ssl
))
{
context
->
ssl_flag_buffered_reads
=
1
;
wsi
->
buffered_reads_pending
=
1
;
}
return
n
;
}
...
...
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
register
or
sign in
to comment