Skip to content

[bug] connection won't be closed when using ngx.thread.spawn #31

Closed
@mike07026

Description

@mike07026

Example: test.lua

local function say_hello()
    return ngx.say("hello")
end

for i = 1, 3 do

    ngx.sleep(1.0)
    local co = ngx.thread.spawn(say_hello)
    ngx.thread.wait(co)

end

-- the clinet connection will not be close
-- it's a bug, but we can workaround with ngx.sleep
--ngx.sleep(0.001)

After printing three "hello", the client's connection won't be closed after the "world" exit.
It's a bug, but we can workaround with ngx.sleep.

I run this code under stream-lua-nginx-module and listen port 1234, here is the result

nc 127.0.0.1 1234
hello
hello
hello
-- wait here forever, the connection won't be closed.

if uncomment code "ngx.sleep(0.001)", the connection will be closed correctly.

nc 127.0.0.1 1234
hello
hello
hello
-- connection closed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions