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