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.

49 lines
1.8 KiB

  1. commit 72c692701ab4197f1f8ec7594b7e8ef5082b9d9e
  2. Author: Christopher Faulet <cfaulet@haproxy.com>
  3. Date: Fri Jul 26 16:40:24 2019 +0200
  4. BUG/MINOR: hlua/htx: Reset channels analyzers when txn:done() is called
  5. For HTX streams, when txn:done() is called, the work is delegated to the
  6. function http_reply_and_close(). But it is not enough. The channel's analyzers
  7. must also be reset. Otherwise, some analyzers may still be called while
  8. processing should be aborted.
  9. For instance, if the function is called from an http-request rules on the
  10. frontend, request analyzers on the backend side are still called. So we may try
  11. to add an header to the request, while this one was already reset.
  12. This patch must be backported to 2.0 and 1.9.
  13. (cherry picked from commit fe6a71b8e08234dbe03fbd2fa3017590681479df)
  14. Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
  15. diff --git a/src/hlua.c b/src/hlua.c
  16. index 23d2aa04..f9d1d699 100644
  17. --- a/src/hlua.c
  18. +++ b/src/hlua.c
  19. @@ -5996,8 +5996,12 @@ __LJMP static int hlua_txn_done(lua_State *L)
  20. ic = &htxn->s->req;
  21. oc = &htxn->s->res;
  22. - if (IS_HTX_STRM(htxn->s))
  23. - htx_reply_and_close(htxn->s, 0, NULL);
  24. + if (IS_HTX_STRM(htxn->s)) {
  25. + htxn->s->txn->status = 0;
  26. + http_reply_and_close(htxn->s, 0, NULL);
  27. + ic->analysers &= AN_REQ_FLT_END;
  28. + oc->analysers &= AN_RES_FLT_END;
  29. + }
  30. else {
  31. if (htxn->s->txn) {
  32. /* HTTP mode, let's stay in sync with the stream */
  33. @@ -6031,6 +6035,9 @@ __LJMP static int hlua_txn_done(lua_State *L)
  34. ic->analysers = 0;
  35. }
  36. + if (!(htxn->s->flags & SF_ERR_MASK)) // this is not really an error but it is
  37. + htxn->s->flags |= SF_ERR_LOCAL; // to mark that it comes from the proxy
  38. +
  39. hlua->flags |= HLUA_STOP;
  40. WILL_LJMP(hlua_done(L));
  41. return 0;