╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ serve_ssh_protocol.zig ───────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
1773 1774 /// Send a CHANNEL_WINDOW_ADJUST if our receive window has dipped below half 1775 /// of the initial value. Used both for the pre-session discard path and by 1776 /// SessionCtx after it consumes a CHANNEL_DATA payload. 1777 fn maybeRefillRecvWindow( 1778 io: std.Io, 1779 allocator: std.mem.Allocator, 1780 sc_cipher: *Cipher, 1781 writer: *std.Io.Writer, 1782 ch: *Channel, 1783 ) !void { 1784 if (ch.local_window >= initial_recv_window / 2) return; 1785 const add = initial_recv_window - ch.local_window; 1786 ch.local_window += add; 1787 var adj: std.ArrayList(u8) = .empty; 1788 defer adj.deinit(allocator); 1789 try adj.append(allocator, SSH_MSG_CHANNEL_WINDOW_ADJUST); 1790 try writeU32(&adj, allocator, ch.remote_id); 1791 try writeU32(&adj, allocator, add); 1792 try sc_cipher.writePacket(io, allocator, writer, adj.items); 1793 } 1794 1795 pub fn writeU32(buf: *std.ArrayList(u8), allocator: std.mem.Allocator, value: u32) !void { 1796 var bytes: [4]u8 = undefined; 1797 std.mem.writeInt(u32, &bytes, value, .big); 1798 try buf.appendSlice(allocator, &bytes); 1799 } 1800