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.

46 lines
2.0 KiB

  1. From ae03ce5039283b63124e069bccd2c742cd71c5fb Mon Sep 17 00:00:00 2001
  2. From: Willy Tarreau <w@1wt.eu>
  3. Date: Tue, 13 Dec 2016 15:21:25 +0100
  4. Subject: [PATCH 04/19] BUG/MINOR: stream-int: automatically release
  5. SI_FL_WAIT_DATA on SHUTW_NOW
  6. While developing an experimental applet performing only one read per full
  7. line, it appeared that it would be woken up for the client's close, not
  8. read all data (missing LF), then wait for a subsequent call, and would only
  9. be woken up on client timeout to finish the read. The reason is that we
  10. preset SI_FL_WAIT_DATA in the stream-interface's flags to avoid a fast loop,
  11. but there's nothing which can remove this flag until there's a read operation.
  12. We must definitely remove it in stream_int_notify() each time we're called
  13. with CF_SHUTW_NOW because we know there will be no more subsequent read
  14. and we don't want an applet which keeps the WANT_GET flag to block on this.
  15. This fix should be backported to 1.7 and 1.6 though it's uncertain whether
  16. cli, peers, lua or spoe really are affected there.
  17. (cherry picked from commit 8cf9c8e663fa468fa2380eddecd671172ff63868)
  18. ---
  19. src/stream_interface.c | 6 +++++-
  20. 1 file changed, 5 insertions(+), 1 deletion(-)
  21. diff --git a/src/stream_interface.c b/src/stream_interface.c
  22. index faeceb9..758aec7 100644
  23. --- a/src/stream_interface.c
  24. +++ b/src/stream_interface.c
  25. @@ -455,9 +455,13 @@ void stream_int_notify(struct stream_interface *si)
  26. oc->wex = TICK_ETERNITY;
  27. }
  28. - /* indicate that we may be waiting for data from the output channel */
  29. + /* indicate that we may be waiting for data from the output channel or
  30. + * we're about to close and can't expect more data if SHUTW_NOW is there.
  31. + */
  32. if ((oc->flags & (CF_SHUTW|CF_SHUTW_NOW)) == 0 && channel_may_recv(oc))
  33. si->flags |= SI_FL_WAIT_DATA;
  34. + else if ((oc->flags & (CF_SHUTW|CF_SHUTW_NOW)) == CF_SHUTW_NOW)
  35. + si->flags &= ~SI_FL_WAIT_DATA;
  36. /* update OC timeouts and wake the other side up if it's waiting for room */
  37. if (oc->flags & CF_WRITE_ACTIVITY) {
  38. --
  39. 2.10.2