From 0d7a82940b99a9fd4c161161367bb73552fbcf6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Thu, 23 Nov 2017 15:21:45 +0100 Subject: [PATCH] Sendfile: Improved support for TLS/SSL. Wait for write callback (ie TLS handshake completion) before calling the sendfile done callback when sending an empty string (ie the NOOP case). Fixes issue where the connection got closed by our side before TLS handshaking was completed, confusing the other side. Potential fix for [WS-94]. --- lib/modules/Stdio.pmod/module.pmod | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/lib/modules/Stdio.pmod/module.pmod b/lib/modules/Stdio.pmod/module.pmod index e8f02cd634..feebaa511d 100644 --- a/lib/modules/Stdio.pmod/module.pmod +++ b/lib/modules/Stdio.pmod/module.pmod @@ -3171,13 +3171,6 @@ protected class nb_sendfile } tr = 0; } - - if (!hd || !sizeof(hd - ({ "" }))) { - // NOOP! - SF_WERR("NOOP!"); - backend->call_out(cb, 0, 0, @a); - return; - } } if (hd) @@ -3214,7 +3207,7 @@ protected class nb_sendfile blocking_from = from->is_file || ((!from->set_nonblocking) || (from->mode && !(from->mode() & PROP_NONBLOCK))); - + if (off >= 0) { from->seek(off); } @@ -3242,12 +3235,8 @@ protected class nb_sendfile if (blocking_from) { SF_WERR("Reading some data."); do_read(); - if (!sizeof(to_write)) { - SF_WERR("NOOP!"); - backend->call_out(cb, 0, 0, @args); - } } - if (sizeof(to_write)) { + if (!from || sizeof(to_write)) { SF_WERR("Starting the writer."); start_writer(); } -- GitLab