pr12633-fix-mpd-streaming.patch 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. From 3a24ef09af5fe7fdd672dee72ff760f871105a03 Mon Sep 17 00:00:00 2001
  2. From: Stefan Eissing <stefan@eissing.org>
  3. Date: Thu, 4 Jan 2024 10:06:17 +0100
  4. Subject: [PATCH] adjust_pollset fix
  5. - do not add a socket for POLLIN when the transfer does not
  6. want to send (for example is paused).
  7. - refs #12632
  8. ---
  9. lib/cf-socket.c | 2 +-
  10. lib/http2.c | 4 ++--
  11. lib/vquic/curl_ngtcp2.c | 7 ++++---
  12. lib/vquic/curl_quiche.c | 2 +-
  13. 4 files changed, 8 insertions(+), 7 deletions(-)
  14. diff --git a/lib/cf-socket.c b/lib/cf-socket.c
  15. index bd4f0d1e97e2d3..c86aa7e7c2a969 100644
  16. --- a/lib/cf-socket.c
  17. +++ b/lib/cf-socket.c
  18. @@ -1243,7 +1243,7 @@ static void cf_socket_adjust_pollset(struct Curl_cfilter *cf,
  19. if(ctx->sock != CURL_SOCKET_BAD) {
  20. if(!cf->connected)
  21. Curl_pollset_set_out_only(data, ps, ctx->sock);
  22. - else
  23. + else if(CURL_WANT_RECV(data))
  24. Curl_pollset_add_in(data, ps, ctx->sock);
  25. CURL_TRC_CF(data, cf, "adjust_pollset -> %d socks", ps->num);
  26. }
  27. diff --git a/lib/http2.c b/lib/http2.c
  28. index dcc24ea102302c..b7a08607945357 100644
  29. --- a/lib/http2.c
  30. +++ b/lib/http2.c
  31. @@ -2341,8 +2341,8 @@ static void cf_h2_adjust_pollset(struct Curl_cfilter *cf,
  32. bool c_exhaust, s_exhaust;
  33. CF_DATA_SAVE(save, cf, data);
  34. - c_exhaust = !nghttp2_session_get_remote_window_size(ctx->h2);
  35. - s_exhaust = stream && stream->id >= 0 &&
  36. + c_exhaust = want_send && !nghttp2_session_get_remote_window_size(ctx->h2);
  37. + s_exhaust = want_send && stream && stream->id >= 0 &&
  38. !nghttp2_session_get_stream_remote_window_size(ctx->h2,
  39. stream->id);
  40. want_recv = (want_recv || c_exhaust || s_exhaust);
  41. diff --git a/lib/vquic/curl_ngtcp2.c b/lib/vquic/curl_ngtcp2.c
  42. index f4edf2d636ef93..89f690462d640b 100644
  43. --- a/lib/vquic/curl_ngtcp2.c
  44. +++ b/lib/vquic/curl_ngtcp2.c
  45. @@ -1166,9 +1166,10 @@ static void cf_ngtcp2_adjust_pollset(struct Curl_cfilter *cf,
  46. bool c_exhaust, s_exhaust;
  47. CF_DATA_SAVE(save, cf, data);
  48. - c_exhaust = !ngtcp2_conn_get_cwnd_left(ctx->qconn) ||
  49. - !ngtcp2_conn_get_max_data_left(ctx->qconn);
  50. - s_exhaust = stream && stream->id >= 0 && stream->quic_flow_blocked;
  51. + c_exhaust = want_send && (!ngtcp2_conn_get_cwnd_left(ctx->qconn) ||
  52. + !ngtcp2_conn_get_max_data_left(ctx->qconn));
  53. + s_exhaust = want_send && stream && stream->id >= 0 &&
  54. + stream->quic_flow_blocked;
  55. want_recv = (want_recv || c_exhaust || s_exhaust);
  56. want_send = (!s_exhaust && want_send) ||
  57. !Curl_bufq_is_empty(&ctx->q.sendbuf);
  58. diff --git a/lib/vquic/curl_quiche.c b/lib/vquic/curl_quiche.c
  59. index 33c2621dc8bf63..9c4df2df0f6955 100644
  60. --- a/lib/vquic/curl_quiche.c
  61. +++ b/lib/vquic/curl_quiche.c
  62. @@ -1189,7 +1189,7 @@ static void cf_quiche_adjust_pollset(struct Curl_cfilter *cf,
  63. c_exhaust = FALSE; /* Have not found any call in quiche that tells
  64. us if the connection itself is blocked */
  65. - s_exhaust = stream && stream->id >= 0 &&
  66. + s_exhaust = want_send && stream && stream->id >= 0 &&
  67. (stream->quic_flow_blocked || !stream_is_writeable(cf, data));
  68. want_recv = (want_recv || c_exhaust || s_exhaust);
  69. want_send = (!s_exhaust && want_send) ||