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.

82 lines
2.7 KiB

  1. From ebb2bceb34d7787453548627ed0e99c60354672b Mon Sep 17 00:00:00 2001
  2. From: Willy Tarreau <w@1wt.eu>
  3. Date: Wed, 13 May 2015 11:59:14 +0200
  4. Subject: [PATCH 6/8] CLEANUP: checks: simplify the loop processing of
  5. tcp-checks
  6. There is some unobvious redundancy between the various ways we can leave
  7. the loop. Some of them can be factored out. So now we leave the loop when
  8. we can't go further, whether it's caused by reaching the end of the rules
  9. or by a blocking I/O.
  10. (cherry picked from commit 263013d031d754c9f96de0d0cb5afcc011af6441)
  11. [wt: this patch is required for the next fix]
  12. ---
  13. src/checks.c | 26 ++++++++++++++------------
  14. 1 file changed, 14 insertions(+), 12 deletions(-)
  15. diff --git a/src/checks.c b/src/checks.c
  16. index a887be1..a0c42f2 100644
  17. --- a/src/checks.c
  18. +++ b/src/checks.c
  19. @@ -1926,8 +1926,10 @@ static void tcpcheck_main(struct connection *conn)
  20. __conn_data_stop_both(conn);
  21. while (1) {
  22. - /* we have to try to flush the output buffer before reading, at the end,
  23. - * or if we're about to send a string that does not fit in the remaining space.
  24. + /* We have to try to flush the output buffer before reading, at
  25. + * the end, or if we're about to send a string that does not fit
  26. + * in the remaining space. That explains why we break out of the
  27. + * loop after this control.
  28. */
  29. if (check->bo->o &&
  30. (&check->current_step->list == head ||
  31. @@ -1940,16 +1942,12 @@ static void tcpcheck_main(struct connection *conn)
  32. __conn_data_stop_both(conn);
  33. goto out_end_tcpcheck;
  34. }
  35. - goto out_need_io;
  36. + break;
  37. }
  38. }
  39. - /* did we reach the end ? If so, let's check that everything was sent */
  40. - if (&check->current_step->list == head) {
  41. - if (check->bo->o)
  42. - goto out_need_io;
  43. + if (&check->current_step->list == head)
  44. break;
  45. - }
  46. /* have 'next' point to the next rule or NULL if we're on the
  47. * last one, connect() needs this.
  48. @@ -2131,7 +2129,7 @@ static void tcpcheck_main(struct connection *conn)
  49. }
  50. }
  51. else
  52. - goto out_need_io;
  53. + break;
  54. }
  55. /* mark the step as started */
  56. @@ -2233,10 +2231,14 @@ static void tcpcheck_main(struct connection *conn)
  57. } /* end expect */
  58. } /* end loop over double chained step list */
  59. - set_server_check_status(check, HCHK_STATUS_L7OKD, "(tcp-check)");
  60. - goto out_end_tcpcheck;
  61. + /* We're waiting for some I/O to complete, we've reached the end of the
  62. + * rules, or both. Do what we have to do, otherwise we're done.
  63. + */
  64. + if (&check->current_step->list == head && !check->bo->o) {
  65. + set_server_check_status(check, HCHK_STATUS_L7OKD, "(tcp-check)");
  66. + goto out_end_tcpcheck;
  67. + }
  68. - out_need_io:
  69. /* warning, current_step may now point to the head */
  70. if (check->bo->o)
  71. __conn_data_want_send(conn);
  72. --
  73. 2.0.5