diff --git a/src/hlua.c b/src/hlua.c index 48de5cba5..5d49d3c03 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -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;