Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The select is blocking on read. We can't do anything (e.g. send anything) so we have to wait on something turning up to read - once we have read something then we can try to send our queued up data again.</p> <p>It looks like send() puts a buffer of data onto the end an internal linked list of buffers and tries to send it, and sendbuffer() will flush the internal linked list of buffers of any remaining data (e.g. if send() could not send it all due to it backing up).</p> <p>The send() / sendbuffer() methods look like they return the amount of data left to send, e.g. there were 5 buffers of 10 bytes to send, you were only able to send 2 buffers leaving 30 bytes still to be sent in the internal buffer linked list so the send methods would return 30.</p> <p>The important takeaway is that the congestion is detected by looking at the values returned by the send methods - if they return non-zero it means that some of the data remains in the internal send buffer and has not been sent out yet due to congestion presumably.</p> <p>The ssh back-end (ssh.c) shares an API with the plain old telnet back-end so we can derive the API from the telnet.c and wininet.c sources without worrying about the encryption layer. In <a href="https://github.com/Yasushi/putty/blob/4eeae4a39bc9faf539b8f819c12b1d1b9f22fc86/winnet.c#L711" rel="nofollow">wininet.c:711</a> we actually see where send() is finally called on a socket, if this send is successful we call buffchain_consume() to de-queue so many bytes from the start of the buffer linked list (e.g. FIFO queue). This whole function has an outer while loop that continues until the buffer chain is empty (or unless we return out with an error in the middle).</p> <p>It is in this method where the 'bytes successfully sent' paradigm we all know from send() in libc (and hence php) is converted into the 'bytes queued waiting to be sent' paradigm used in the putty code in your examples.</p> <p>Basically you have N bytes of data to be sent, you successfully send() X bytes so you have N-X bytes left to send.</p> <p>The actual subtraction happens in <a href="https://github.com/Yasushi/putty/blob/4eeae4a39bc9faf539b8f819c12b1d1b9f22fc86/misc.c#L127" rel="nofollow">buffchain_consume():127</a> the linked list of buffers stuff are managed by the buffchain_*() methods in that file.</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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