Skip to content

Conversation

@pspacek
Copy link
Contributor

@pspacek pspacek commented Apr 12, 2019

Fixes: #146

I'm not sure if implementation is correct, or if it best way to handle
it. In any case it fixes client-visible problem where lua-http server
keep connection open even after internal error (like #145).

@pspacek
Copy link
Contributor Author

pspacek commented Apr 12, 2019

Also, I have no idea how to write for this because it would require a way to cause exception from client side ... which is certainly something I do not want to see in server code ;-)

Copy link
Owner

@daurnimator daurnimator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't had time to review properly. Just things that immediately jumped out at me.

http/server.lua Outdated
stream, err, errno = conn:get_next_incoming_stream(timeout)
local stream_or_err
local finished
finished, stream_or_err, err, errno = xpcall(conn.get_next_incoming_stream, function(err) return debug.traceback(err) end, conn, timeout)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try and avoid xpcall on hot paths; it has quite an impact.

Also you can pass debug.traceback directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not Lua expert - can you advise a different approach to catch errors instead of xpcall?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it would be sufficient to wrap whole while cycle in xpcall(). Opinions?

Fixes: daurnimator#146

I'm not sure if implementation is correct, or if it best way to handle
it. In any case it fixes client-visible problem where lua-http server
keep connection open even after internal error (like daurnimator#145).
@pspacek pspacek force-pushed the throw_kill_connection branch from 026f9af to d254321 Compare April 12, 2019 16:00
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 86.615% when pulling d254321 on pspacek:throw_kill_connection into bc49a4b on daurnimator:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 86.615% when pulling d254321 on pspacek:throw_kill_connection into bc49a4b on daurnimator:master.

@daurnimator
Copy link
Owner

See #146 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unhandled errors leave connection open

3 participants