Note that there are some explanatory texts on larger screens.

plurals
  1. POhow does putty detect if xfer is backing up?
    primarykey
    data
    text
    <p>So I'm trying to understand how PuTTY is implementing SCP and have a few questions.</p> <p>First, here's a copy of an older and (imho) easier to read version of PuTTY's SCP implementation:</p> <p><a href="https://github.com/Yasushi/putty/blob/4eeae4a39bc9faf539b8f819c12b1d1b9f22fc86/scp.c" rel="nofollow">https://github.com/Yasushi/putty/blob/4eeae4a39bc9faf539b8f819c12b1d1b9f22fc86/scp.c</a></p> <p>Here's the function that sends data:</p> <pre><code>int scp_send_filedata(char *data, int len) { int bufsize = back-&gt;send(data, len); /* * If the network transfer is backing up - that is, the remote * site is not accepting data as fast as we can produce it - * then we must loop on network events until we have space in * the buffer again. */ while (bufsize &gt; MAX_SCP_BUFSIZE) { if (!scp_process_network_event()) return 1; bufsize = back-&gt;sendbuffer(); } return 0; } </code></pre> <p>Here's scp_process_network_event:</p> <pre><code>static int scp_process_network_event(void) { fd_set readfds; FD_ZERO(&amp;readfds); FD_SET(scp_ssh_socket, &amp;readfds); if (select(1, &amp;readfds, NULL, NULL, NULL) &lt; 0) return 0; /* doom */ select_result((WPARAM) scp_ssh_socket, (LPARAM) FD_READ); return 1; } </code></pre> <p>So scp_process_network_event does a select() system call, blocking until a write operation wouldn't block?</p> <p>I'm thinking back->sendbuffer and back->send correspond to this:</p> <p><a href="https://github.com/Yasushi/putty/blob/4eeae4a39bc9faf539b8f819c12b1d1b9f22fc86/ssh.c" rel="nofollow">https://github.com/Yasushi/putty/blob/4eeae4a39bc9faf539b8f819c12b1d1b9f22fc86/ssh.c</a></p> <pre><code>/* * Called to send data down the Telnet connection. */ static int ssh_send(char *buf, int len) { if (s == NULL || ssh_protocol == NULL) return 0; ssh_protocol(buf, len, 0); return ssh_sendbuffer(); } /* * Called to query the current amount of buffered stdin data. */ static int ssh_sendbuffer(void) { int override_value; if (s == NULL || ssh_protocol == NULL) return 0; /* * If the SSH socket itself has backed up, add the total backup * size on that to any individual buffer on the stdin channel. */ override_value = 0; if (ssh_throttled_all) override_value = ssh_overall_bufsize; if (ssh_version == 1) { return override_value; } else if (ssh_version == 2) { if (!mainchan || mainchan-&gt;closes &gt; 0) return override_value; else return override_value + bufchain_size(&amp;mainchan-&gt;v.v2.outbuffer); } return 0; } </code></pre> <p>I'm not completely sure on that though and tbh I'm not very good at C either :(</p> <p>Anyway it's not entirely clear to me what bufsize is supposed to be.</p> <p>Any ideas?</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload