diff --git a/src/sockets/client.jl b/src/sockets/client.jl index 158e22d..085cb27 100644 --- a/src/sockets/client.jl +++ b/src/sockets/client.jl @@ -138,6 +138,7 @@ function c_increment_read_window_task(channel_task, arg, status) if status == Int(AWS_TASK_STATUS_RUN_READY) socket.window_size += arg.increment slotobj = unsafe_load(socket.slot) + # TODO: check return value of aws_channel_slot_increment_read_window aws_channel_slot_increment_read_window(socket.slot, arg.increment) put!(socket.ch, :read_window_incremented) socket.debug && @info "[$(_id(socket))]: c_increment_read_window_task: incremented read window by $(arg.increment) bytes" @@ -268,14 +269,13 @@ end const SETUP_CALLBACK = Ref{Ptr{Cvoid}}(C_NULL) function c_shutdown_callback(bootstrap, error_code, channel, socket) - GC.@preserve socket begin - socket.debug && @warn "c_shutdown_callback" - close(socket.ch) - close(socket.readbuf) - close(socket.writebuf) - socket.channel = C_NULL - socket.slot = C_NULL - end + socket.debug && @warn "c_shutdown_callback" + close(socket.ch) + close(socket.readbuf) + close(socket.writebuf) + socket.channel = C_NULL + socket.slot = C_NULL + aws_channel_destroy(channel) return end diff --git a/test/runtests.jl b/test/runtests.jl index f56f227..93aa5ed 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -21,12 +21,33 @@ data = String(read(sock, 100)) close(sock) println("testing tls upgrade") +Sockets.set_log_level!(7) sock = Sockets.Client("www.google.com", 443; tls=false, buffer_capacity=2^12, debug=true) AwsIO.Sockets.tlsupgrade!(sock; ssl_alpn_list="http/1.1") write(sock, "GET / HTTP/1.1\r\nHost: www.google.com\r\n\r\n") sleep(0.1) -data = String(read(sock, 100)) +data = String(read(sock, 1000)) @test startswith(data, "HTTP/1.1 200 OK") +data = String(read(sock, 1000)) +data = String(read(sock, 1000)) +data = String(read(sock, 1000)) +data = String(read(sock, 1000)) close(sock) end + + + +# using Test, AwsIO +# import AwsIO: AwsIO, Sockets +# println("testing tls upgrade") +# Sockets.set_log_level!(4) +# sock = Sockets.Client("www.google.com", 443; tls=false, buffer_capacity=2^12, debug=true) +# AwsIO.Sockets.tlsupgrade!(sock; ssl_alpn_list="http/1.1") +# write(sock, "GET / HTTP/1.1\r\nHost: www.google.com\r\n\r\n") +# sleep(0.1) +# data = String(read(sock, 1000)) +# data = String(read(sock, 1000)) +# data = String(read(sock, 1000)) +# data = String(read(sock, 1000)) +# data = String(read(sock, 1000))