]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MAJOR: lua: Dead lock with sockets
authorThierry FOURNIER <thierry.fournier@ozon.io>
Fri, 25 May 2018 13:03:50 +0000 (15:03 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 31 May 2018 08:58:41 +0000 (10:58 +0200)
In some cases, when we are waiting for data and the socket
timeout expires, we have a dead lock. The Lua socket locks
the applet socket, and call for a notify. The notify
immediately executes code and try to acquire the same lock,
so ... dead lock.

stream_int_notify() cant be used because it wakeup the applet
task only if the stream have changes. The changes are forces
by Lua, but not repported on the stream.

stream_int_update_applet() cant be used because the deadlock.

So, I inconditionnaly wakeup the applet. This wake is performed
asynchronously, and will call a stream_int_notify().

This patch must be backported in 1.6, 1.7 and 1.8

src/hlua.c

index 03e961c378f524791b76a3df6d23a1fcc2bda55c..48de5cba553f505a77b9d3a88cae4ff23f71dad8 100644 (file)
@@ -1766,8 +1766,7 @@ __LJMP static int hlua_socket_receive_yield(struct lua_State *L, int status, lua
        co_skip(oc, len + skip_at_end);
 
        /* Don't wait anything. */
-       stream_int_notify(&s->si[0]);
-       stream_int_update_applet(&s->si[0]);
+       appctx_wakeup(appctx);
 
        /* If the pattern reclaim to read all the data
         * in the connection, got out.