| ... | ... | @@ -923,20 +923,22 @@ pub fn readvAdvanced(c: *Client, stream: anytype, iovecs: []const std.os.iovec) |
| 923 | 923 | if (partial_cleartext.len > 0) { |
| 924 | 924 | const amt = @intCast(u15, vp.put(partial_cleartext)); |
| 925 | 925 | c.partial_cleartext_idx += amt; |
| 926 | | if (amt < partial_cleartext.len) { |
| 927 | | // We still have cleartext left so we cannot issue another read() call yet. |
| 928 | | assert(vp.total == amt); |
| 929 | | return amt; |
| 926 | |
| 927 | if (c.partial_ciphertext_end == c.partial_ciphertext_idx) { |
| 928 | // The buffer is now empty. |
| 929 | c.partial_cleartext_idx = 0; |
| 930 | c.partial_ciphertext_idx = 0; |
| 931 | c.partial_ciphertext_end = 0; |
| 930 | 932 | } |
| 933 | |
| 931 | 934 | if (c.received_close_notify) { |
| 932 | 935 | c.partial_ciphertext_end = 0; |
| 933 | 936 | assert(vp.total == amt); |
| 934 | 937 | return amt; |
| 935 | | } |
| 936 | | if (c.partial_ciphertext_end == c.partial_ciphertext_idx) { |
| 937 | | c.partial_cleartext_idx = 0; |
| 938 | | c.partial_ciphertext_idx = 0; |
| 939 | | c.partial_ciphertext_end = 0; |
| 938 | } else if (amt <= partial_cleartext.len) { |
| 939 | // We don't need more data, so don't call read. |
| 940 | assert(vp.total == amt); |
| 941 | return amt; |
| 940 | 942 | } |
| 941 | 943 | } |
| 942 | 944 | |