You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
2.0 KiB

  1. From 8d570235f18eb7a6c920d674d1a057f35c6740e8 Mon Sep 17 00:00:00 2001
  2. From: Christopher Faulet <cfaulet@haproxy.com>
  3. Date: Mon, 19 Dec 2016 09:29:06 +0100
  4. Subject: [PATCH 09/19] BUG/MINOR: Fix the sending function in Lua's cosocket
  5. This is a regression from the commit a73e59b6901a164d19b1145e8511602d9814f28f.
  6. When data are sent from a cosocket, the action is done in the context of the
  7. applet running a lua stack and not in the context of the applet owning the
  8. cosocket. So we must take care, explicitly, that this last applet have a buffer
  9. (the req buffer of the cosocket).
  10. This patch must be backported in 1.7
  11. (cherry picked from commit 33834b15dce4658ee98fa85668162d78abf32e18)
  12. ---
  13. src/hlua.c | 14 ++++++++------
  14. 1 file changed, 8 insertions(+), 6 deletions(-)
  15. diff --git a/src/hlua.c b/src/hlua.c
  16. index cee2c1b..e82656b 100644
  17. --- a/src/hlua.c
  18. +++ b/src/hlua.c
  19. @@ -1884,14 +1884,19 @@ static int hlua_socket_write_yield(struct lua_State *L,int status, lua_KContext
  20. * the request buffer if its not required.
  21. */
  22. if (socket->s->req.buf->size == 0) {
  23. - si_applet_cant_put(&socket->s->si[0]);
  24. - goto hlua_socket_write_yield_return;
  25. + appctx = hlua->task->context;
  26. + if (!channel_alloc_buffer(&socket->s->req, &appctx->buffer_wait))
  27. + goto hlua_socket_write_yield_return;
  28. }
  29. /* Check for avalaible space. */
  30. len = buffer_total_space(socket->s->req.buf);
  31. - if (len <= 0)
  32. + if (len <= 0) {
  33. + appctx = objt_appctx(socket->s->si[0].end);
  34. + if (!hlua_com_new(hlua, &appctx->ctx.hlua.wake_on_write))
  35. + WILL_LJMP(luaL_error(L, "out of memory"));
  36. goto hlua_socket_write_yield_return;
  37. + }
  38. /* send data */
  39. if (len < send_len)
  40. @@ -1929,9 +1934,6 @@ static int hlua_socket_write_yield(struct lua_State *L,int status, lua_KContext
  41. return 1;
  42. hlua_socket_write_yield_return:
  43. - appctx = objt_appctx(socket->s->si[0].end);
  44. - if (!hlua_com_new(hlua, &appctx->ctx.hlua.wake_on_write))
  45. - WILL_LJMP(luaL_error(L, "out of memory"));
  46. WILL_LJMP(hlua_yieldk(L, 0, 0, hlua_socket_write_yield, TICK_ETERNITY, 0));
  47. return 0;
  48. }
  49. --
  50. 2.10.2