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.

100 lines
4.2 KiB

  1. From a49007a187ab7fddfcec58e1d9fc8a707e4531c9 Mon Sep 17 00:00:00 2001
  2. From: Christopher Faulet <cfaulet@haproxy.com>
  3. Date: Tue, 18 Jul 2017 11:18:46 +0200
  4. Subject: [PATCH 12/18] MINOR: http: Reorder/rewrite checks in
  5. http_resync_states
  6. The previous patch removed the forced symmetry of the TUNNEL mode during the
  7. state synchronization. Here, we take care to remove body analyzer only on the
  8. channel in TUNNEL mode. In fact, today, this change has no effect because both
  9. sides are switched in same time. But this way, with some changes, it will be
  10. possible to keep body analyzer on a side (to finish the states synchronization)
  11. with the other one in TUNNEL mode.
  12. WARNING: This patch will be used to fix a bug. The fix will be commited in a
  13. very next commit. So if the fix is backported, this one must be backported too.
  14. (cherry picked from commit f77bb539d4846ab278269b99a3165a5608ca0cf4)
  15. Signed-off-by: William Lallemand <wlallemand@haproxy.org>
  16. ---
  17. src/proto_http.c | 48 +++++++++++++++++++++++++++++-------------------
  18. 1 file changed, 29 insertions(+), 19 deletions(-)
  19. diff --git a/src/proto_http.c b/src/proto_http.c
  20. index 796955f5..aaf9f648 100644
  21. --- a/src/proto_http.c
  22. +++ b/src/proto_http.c
  23. @@ -5577,34 +5577,27 @@ int http_resync_states(struct stream *s)
  24. /* OK, both state machines agree on a compatible state.
  25. * There are a few cases we're interested in :
  26. - * - HTTP_MSG_TUNNEL on either means we have to disable both analysers
  27. * - HTTP_MSG_CLOSED on both sides means we've reached the end in both
  28. * directions, so let's simply disable both analysers.
  29. - * - HTTP_MSG_CLOSED on the response only means we must abort the
  30. - * request.
  31. - * - HTTP_MSG_CLOSED on the request and HTTP_MSG_DONE on the response
  32. - * with server-close mode means we've completed one request and we
  33. - * must re-initialize the server connection.
  34. + * - HTTP_MSG_CLOSED on the response only or HTTP_MSG_ERROR on either
  35. + * means we must abort the request.
  36. + * - HTTP_MSG_TUNNEL on either means we have to disable analyser on
  37. + * corresponding channel.
  38. + * - HTTP_MSG_DONE or HTTP_MSG_CLOSED on the request and HTTP_MSG_DONE
  39. + * on the response with server-close mode means we've completed one
  40. + * request and we must re-initialize the server connection.
  41. */
  42. -
  43. - if (txn->req.msg_state == HTTP_MSG_TUNNEL ||
  44. - txn->rsp.msg_state == HTTP_MSG_TUNNEL ||
  45. - (txn->req.msg_state == HTTP_MSG_CLOSED &&
  46. - txn->rsp.msg_state == HTTP_MSG_CLOSED)) {
  47. + if (txn->req.msg_state == HTTP_MSG_CLOSED &&
  48. + txn->rsp.msg_state == HTTP_MSG_CLOSED) {
  49. s->req.analysers &= AN_REQ_FLT_END;
  50. channel_auto_close(&s->req);
  51. channel_auto_read(&s->req);
  52. s->res.analysers &= AN_RES_FLT_END;
  53. channel_auto_close(&s->res);
  54. channel_auto_read(&s->res);
  55. - if (txn->req.msg_state == HTTP_MSG_TUNNEL && HAS_REQ_DATA_FILTERS(s))
  56. - s->req.analysers |= AN_REQ_FLT_XFER_DATA;
  57. - if (txn->rsp.msg_state == HTTP_MSG_TUNNEL && HAS_RSP_DATA_FILTERS(s))
  58. - s->res.analysers |= AN_RES_FLT_XFER_DATA;
  59. - }
  60. - else if ((txn->req.msg_state >= HTTP_MSG_DONE &&
  61. - (txn->rsp.msg_state == HTTP_MSG_CLOSED || (s->res.flags & CF_SHUTW))) ||
  62. - txn->rsp.msg_state == HTTP_MSG_ERROR ||
  63. + }
  64. + else if (txn->rsp.msg_state == HTTP_MSG_CLOSED ||
  65. + txn->rsp.msg_state == HTTP_MSG_ERROR ||
  66. txn->req.msg_state == HTTP_MSG_ERROR) {
  67. s->res.analysers &= AN_RES_FLT_END;
  68. channel_auto_close(&s->res);
  69. @@ -5615,6 +5608,23 @@ int http_resync_states(struct stream *s)
  70. channel_auto_read(&s->req);
  71. channel_truncate(&s->req);
  72. }
  73. + else if (txn->req.msg_state == HTTP_MSG_TUNNEL ||
  74. + txn->rsp.msg_state == HTTP_MSG_TUNNEL) {
  75. + if (txn->req.msg_state == HTTP_MSG_TUNNEL) {
  76. + s->req.analysers &= AN_REQ_FLT_END;
  77. + if (HAS_REQ_DATA_FILTERS(s))
  78. + s->req.analysers |= AN_REQ_FLT_XFER_DATA;
  79. + }
  80. + if (txn->rsp.msg_state == HTTP_MSG_TUNNEL) {
  81. + s->res.analysers &= AN_RES_FLT_END;
  82. + if (HAS_RSP_DATA_FILTERS(s))
  83. + s->res.analysers |= AN_RES_FLT_XFER_DATA;
  84. + }
  85. + channel_auto_close(&s->req);
  86. + channel_auto_read(&s->req);
  87. + channel_auto_close(&s->res);
  88. + channel_auto_read(&s->res);
  89. + }
  90. else if ((txn->req.msg_state == HTTP_MSG_DONE ||
  91. txn->req.msg_state == HTTP_MSG_CLOSED) &&
  92. txn->rsp.msg_state == HTTP_MSG_DONE &&
  93. --
  94. 2.13.0