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.

42 lines
1.4 KiB

  1. commit 947a3f71ad9733dde6645edb91b6becb3ee51e7c
  2. Author: Cyril Bonté <cyril.bonte@free.fr>
  3. Date: Fri Aug 17 23:51:02 2018 +0200
  4. BUG/MEDIUM: lua: socket timeouts are not applied
  5. Sachin Shetty reported that socket timeouts set in LUA code have no effect.
  6. Indeed, connect timeout is never modified and is always set to its default,
  7. set to 5 seconds. Currently, this patch will apply the specified timeout
  8. value to the connect timeout.
  9. For the read and write timeouts, the issue is that the timeout is updated but
  10. the expiration dates were not updated.
  11. This patch should be backported up to the 1.6 branch.
  12. (cherry picked from commit 7bb634549794298fc701d33efd93c7289dcf9cb7)
  13. Signed-off-by: Willy Tarreau <w@1wt.eu>
  14. diff --git a/src/hlua.c b/src/hlua.c
  15. index 4e50fa64..daf775fc 100644
  16. --- a/src/hlua.c
  17. +++ b/src/hlua.c
  18. @@ -2566,10 +2566,19 @@ __LJMP static int hlua_socket_settimeout(struct lua_State *L)
  19. si = appctx->owner;
  20. s = si_strm(si);
  21. + s->sess->fe->timeout.connect = tmout;
  22. s->req.rto = tmout;
  23. s->req.wto = tmout;
  24. s->res.rto = tmout;
  25. s->res.wto = tmout;
  26. + s->req.rex = tick_add_ifset(now_ms, tmout);
  27. + s->req.wex = tick_add_ifset(now_ms, tmout);
  28. + s->res.rex = tick_add_ifset(now_ms, tmout);
  29. + s->res.wex = tick_add_ifset(now_ms, tmout);
  30. +
  31. + s->task->expire = tick_add_ifset(now_ms, tmout);
  32. + task_queue(s->task);
  33. +
  34. xref_unlock(&socket->xref, peer);
  35. lua_pushinteger(L, 1);