changing the first handler->getsock method

This commit is contained in:
Stefan Eissing 2025-08-04 13:40:35 +02:00
parent cab43414f9
commit 1dffb13e93
No known key found for this signature in database
24 changed files with 181 additions and 73 deletions

View file

@ -128,6 +128,8 @@ CURLcode sftp_perform(struct Curl_easy *data,
static unsigned int myssh_getsock(struct Curl_easy *data,
struct connectdata *conn,
curl_socket_t *sock);
static CURLcode myssh_pollset(struct Curl_easy *data,
struct easy_pollset *ps);
static void myssh_block2waitfor(struct connectdata *conn,
struct ssh_conn *sshc,
bool block);
@ -149,7 +151,7 @@ const struct Curl_handler Curl_handler_scp = {
myssh_connect, /* connect_it */
myssh_multi_statemach, /* connecting */
scp_doing, /* doing */
myssh_getsock, /* proto_getsock */
myssh_pollset, /* proto_pollset */
myssh_getsock, /* doing_getsock */
ZERO_NULL, /* domore_getsock */
myssh_getsock, /* perform_getsock */
@ -178,7 +180,7 @@ const struct Curl_handler Curl_handler_sftp = {
myssh_connect, /* connect_it */
myssh_multi_statemach, /* connecting */
sftp_doing, /* doing */
myssh_getsock, /* proto_getsock */
myssh_pollset, /* proto_pollset */
myssh_getsock, /* doing_getsock */
ZERO_NULL, /* domore_getsock */
myssh_getsock, /* perform_getsock */
@ -2412,6 +2414,21 @@ static unsigned int myssh_getsock(struct Curl_easy *data,
return bitmap;
}
static CURLcode myssh_pollset(struct Curl_easy *data,
struct easy_pollset *ps)
{
int flags = 0;
if(data->conn->waitfor & KEEP_RECV)
flags |= CURL_POLL_IN;
if(data->conn->waitfor & KEEP_SEND)
flags |= CURL_POLL_OUT;
if(!data->conn->waitfor)
flags |= CURL_POLL_OUT;
return flags ?
Curl_pollset_change(data, ps, data->conn->sock[FIRSTSOCKET], flags, 0) :
CURLE_OK;
}
static void myssh_block2waitfor(struct connectdata *conn,
struct ssh_conn *sshc,
bool block)

View file

@ -102,6 +102,8 @@ static CURLcode sftp_perform(struct Curl_easy *data, bool *connected,
static unsigned int ssh_getsock(struct Curl_easy *data,
struct connectdata *conn,
curl_socket_t *sock);
static CURLcode ssh_pollset(struct Curl_easy *data,
struct easy_pollset *ps);
static CURLcode ssh_setup_connection(struct Curl_easy *data,
struct connectdata *conn);
static void ssh_attach(struct Curl_easy *data, struct connectdata *conn);
@ -120,7 +122,7 @@ const struct Curl_handler Curl_handler_scp = {
ssh_connect, /* connect_it */
ssh_multi_statemach, /* connecting */
scp_doing, /* doing */
ssh_getsock, /* proto_getsock */
ssh_pollset, /* proto_pollset */
ssh_getsock, /* doing_getsock */
ZERO_NULL, /* domore_getsock */
ssh_getsock, /* perform_getsock */
@ -151,7 +153,7 @@ const struct Curl_handler Curl_handler_sftp = {
ssh_connect, /* connect_it */
ssh_multi_statemach, /* connecting */
sftp_doing, /* doing */
ssh_getsock, /* proto_getsock */
ssh_pollset, /* proto_pollset */
ssh_getsock, /* doing_getsock */
ZERO_NULL, /* domore_getsock */
ssh_getsock, /* perform_getsock */
@ -3106,6 +3108,19 @@ static unsigned int ssh_getsock(struct Curl_easy *data,
return bitmap;
}
static CURLcode ssh_pollset(struct Curl_easy *data,
struct easy_pollset *ps)
{
int flags = 0;
if(data->conn->waitfor & KEEP_RECV)
flags |= CURL_POLL_IN;
if(data->conn->waitfor & KEEP_SEND)
flags |= CURL_POLL_OUT;
return flags ?
Curl_pollset_change(data, ps, data->conn->sock[FIRSTSOCKET], flags, 0) :
CURLE_OK;
}
/*
* When one of the libssh2 functions has returned LIBSSH2_ERROR_EAGAIN this
* function is used to figure out in what direction and stores this info so

View file

@ -69,6 +69,8 @@ static CURLcode wsftp_disconnect(struct Curl_easy *data,
static unsigned int wssh_getsock(struct Curl_easy *data,
struct connectdata *conn,
curl_socket_t *sock);
static CURLcode wssh_pollset(struct Curl_easy *data,
struct easy_pollset *ps);
static CURLcode wssh_setup_connection(struct Curl_easy *data,
struct connectdata *conn);
static void wssh_sshc_cleanup(struct ssh_conn *sshc);
@ -87,7 +89,7 @@ const struct Curl_handler Curl_handler_scp = {
wssh_connect, /* connect_it */
wssh_multi_statemach, /* connecting */
wscp_doing, /* doing */
wssh_getsock, /* proto_getsock */
wssh_pollset, /* proto_pollset */
wssh_getsock, /* doing_getsock */
ZERO_NULL, /* domore_getsock */
wssh_getsock, /* perform_getsock */
@ -118,7 +120,7 @@ const struct Curl_handler Curl_handler_sftp = {
wssh_connect, /* connect_it */
wssh_multi_statemach, /* connecting */
wsftp_doing, /* doing */
wssh_getsock, /* proto_getsock */
wssh_pollset, /* proto_pollset */
wssh_getsock, /* doing_getsock */
ZERO_NULL, /* domore_getsock */
wssh_getsock, /* perform_getsock */
@ -1202,6 +1204,19 @@ static unsigned int wssh_getsock(struct Curl_easy *data,
return bitmap;
}
static CURLcode wssh_pollset(struct Curl_easy *data,
struct easy_pollset *ps)
{
int flags = 0;
if(data->conn->waitfor & KEEP_RECV)
flags |= CURL_POLL_IN;
if(data->conn->waitfor & KEEP_SEND)
flags |= CURL_POLL_OUT;
return flags ?
Curl_pollset_change(data, ps, data->conn->sock[FIRSTSOCKET], flags, 0) :
CURLE_OK;
}
void Curl_ssh_version(char *buffer, size_t buflen)
{
(void)msnprintf(buffer, buflen, "wolfssh/%s", LIBWOLFSSH_VERSION_STRING);