aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2020-05-02 16:37:46 +1000
committerSteve Bennett <steveb@workware.net.au>2020-05-06 11:22:52 +1000
commit90669224d718ec875d83df47694370d1cc6ccf23 (patch)
tree6552ff10b29e41ea9ef2f566e6d558ca6508d6a6 /tests
parentf8be02f204b55daaee5304e8ee99294612b29737 (diff)
downloadjimtcl-90669224d718ec875d83df47694370d1cc6ccf23.zip
jimtcl-90669224d718ec875d83df47694370d1cc6ccf23.tar.gz
jimtcl-90669224d718ec875d83df47694370d1cc6ccf23.tar.bz2
aio: Fix eventloop and eof for ssl connections
We can't use feof() and 'buffering none' on ssl connections. Instead we have to get eof from the ssl layer, and provide special handling for buffering in the eventloop. For eof, add ssl_eof() and detect SSL_read() results that indicate eof to set AIO_EOF in flags. For buffering, add 'read -pending' that will read, and then immediately read any buffered data so that the 'readable' event will trigger next time. Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'tests')
-rw-r--r--tests/aio.test8
-rw-r--r--tests/ssl.test10
2 files changed, 9 insertions, 9 deletions
diff --git a/tests/aio.test b/tests/aio.test
index 501b9a6..361acdc 100644
--- a/tests/aio.test
+++ b/tests/aio.test
@@ -58,7 +58,7 @@ test aio-1.9 {seek bad pos} -body {
test aio-2.1 {read usage} -body {
$f read -nonoption
-} -returnCodes error -result {expected integer but got "-nonoption"}
+} -returnCodes error -result {bad option "-nonoption": must be -nonewline, or -pending}
test aio-2.2 {read usage} -body {
$f read badint
@@ -70,7 +70,11 @@ test aio-2.3 {read -ve len} -body {
test aio-2.4 {read too many args} -body {
$f read 20 extra
-} -returnCodes error -match glob -result {wrong # args: should be "* read ?-nonewline? ?len?"}
+} -returnCodes error -match glob -result {wrong # args: should be "* read ?-nonewline|-pending|len?"}
+
+test aio-2.5 {read -pending on non-ssl} -body {
+ $f read -pending
+} -returnCodes error -result {-pending not supported on this connection type}
test aio-3.1 {copy to invalid fh} -body {
$f copy lambda
diff --git a/tests/ssl.test b/tests/ssl.test
index a15c4d6..f07391e 100644
--- a/tests/ssl.test
+++ b/tests/ssl.test
@@ -2,7 +2,6 @@ source [file dirname [info script]]/testing.tcl
needs constraint jim
needs cmd socket
-needs cmd alarm
needs cmd os.fork
testCmdConstraints load_ssl_certs
@@ -16,11 +15,12 @@ set s [socket stream.server 1443]
if {[os.fork] == 0} {
# child
set c [[socket stream [$s sockname]] ssl]
- $c buffering none
$s close
sleep 0.25
$c readable {
- set buf [$c read 1]
+ # when we read we need to also read any pending data,
+ # otherwise readable won't retrigger
+ set buf [$c read -pending]
if {[string length $buf] == 0} {
incr ssldone
$c close
@@ -47,9 +47,6 @@ test ssl-1.1 {puts/gets} {
$cs gets
} hello
-# XXX this test does not work because of the interaction between
-# ssl buffering and readable
-alarm 1
test ssl-1.2 {puts/gets} {
$cs puts -nonewline again
lmap p [range 5] {
@@ -57,7 +54,6 @@ test ssl-1.2 {puts/gets} {
set c
}
} {a g a i n}
-alarm 0
test ssl-2.1 {https to google.com, gets} -body {
set c [[socket stream www.google.com:443] ssl]