1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-30 13:01:23 +03:00

session: Fix an infinite loop in the termination callback.

This happened due to the use of the buggy and obsolete timeout
funtions.
This commit is contained in:
rofl0r
2011-08-10 01:44:47 +02:00
committed by Andreas Schneider
parent 2f87873642
commit 7949f2cdc6

View File

@@ -493,20 +493,14 @@ int ssh_handle_packets(ssh_session session, int timeout) {
*/ */
int ssh_handle_packets_termination(ssh_session session, int timeout, int ssh_handle_packets_termination(ssh_session session, int timeout,
ssh_termination_function fct, void *user){ ssh_termination_function fct, void *user){
int ret = SSH_ERROR; int ret = SSH_OK;
struct ssh_timestamp ts;
ssh_timestamp_init(&ts);
while(!fct(user)){ while(!fct(user)){
ret = ssh_handle_packets(session, timeout); ret = ssh_handle_packets(session, timeout);
if(ret == SSH_ERROR) if(ret == SSH_ERROR || ret == SSH_AGAIN)
return SSH_ERROR; return ret;
if(fct(user)) { if(fct(user))
return SSH_OK; return SSH_OK;
} else if (ssh_timeout_elapsed(&ts, timeout)) {
return SSH_AGAIN;
}
timeout = ssh_timeout_update(&ts,timeout);
} }
return ret; return ret;
} }