] with-destructors ;
M: openssl-context dispose*
- [ aliens>> [ free ] each ]
- [ sessions>> values [ SSL_SESSION_free ] each ]
- [ handle>> SSL_CTX_free ]
- tri ;
+ [
+ [ aliens>> [ &free drop ] each ]
+ [ sessions>> values [ SSL_SESSION_free ] each ]
+ [ handle>> SSL_CTX_free ]
+ tri
+ ] with-destructors ;
TUPLE: ssl-handle < disposable file handle connected ;
] unless* ;
: <ssl-handle> ( fd -- ssl )
- ssl-handle new-disposable
- current-secure-context handle>> SSL_new
- dup ssl-error >>handle
- swap >>file ;
+ [
+ ssl-handle new-disposable |dispose
+ current-secure-context handle>> SSL_new
+ dup ssl-error >>handle
+ swap >>file
+ ] with-destructors ;
M: ssl-handle dispose*
- [ handle>> SSL_free ] [ file>> dispose ] bi ;
+ [
+ ! Free file>> after SSL_free
+ [ file>> &dispose drop ]
+ [ handle>> SSL_free ] bi
+ ] with-destructors ;
: check-verify-result ( ssl-handle -- )
SSL_get_verify_result dup X509_V_OK =
[ ] [
[
- "127.0.0.1" 0 <inet4> ascii <server> [
- dup addr>> port>> "port" get fulfill
- accept drop 1 minutes sleep dispose
- ] with-disposal
+ [
+ "127.0.0.1" 0 <inet4> ascii <server> &dispose
+ dup addr>> port>> "port" get fulfill
+ accept drop &dispose 1 minutes sleep
+ ] with-destructors
] "Silly server" spawn drop
] unit-test
[ ] [
[
- "127.0.0.1" "port" get ?promise
- <inet4> ascii <client> drop 1 minutes sleep dispose
+ [
+ "127.0.0.1" "port" get ?promise
+ <inet4> ascii <client> drop &dispose 1 minutes sleep
+ ] with-destructors
] "Silly client" spawn drop
] unit-test
[
1 seconds secure-socket-timeout [
[
- "127.0.0.1" 0 <inet4> <secure> ascii <server> [
- dup addr>> addrspec>> port>> "port" get fulfill
- accept drop dup stream-read1 drop dispose
- ] with-disposal
+ [
+ "127.0.0.1" 0 <inet4> <secure> ascii <server> [
+ dup addr>> addrspec>> port>> "port" get fulfill
+ accept drop &dispose dup stream-read1 drop
+ ] with-disposal
+ ] with-destructors
] with-test-context
] with-variable
] [ io-timeout? ] must-fail-with
[ ] [
[
[
- "127.0.0.1" 0 <inet4> <secure> ascii <server> [
- dup addr>> addrspec>> port>> "port" get fulfill
- accept drop 1 minutes sleep dispose
- ] with-disposal
- ] with-test-context
+ [
+ "127.0.0.1" 0 <inet4> <secure> ascii <server> [
+ dup addr>> addrspec>> port>> "port" get fulfill
+ accept drop &dispose 1 minutes sleep
+ ] with-disposal
+ ] with-test-context
+ ] with-destructors
] "Silly server" spawn drop
] unit-test
[ ] [
[
[
- "127.0.0.1" "port" get ?promise
- <inet4> <secure> ascii <client> drop 1 minutes sleep dispose
- ] with-test-context
+ [
+ "127.0.0.1" "port" get ?promise
+ <inet4> <secure> ascii <client> drop &dispose 1 minutes sleep
+ ] with-test-context
+ ] with-destructors
] "Silly client" spawn drop
] unit-test
[
- 1 seconds secure-socket-timeout [
- [
- "127.0.0.1" 0 <inet4> <secure> ascii <server> [
- dup addr>> addrspec>> port>> "port" get fulfill
- accept drop dispose
- ] with-disposal
- ] with-test-context
- ] with-variable
+ [
+ 1 seconds secure-socket-timeout [
+ [
+ "127.0.0.1" 0 <inet4> <secure> ascii <server> [
+ dup addr>> addrspec>> port>> "port" get fulfill
+ accept drop &dispose
+ ] with-disposal
+ ] with-test-context
+ ] with-variable
+ ] with-destructors
] [ io-timeout? ] must-fail-with
] drop