Helper: Write all pending TLS data (including close_notify) to outgoing buffer/BIO
(&self, conn: &mut TlsConnection, vm: &VirtualMachine)
| 4269 | |
| 4270 | // Helper: Write all pending TLS data (including close_notify) to outgoing buffer/BIO |
| 4271 | fn write_pending_tls(&self, conn: &mut TlsConnection, vm: &VirtualMachine) -> PyResult<()> { |
| 4272 | // First, flush any previously pending TLS output |
| 4273 | // Must succeed before sending new data to maintain order |
| 4274 | self.flush_pending_tls_output(vm, None)?; |
| 4275 | |
| 4276 | loop { |
| 4277 | if !conn.wants_write() { |
| 4278 | break; |
| 4279 | } |
| 4280 | |
| 4281 | let mut buf = vec![0u8; SSL3_RT_MAX_PLAIN_LENGTH]; |
| 4282 | let written = conn |
| 4283 | .write_tls(&mut buf.as_mut_slice()) |
| 4284 | .map_err(|e| vm.new_os_error(format!("TLS write failed: {e}")))?; |
| 4285 | |
| 4286 | if written == 0 { |
| 4287 | break; |
| 4288 | } |
| 4289 | |
| 4290 | // Send TLS data, saving unsent bytes to pending buffer if needed |
| 4291 | self.send_tls_output(buf[..written].to_vec(), vm)?; |
| 4292 | } |
| 4293 | |
| 4294 | Ok(()) |
| 4295 | } |
| 4296 | |
| 4297 | // Helper: Try to read incoming data from socket/BIO |
| 4298 | // Returns true if peer closed connection (with or without close_notify) |
no test coverage detected