-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Description
This is an example from the documentation, with a snippet from daurnimator's lua-http library, and is the minimal code needed to reproduce the issue I'm seeing in my application.
local ce = require "cqueues.errno"
local cqueues = require "cqueues"
local socket = require "cqueues.socket"
local cq = cqueues.new()
-- copied from https://git.io/JYqpM
local function onerror(socket, op, why, lvl)
local err = string.format("%s: %s", op, ce.strerror(why))
if op == "starttls" then
local ssl = socket:checktls()
if ssl and ssl.getVerifyResult then
local code, msg = ssl:getVerifyResult()
if code ~= 0 then
err = err .. ":" .. msg
end
end
end
if why == ce.ETIMEDOUT then
if op == "fill" or op == "read" then
socket:clearerr("r")
elseif op == "flush" then
socket:clearerr("w")
end
end
return err, why
end
local function send_request()
local http = socket.connect("google.com", 443)
http:onerror(onerror)
local ok, err, errno = http:starttls()
if not ok then
-- Note: calling http:close() here causes a different error to occur (Bad file descriptor)
return nil, err, errno
end
http:write("GET / HTTP/1.0\n")
http:write("Host: google.com:443\n\n")
local status = http:read()
print("!", status)
for ln in http:lines "*h" do
print("|", ln)
end
local empty = http:read "*L"
print "~"
for ln in http:lines "*L" do
io.stdout:write(ln)
end
http:close()
end
cq:wrap(function()
while true do
print(send_request())
cqueues.sleep(0.5)
end
end)
cq:wrap(function()
while true do
print(send_request())
cqueues.sleep(1)
end
end)
print(cq:loop())Note: The contents of onerror don't affect this issue, but give a nice error message.
Output:
nil starttls: Network is unreachable 101
nil starttls: Network is unreachable 101
nil starttls: Network is unreachable 101
nil starttls: Network is unreachable 101
nil starttls: Network is unreachable 101
nil starttls: Network is unreachable 101
nil starttls: Network is unreachable 101
nil starttls: Network is unreachable 101
nil starttls: Network is unreachable 101
nil starttls: Network is unreachable 101
nil starttls: Network is unreachable 101
false unable to update event disposition: No such file or directory (fd:28) 2 thread: 0xb6d75648 nil 28The count of starttls lines varies, from one to about a dozen. Which leads me to believe something is getting garbage collected and a reference to the garbage collected object is being used?
Metadata
Metadata
Assignees
Labels
No labels