#293: error in direct_tcpip.c example ----------------------+-------------------- Reporter: bbo | Owner: Type: defect | Status: new Priority: normal | Milestone: 1.5.0 Component: examples | Version: 1.4.2 Keywords: | Blocked By: Blocks: | ----------------------+-------------------- The example direct_tcpip.c doesn't take care of EAGAIN case return by libssh2_channel_write. This can lead to non transmitted file when this error is raised, while this should just delay the transmission because the socket are busy. To see the error, just run a process with high priority on the receiver of data trasnmitted through the libssh2_channel_write. Solution is just to retry the call to libssh2_channel_write one (or several) other time.
Here under is the current code taken from the git repo today: Git repo code: wr = 0; do { i = libssh2_channel_write(channel, buf, len); if (i < 0) { fprintf(stderr, "libssh2_channel_write: %d\n", i); goto shutdown; } wr += i; } while(i > 0 && wr < len); Code patched: wr = 0; do { i = libssh2_channel_write(channel, buf, len); if (i >= 0) { wr += i; } else if(i == LIBSSH2_ERROR_EAGAIN) { fprintf(stderr, "libssh2_channel_write: LIBSSH2_ERROR_EAGAIN, retry to write\n"); } else { fprintf(stderr, "libssh2_channel_write: %d\n", i); goto shutdown; } } while(wr < len); -- Ticket URL: <https://trac.libssh2.org/ticket/293> libssh2 <https://trac.libssh2.org/> C library for writing portable SSH2 clients _______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel