mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-12-02 01:17:52 +03:00
session: Add brackets to ssh_handle_packets_termination().
This commit is contained in:
@@ -515,33 +515,44 @@ int ssh_handle_packets(ssh_session session, int timeout) {
|
|||||||
* @param[in] user User parameter to be passed to fct termination function.
|
* @param[in] user User parameter to be passed to fct termination function.
|
||||||
* @return SSH_OK on success, SSH_ERROR otherwise.
|
* @return SSH_OK on success, SSH_ERROR otherwise.
|
||||||
*/
|
*/
|
||||||
int ssh_handle_packets_termination(ssh_session session, int timeout,
|
int ssh_handle_packets_termination(ssh_session session,
|
||||||
ssh_termination_function fct, void *user){
|
int timeout,
|
||||||
int ret = SSH_OK;
|
ssh_termination_function fct,
|
||||||
|
void *user)
|
||||||
|
{
|
||||||
struct ssh_timestamp ts;
|
struct ssh_timestamp ts;
|
||||||
|
int ret = SSH_OK;
|
||||||
int tm;
|
int tm;
|
||||||
|
|
||||||
if (timeout == SSH_TIMEOUT_USER) {
|
if (timeout == SSH_TIMEOUT_USER) {
|
||||||
if (ssh_is_blocking(session))
|
if (ssh_is_blocking(session)) {
|
||||||
timeout = ssh_make_milliseconds(session->opts.timeout,
|
timeout = ssh_make_milliseconds(session->opts.timeout,
|
||||||
session->opts.timeout_usec);
|
session->opts.timeout_usec);
|
||||||
else
|
} else {
|
||||||
timeout = SSH_TIMEOUT_NONBLOCKING;
|
|
||||||
} else if (timeout == SSH_TIMEOUT_DEFAULT){
|
|
||||||
if(ssh_is_blocking(session))
|
|
||||||
timeout = SSH_TIMEOUT_INFINITE;
|
|
||||||
else
|
|
||||||
timeout = SSH_TIMEOUT_NONBLOCKING;
|
timeout = SSH_TIMEOUT_NONBLOCKING;
|
||||||
}
|
}
|
||||||
|
} else if (timeout == SSH_TIMEOUT_DEFAULT) {
|
||||||
|
if (ssh_is_blocking(session)) {
|
||||||
|
timeout = SSH_TIMEOUT_INFINITE;
|
||||||
|
} else {
|
||||||
|
timeout = SSH_TIMEOUT_NONBLOCKING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ssh_timestamp_init(&ts);
|
ssh_timestamp_init(&ts);
|
||||||
tm = timeout;
|
tm = timeout;
|
||||||
while(!fct(user)) {
|
while(!fct(user)) {
|
||||||
ret = ssh_handle_packets(session, tm);
|
ret = ssh_handle_packets(session, tm);
|
||||||
if(ret == SSH_ERROR)
|
if (ret == SSH_ERROR) {
|
||||||
break;
|
break;
|
||||||
if(ssh_timeout_elapsed(&ts,timeout))
|
}
|
||||||
|
if (ssh_timeout_elapsed(&ts,timeout)) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
tm = ssh_timeout_update(&ts, timeout);
|
tm = ssh_timeout_update(&ts, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user