|
| 1 | +From fb5b9a505c673c8f6c0dc2f636dfc34935496abc Mon Sep 17 00:00:00 2001 |
| 2 | +From: Stefan Eissing < [email protected]> |
| 3 | +Date: Fri, 29 Sep 2023 14:17:08 +0200 |
| 4 | +Subject: [PATCH] h2: testcase and fix for pausing h2 streams |
| 5 | + |
| 6 | +- refs #11982 where it was noted that paused transfers may |
| 7 | + close successfully without delivering the complete data |
| 8 | +- made sample poc into tests/http/client/h2-pausing.c and |
| 9 | + added test_02_27 to reproduce |
| 10 | + |
| 11 | +Closes #11989 |
| 12 | +Fixes #11982 |
| 13 | +Reported-by: Harry Sintonen |
| 14 | +--- |
| 15 | + lib/transfer.c | 23 ++- |
| 16 | + 1 file changed, 23 insertions(+), 1 deletions(-) |
| 17 | + create mode 100644 tests/http/clients/h2-pausing.c |
| 18 | + |
| 19 | +diff --git a/lib/transfer.c b/lib/transfer.c |
| 20 | +index d0602b875..548fbb9e3 100644 |
| 21 | +--- a/lib/transfer.c |
| 22 | ++++ b/lib/transfer.c |
| 23 | +@@ -1050,6 +1050,19 @@ static CURLcode readwrite_upload(struct Curl_easy *data, |
| 24 | + return CURLE_OK; |
| 25 | + } |
| 26 | + |
| 27 | ++static int select_bits_paused(struct Curl_easy *data, int select_bits) |
| 28 | ++{ |
| 29 | ++ /* See issue #11982: we really need to be careful not to progress |
| 30 | ++ * a transfer direction when that direction is paused. Not all parts |
| 31 | ++ * of our state machine are handling PAUSED transfers correctly. So, we |
| 32 | ++ * do not want to go there. |
| 33 | ++ * NOTE: we are only interested in PAUSE, not HOLD. */ |
| 34 | ++ return (((select_bits & CURL_CSELECT_IN) && |
| 35 | ++ (data->req.keepon & KEEP_RECV_PAUSE)) || |
| 36 | ++ ((select_bits & CURL_CSELECT_OUT) && |
| 37 | ++ (data->req.keepon & KEEP_SEND_PAUSE))); |
| 38 | ++} |
| 39 | ++ |
| 40 | + /* |
| 41 | + * Curl_readwrite() is the low-level function to be called when data is to |
| 42 | + * be read and written to/from the connection. |
| 43 | +@@ -1068,12 +1081,20 @@ CURLcode Curl_readwrite(struct connectdata *conn, |
| 44 | + int didwhat = 0; |
| 45 | + int select_bits; |
| 46 | + |
| 47 | +- |
| 48 | + if(data->state.dselect_bits) { |
| 49 | ++ if(select_bits_paused(data, data->state.dselect_bits)) { |
| 50 | ++ /* leave the bits unchanged, so they'll tell us what to do when |
| 51 | ++ * this transfer gets unpaused. */ |
| 52 | ++ DEBUGF(infof(data, "readwrite, dselect_bits, early return on PAUSED")); |
| 53 | ++ result = CURLE_OK; |
| 54 | ++ goto out; |
| 55 | ++ } |
| 56 | + select_bits = data->state.dselect_bits; |
| 57 | + data->state.dselect_bits = 0; |
| 58 | + } |
| 59 | + else if(conn->cselect_bits) { |
| 60 | ++ /* CAVEAT: adding `select_bits_paused()` check here makes test640 hang |
| 61 | ++ * (among others). Which hints at strange state handling in FTP land... */ |
| 62 | + select_bits = conn->cselect_bits; |
| 63 | + conn->cselect_bits = 0; |
| 64 | + } |
| 65 | +-- |
| 66 | +2.42.0.windows.2 |
| 67 | + |
0 commit comments