1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-11-20 02:42:09 +03:00

Configurable session read timeout (#892)

This set of changes provides a mechanism to runtime-configure the
previously #define'd timeout for reading packets from a session. The
intention here is to also extend libcurl to be able to use this
interface so that when fetching from sftp servers which are very slow
to return directory listings, connections do not time-out so much.

* Add new field to session to hold configurable read timeout

* Updated `_libssh2_packet_require()`, `_libssh2_packet_requirev()`,
  and `sftp_packet_requirev()` to use new field in session structure

* Updated docs for API functions to set/get read timeout field in
  session structure

* Updated `libssh2.h` to declare the get/set read timeout functions

Co-authored-by: Jon Axtell <jon.axtell@codethink.co.uk>
Credit: Daniel Silverstone
This commit is contained in:
Daniel Silverstone
2023-04-05 14:53:53 +01:00
committed by GitHub
parent a7d60c62ab
commit c20c81ab10
7 changed files with 77 additions and 6 deletions

View File

@@ -883,6 +883,9 @@ struct _LIBSSH2_SESSION
int keepalive_interval;
int keepalive_want_reply;
time_t keepalive_last_sent;
/* Configurable timeout for packets. Replaces LIBSSH2_READ_TIMEOUT */
long packet_read_timeout;
};
/* session.state bits */
@@ -1089,8 +1092,8 @@ ssize_t _libssh2_recv(libssh2_socket_t socket, void *buffer,
ssize_t _libssh2_send(libssh2_socket_t socket, const void *buffer,
size_t length, int flags, void **abstract);
#define LIBSSH2_READ_TIMEOUT 60 /* generic timeout in seconds used when
waiting for more data to arrive */
#define LIBSSH2_DEFAULT_READ_TIMEOUT 60 /* generic timeout in seconds used when
waiting for more data to arrive */
int _libssh2_kex_exchange(LIBSSH2_SESSION * session, int reexchange,