Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
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
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
d2f58bff
Commit
d2f58bff
authored
4 years ago
by
H William Welliver
Browse files
Options
Downloads
Patches
Plain Diff
SSL: fix protocol hangs when non-blocking callbacks are set before handshake completes.
parent
1bd80db4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/modules/SSL.pmod/File.pike
+24
-6
24 additions, 6 deletions
lib/modules/SSL.pmod/File.pike
with
24 additions
and
6 deletions
lib/modules/SSL.pmod/File.pike
+
24
−
6
View file @
d2f58bff
...
@@ -93,6 +93,11 @@ protected Stdio.read_callback_t read_callback;
...
@@ -93,6 +93,11 @@ protected Stdio.read_callback_t read_callback;
protected Stdio.write_callback_t write_callback;
protected Stdio.write_callback_t write_callback;
protected function(void|mixed:int) close_callback;
protected function(void|mixed:int) close_callback;
// callbacks set during handshake are temporarily deferred and stored here.
protected Stdio.read_callback_t d_read_callback;
protected Stdio.write_callback_t d_write_callback;
protected function(void|mixed:int) d_close_callback;
protected Pike.Backend real_backend;
protected Pike.Backend real_backend;
// The real backend for the stream.
// The real backend for the stream.
...
@@ -1414,14 +1419,21 @@ void set_nonblocking(void|Stdio.read_callback_t read,
...
@@ -1414,14 +1419,21 @@ void set_nonblocking(void|Stdio.read_callback_t read,
nonblocking_mode = 1;
nonblocking_mode = 1;
accept_callback = accept;
accept_callback = accept;
read_callback = read;
write_callback = write;
if(SSL_HANDSHAKING) {
close_callback = close;
d_read_callback = read;
d_write_callback = write;
d_close_callback = close;
} else {
read_callback = read;
write_callback = write;
close_callback = close;
}
if (stream) {
if (stream) {
stream->set_backend(real_backend);
stream->set_backend(real_backend);
schedule_poll();
schedule_poll();
// Has to restore here since a backend waiting in another thread
// Has to restore here since a backend waiting in another thread
// might be woken immediately when callbacks are registered.
// might be woken immediately when callbacks are registered.
...
@@ -1495,7 +1507,8 @@ void set_blocking()
...
@@ -1495,7 +1507,8 @@ void set_blocking()
nonblocking_mode = 0;
nonblocking_mode = 0;
accept_callback = read_callback = write_callback = close_callback = 0;
accept_callback = read_callback = write_callback = close_callback = 0;
d_read_callback = d_write_callback = d_close_callback = 0;
if (!local_backend) local_backend = Pike.SmallBackend();
if (!local_backend) local_backend = Pike.SmallBackend();
if (stream) {
if (stream) {
...
@@ -2014,7 +2027,12 @@ protected int ssl_read_callback (int ignored, string input)
...
@@ -2014,7 +2027,12 @@ protected int ssl_read_callback (int ignored, string input)
if (stringp (data)) {
if (stringp (data)) {
if (!handshake_already_finished &&
if (!handshake_already_finished &&
!(conn->state & CONNECTION_handshaking)) {
!(conn->state & CONNECTION_handshaking)) {
SSL3_DEBUG_MSG ("ssl_read_callback: Handshake finished\n");
SSL3_DEBUG_MSG ("ssl_read_callback: Handshake finished\n");
// set deferred callbacks set during handshake
if(d_read_callback) read_callback = d_read_callback;
if(d_write_callback) write_callback = d_write_callback;
if(d_close_callback) close_callback = d_close_callback;
d_read_callback = d_write_callback = d_close_callback = 0;
}
}
SSL3_DEBUG_MSG ("ssl_read_callback: "
SSL3_DEBUG_MSG ("ssl_read_callback: "
...
...
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