Hello, i am currently trying to run 2 TCP servers, one that will encrypt itself using MbedTLS and the other that will not.
An issue i am having is that when a socket is opened on one of the servers and it is waiting to time out neither server can take more requests. I looked into the accept code and i see there is an iolock, could that be causing this?
function loop(port, db)
server = Sockets.listen(port)
control_channel = Channel(10)
task = @async begin
while true
if(isready(control_channel))
val = take!(control_channel)
if(val == false)
break
end
end
conn = Sockets.accept(server)
@debug "Accepted " conn
@async begin
@debug "Connection Start"
state = 0
time_start = 0
while true
if(processConnection(conn, db) )
state = 0
else
if(state == 0)
time_start = now()
state = 1
elseif(state == 1)
if(now() - time_start >= Minute(1))
@debug "Connection Timeout." conn
break
end
end
end
sleep(0.1)
end
end
end
close(server)
end
return server, control_channel
end
function loopSecure(port, db)
server = Sockets.listen(port)
control_channel = Channel(10)
task = @async begin
while true
if(isready(control_channel))
val = take!(control_channel)
if(val == false)
break
end
end
conn = Sockets.accept(server)
@debug "Accepted " conn
@async begin
@debug "Secure Connection Start"
entropy = MbedTLS.Entropy()
rng = MbedTLS.CtrDrbg()
MbedTLS.seed!(rng, entropy)
ctx = MbedTLS.SSLContext()
conf = MbedTLS.SSLConfig()
MbedTLS.config_defaults!(conf)
MbedTLS.authmode!(conf, MbedTLS.MBEDTLS_SSL_VERIFY_REQUIRED)
MbedTLS.rng!(conf, rng)
MbedTLS.ca_chain!(conf)
MbedTLS.setup!(ctx, conf)
MbedTLS.set_bio!(ctx, conn)
MbedTLS.handshake(ctx)
state = 0
time_start = 0
while true
if(processConnection(conn, db) )
state = 0
else
if(state == 0)
time_start = now()
state = 1
elseif(state == 1)
if(now() - time_start >= Minute(1))
@debug "Connection Timeout." conn
break
end
end
end
sleep(0.1)
end
end
end
close(server)
end
return server, control_channel
end