geom_gate userland utility improvements
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

175 lines
6.1 KiB

  1. Things TODO
  2. ===========
  3. * Fix the numerous malloc+copy operations for sending data, see "Buffering
  4. Improvements" below for details
  5. * make sure the windowing code adapts better to slow situations so that it
  6. doesn't then use as much memory as today. Possibly by an app-controllable
  7. "Window mode"?
  8. * Decrease the number of mallocs. Everywhere. Will get easier once the
  9. buffering improvements have been done.
  10. * Use SO_NOSIGPIPE for Mac OS/BSD systems where MSG_NOSIGNAL doesn't
  11. exist/work
  12. * Extend the test suite to actually test lots of aspects of libssh2
  13. * Fix all compiler warnings (some can't be done without API changes)
  14. * Expose error messages sent by the server
  15. * select() is troublesome with libssh2 when using multiple channels over
  16. the same session. See "New Transport API" below for more details.
  17. At next SONAME bump
  18. ===================
  19. * stop using #defined macros as part of the official API. The macros should
  20. either be turned into real functions or discarded from the API.
  21. * fix the parts of the API where object pointers and function pointers are
  22. mixed like libssh2_session_callback_set()
  23. * remove the following functions from the API/ABI
  24. libssh2_base64_decode()
  25. libssh2_session_flag()
  26. libssh2_channel_handle_extended_data()
  27. libssh2_channel_receive_window_adjust()
  28. libssh2_poll()
  29. libssh2_poll_channel_read()
  30. libssh2_session_startup() (libssh2_session_handshake() is the replacement)
  31. libssh2_banner_set() (libssh2_session_banner_set() is the repacement)
  32. * Rename a few function:
  33. libssh2_hostkey_hash => libssh2_session_hostkey_hash
  34. libssh2_banner_set => libssh2_session_banner_set
  35. * change 'int' to 'libssh2_socket_t' in the public API for sockets.
  36. * Use 'size_t' for string lengths in all functions.
  37. * Add a comment field to struct libssh2_knownhost.
  38. * remove the existing libssh2_knownhost_add() function and rename
  39. libssh2_knownhost_addc to become the new libssh2_knownhost_add instead
  40. * remove the existing libssh2_scp_send_ex() function and rename
  41. libssh2_scp_send64 to become the new libssh2_scp_send instead.
  42. * remove the existing libssh2_knownhost_check() functin and rename
  43. libssh2_knownhost_checkp() to become the new libssh2_knownhost_check instead
  44. Buffering Improvements
  45. ======================
  46. transport_write
  47. - If this function gets called with a total packet size that is larger than
  48. 32K, it should create more than one SSH packet so that it keeps the largest
  49. one below 32K
  50. sftp_write
  51. - should not copy/allocate anything for the data, only create a header chunk
  52. and pass on the payload data to channel_write "pointed to"
  53. New Transport API
  54. =================
  55. THE PROBLEM
  56. The problem in a nutshell is that when an application opens up multiple
  57. channels over a single session, those are all using the same socket. If the
  58. application is then using select() to wait for traffic (like any sensible app
  59. does) and wants to act on the data when select() tells there is something to
  60. for example read, what does an application do?
  61. With our current API, you have to loop over all the channels and read from
  62. them to see if they have data. This effectively makes blocking reads
  63. impossible. If the app has many channels in a setup like this, it even becomes
  64. slow. (The original API had the libssh2_poll_channel_read() and libssh2_poll()
  65. to somewhat overcome this hurdle, but they too have pretty much the same
  66. problems plus a few others.)
  67. Traffic in the other direction is similarly limited: the app has to try
  68. sending to all channels, even though some of them may very well not accept any
  69. data at that point.
  70. A SOLUTION
  71. I suggest we introduce two new helper functions:
  72. libssh2_transport_read()
  73. - Read "a bunch" of data from the given socket and returns information to the
  74. app about what channels that are now readable (ie they will not block when
  75. read from). The function can be called over and over and it will repeatedly
  76. return info about what channels that are readable at that moment.
  77. libssh2_transport_write()
  78. - Returns information about what channels that are writable, in the sense
  79. that they have windows set from the remote side that allows data to get
  80. sent. Writing to one of those channels will not block. Of course, the
  81. underlying socket may only accept a certain amount of data, so at the first
  82. short return, nothing more should be attempted to get sent until select()
  83. (or equivalent) has been used on the master socket again.
  84. I haven't yet figured out a sensible API for how these functions should return
  85. that info, but if we agree on the general principles I guess we can work that
  86. out.
  87. VOLUNTARY
  88. I wanted to mention that these two helper functions would not be mandatory
  89. in any way. They would just be there for those who want them, and existing
  90. programs can remain using the old functions only if they prefer to.
  91. New SFTP API
  92. ============
  93. PURPOSE
  94. Provide API functions that explicitly tells at once that a (full) SFTP file
  95. transfer is wanted, to allow libssh2 to leverage on that knowledge to speed
  96. up things internally. It can for example do read ahead, buffer writes (merge
  97. small writes into larger chunks), better tune the SSH window and more. This
  98. sort of API is already provided for SCP transfers.
  99. API
  100. New functions:
  101. LIBSSH2_SFTP_HANDLE *libssh2_sftp_send(SFTP_SESSION *sftp,
  102. uint64_t filesize,
  103. char *remote_path,
  104. size_t remote_path_len,
  105. long mode);
  106. Tell libssh2 that a local file with a given size is about to get sent to
  107. the SFTP server.
  108. LIBSSH2_SFTP_HANDLE *libssh2_sftp_recv();
  109. Tell libssh2 that a remote file is requested to get downloaded from the SFTP
  110. server.
  111. Only the setup of the file transfer is different from an application's point
  112. of view. Depending on direction of the transfer(s), the following already
  113. existing functions should then be used until the transfer is complete:
  114. libssh2_sftp_read()
  115. libssh2_sftp_write()
  116. HOW TO USE
  117. 1. Setup the transfer using one of the two new functions.
  118. 2. Loop through the reading or writing of data.
  119. 3. Cleanup the transfer