]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: lua/socket: Notification error
authorThierry FOURNIER <thierry.fournier@ozon.io>
Sat, 26 May 2018 22:59:48 +0000 (00:59 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 31 May 2018 08:58:41 +0000 (10:58 +0200)
Each time the send function yields, a notification must be registered.
Without this notification, the task is never wakeup when data arrives.

Today, the notification is registered only if the buffer is not available.
Other cases like the buffer is too small for all data are not processed.

This patch must be backported in 1.6, 1.7 and 1.8

src/hlua.c

index 48de5cba553f505a77b9d3a88cae4ff23f71dad8..5d49d3c038d8e894ee38bbe2841ca3f851b0730c 100644 (file)
@@ -1956,10 +1956,6 @@ static int hlua_socket_write_yield(struct lua_State *L,int status, lua_KContext
        /* Check for avalaible space. */
        len = buffer_total_space(s->req.buf);
        if (len <= 0) {
-               if (!notification_new(&hlua->com, &appctx->ctx.hlua_cosocket.wake_on_write, hlua->task)) {
-                       xref_unlock(&socket->xref, peer);
-                       WILL_LJMP(luaL_error(L, "out of memory"));
-               }
                goto hlua_socket_write_yield_return;
        }
 
@@ -2002,6 +1998,10 @@ static int hlua_socket_write_yield(struct lua_State *L,int status, lua_KContext
        }
 
 hlua_socket_write_yield_return:
+       if (!notification_new(&hlua->com, &appctx->ctx.hlua_cosocket.wake_on_write, hlua->task)) {
+               xref_unlock(&socket->xref, peer);
+               WILL_LJMP(luaL_error(L, "out of memory"));
+       }
        xref_unlock(&socket->xref, peer);
        WILL_LJMP(hlua_yieldk(L, 0, 0, hlua_socket_write_yield, TICK_ETERNITY, 0));
        return 0;