mirror of
https://github.com/curl/curl.git
synced 2026-08-25 04:43:33 +03:00
lib: keepon improving
Improve the name, type and handling of `data->req.keepon`: - Rename `keepon` to `io_flags` - make `io_flags` and `uint8_t` and reposition in struct - Rename `KEEP_*` defines to `REQ_IO_*`, move to request.h - Replace all direct bit tests to `CURL_REQ_WANT_*` use - Replace all direct bit manipulations with new macros Closes #20905
This commit is contained in:
parent
9325eb5fc4
commit
f50446f6da
13 changed files with 78 additions and 79 deletions
|
|
@ -696,8 +696,8 @@ static void myssh_block2waitfor(struct connectdata *conn,
|
|||
int dir = ssh_get_poll_flags(sshc->ssh_session);
|
||||
/* translate the libssh define bits into our own bit defines */
|
||||
sshc->waitfor =
|
||||
((dir & SSH_READ_PENDING) ? KEEP_RECV : 0) |
|
||||
((dir & SSH_WRITE_PENDING) ? KEEP_SEND : 0);
|
||||
((dir & SSH_READ_PENDING) ? REQ_IO_RECV : 0) |
|
||||
((dir & SSH_WRITE_PENDING) ? REQ_IO_SEND : 0);
|
||||
}
|
||||
else
|
||||
sshc->waitfor = 0;
|
||||
|
|
@ -1084,7 +1084,7 @@ static int myssh_in_UPLOAD_INIT(struct Curl_easy *data,
|
|||
/* upload data */
|
||||
Curl_xfer_setup_send(data, FIRSTSOCKET);
|
||||
|
||||
/* not set by Curl_xfer_setup to preserve keepon bits */
|
||||
/* not set by Curl_xfer_setup to preserve io_flags */
|
||||
data->conn->recv_idx = FIRSTSOCKET;
|
||||
|
||||
/* since we do not really wait for anything at this point, we want the
|
||||
|
|
@ -1205,7 +1205,7 @@ static int myssh_in_SFTP_DOWNLOAD_STAT(struct Curl_easy *data,
|
|||
}
|
||||
Curl_xfer_setup_recv(data, FIRSTSOCKET, data->req.size);
|
||||
|
||||
/* not set by Curl_xfer_setup to preserve keepon bits */
|
||||
/* not set by Curl_xfer_setup to preserve io_flags */
|
||||
data->conn->send_idx = 0;
|
||||
|
||||
sshc->sftp_recv_state = 0;
|
||||
|
|
@ -1736,7 +1736,7 @@ static int myssh_SSH_SCP_DOWNLOAD(struct Curl_easy *data,
|
|||
data->req.maxdownload = bytecount;
|
||||
Curl_xfer_setup_recv(data, FIRSTSOCKET, bytecount);
|
||||
|
||||
/* not set by Curl_xfer_setup to preserve keepon bits */
|
||||
/* not set by Curl_xfer_setup to preserve io_flags */
|
||||
data->conn->send_idx = 0;
|
||||
|
||||
myssh_to(data, sshc, SSH_STOP);
|
||||
|
|
@ -2159,7 +2159,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data,
|
|||
/* upload data */
|
||||
Curl_xfer_setup_send(data, FIRSTSOCKET);
|
||||
|
||||
/* not set by Curl_xfer_setup to preserve keepon bits */
|
||||
/* not set by Curl_xfer_setup to preserve io_flags */
|
||||
data->conn->recv_idx = FIRSTSOCKET;
|
||||
|
||||
myssh_to(data, sshc, SSH_STOP);
|
||||
|
|
@ -2268,12 +2268,12 @@ static CURLcode myssh_pollset(struct Curl_easy *data,
|
|||
if(!sshc || (sock == CURL_SOCKET_BAD))
|
||||
return CURLE_FAILED_INIT;
|
||||
|
||||
waitfor = sshc->waitfor ? sshc->waitfor : data->req.keepon;
|
||||
waitfor = sshc->waitfor ? sshc->waitfor : data->req.io_flags;
|
||||
if(waitfor) {
|
||||
int flags = 0;
|
||||
if(waitfor & KEEP_RECV)
|
||||
if(waitfor & REQ_IO_RECV)
|
||||
flags |= CURL_POLL_IN;
|
||||
if(waitfor & KEEP_SEND)
|
||||
if(waitfor & REQ_IO_SEND)
|
||||
flags |= CURL_POLL_OUT;
|
||||
DEBUGASSERT(flags);
|
||||
CURL_TRC_SSH(data, "pollset, flags=%x", flags);
|
||||
|
|
@ -2596,7 +2596,7 @@ static CURLcode myssh_done(struct Curl_easy *data,
|
|||
if(Curl_pgrsDone(data))
|
||||
return CURLE_ABORTED_BY_CALLBACK;
|
||||
|
||||
data->req.keepon = 0; /* clear all bits */
|
||||
CURL_REQ_CLEAR_IO(data);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1054,7 +1054,7 @@ static CURLcode sftp_upload_init(struct Curl_easy *data,
|
|||
/* upload data */
|
||||
Curl_xfer_setup_send(data, FIRSTSOCKET);
|
||||
|
||||
/* not set by Curl_xfer_setup to preserve keepon bits */
|
||||
/* not set by Curl_xfer_setup to preserve io_flags */
|
||||
data->conn->recv_idx = FIRSTSOCKET;
|
||||
|
||||
/* since we do not really wait for anything at this point, we want the
|
||||
|
|
@ -1358,7 +1358,7 @@ static CURLcode sftp_download_stat(struct Curl_easy *data,
|
|||
}
|
||||
Curl_xfer_setup_recv(data, FIRSTSOCKET, data->req.size);
|
||||
|
||||
/* not set by Curl_xfer_setup to preserve keepon bits */
|
||||
/* not set by Curl_xfer_setup to preserve io_flags */
|
||||
data->conn->send_idx = 0;
|
||||
|
||||
myssh_to(data, sshc, SSH_STOP);
|
||||
|
|
@ -2265,7 +2265,7 @@ static CURLcode ssh_state_scp_download_init(struct Curl_easy *data,
|
|||
data->req.maxdownload = (curl_off_t)sb.st_size;
|
||||
Curl_xfer_setup_recv(data, FIRSTSOCKET, bytecount);
|
||||
|
||||
/* not set by Curl_xfer_setup to preserve keepon bits */
|
||||
/* not set by Curl_xfer_setup to preserve io_flags */
|
||||
data->conn->send_idx = 0;
|
||||
|
||||
myssh_to(data, sshc, SSH_STOP);
|
||||
|
|
@ -2411,7 +2411,7 @@ static CURLcode ssh_state_scp_upload_init(struct Curl_easy *data,
|
|||
Curl_pgrsSetUploadSize(data, data->state.infilesize);
|
||||
Curl_xfer_setup_send(data, FIRSTSOCKET);
|
||||
|
||||
/* not set by Curl_xfer_setup to preserve keepon bits */
|
||||
/* not set by Curl_xfer_setup to preserve io_flags */
|
||||
data->conn->recv_idx = FIRSTSOCKET;
|
||||
|
||||
myssh_to(data, sshc, SSH_STOP);
|
||||
|
|
@ -3023,12 +3023,12 @@ static CURLcode ssh_pollset(struct Curl_easy *data,
|
|||
if(!sshc || (sock == CURL_SOCKET_BAD))
|
||||
return CURLE_FAILED_INIT;
|
||||
|
||||
waitfor = sshc->waitfor ? sshc->waitfor : data->req.keepon;
|
||||
waitfor = sshc->waitfor ? sshc->waitfor : data->req.io_flags;
|
||||
if(waitfor) {
|
||||
int flags = 0;
|
||||
if(waitfor & KEEP_RECV)
|
||||
if(waitfor & REQ_IO_RECV)
|
||||
flags |= CURL_POLL_IN;
|
||||
if(waitfor & KEEP_SEND)
|
||||
if(waitfor & REQ_IO_SEND)
|
||||
flags |= CURL_POLL_OUT;
|
||||
DEBUGASSERT(flags);
|
||||
CURL_TRC_SSH(data, "pollset, flags=%x", flags);
|
||||
|
|
@ -3057,8 +3057,9 @@ static void ssh_block2waitfor(struct Curl_easy *data,
|
|||
dir = libssh2_session_block_directions(sshc->ssh_session);
|
||||
if(dir) {
|
||||
/* translate the libssh2 define bits into our own bit defines */
|
||||
sshc->waitfor = ((dir & LIBSSH2_SESSION_BLOCK_INBOUND) ? KEEP_RECV : 0) |
|
||||
((dir & LIBSSH2_SESSION_BLOCK_OUTBOUND) ? KEEP_SEND : 0);
|
||||
sshc->waitfor =
|
||||
((dir & LIBSSH2_SESSION_BLOCK_INBOUND) ? REQ_IO_RECV : 0) |
|
||||
((dir & LIBSSH2_SESSION_BLOCK_OUTBOUND) ? REQ_IO_SEND : 0);
|
||||
}
|
||||
}
|
||||
if(!dir)
|
||||
|
|
@ -3519,7 +3520,7 @@ static CURLcode ssh_done(struct Curl_easy *data, CURLcode status)
|
|||
if(Curl_pgrsDone(data))
|
||||
return CURLE_ABORTED_BY_CALLBACK;
|
||||
|
||||
data->req.keepon = 0; /* clear all bits */
|
||||
CURL_REQ_CLEAR_IO(data);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ struct ssh_conn {
|
|||
int secondCreateDirs; /* counter use by the code to see if the
|
||||
second attempt has been made to change
|
||||
to/create a directory */
|
||||
int waitfor; /* KEEP_RECV/KEEP_SEND bits overriding
|
||||
int waitfor; /* REQ_IO_RECV/REQ_IO_SEND bits overriding
|
||||
pollset given flags */
|
||||
char *slash_pos; /* used by the SFTP_CREATE_DIRS state */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue