aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2013-07-21 10:35:18 +0200
committerAndreas Schneider <asn@cryptomilk.org>2013-07-21 10:35:18 +0200
commit461988b1531783ac88da24d64bf2223aa7275b04 (patch)
tree4227092aa76334649e25396dea9f464bf9e76213
parentc4937cedeaea7983407ee3f9432d1355927f3c5f (diff)
downloadlibssh-461988b1531783ac88da24d64bf2223aa7275b04.tar.gz
libssh-461988b1531783ac88da24d64bf2223aa7275b04.tar.xz
libssh-461988b1531783ac88da24d64bf2223aa7275b04.zip
session: Add brackets to ssh_handle_packets_termination().
-rw-r--r--src/session.c67
1 files changed, 39 insertions, 28 deletions
diff --git a/src/session.c b/src/session.c
index db7e0f99..c6d0ec8f 100644
--- a/src/session.c
+++ b/src/session.c
@@ -515,34 +515,45 @@ int ssh_handle_packets(ssh_session session, int timeout) {
* @param[in] user User parameter to be passed to fct termination function.
* @return SSH_OK on success, SSH_ERROR otherwise.
*/
-int ssh_handle_packets_termination(ssh_session session, int timeout,
- ssh_termination_function fct, void *user){
- int ret = SSH_OK;
- struct ssh_timestamp ts;
- int tm;
- if (timeout == SSH_TIMEOUT_USER) {
- if (ssh_is_blocking(session))
- timeout = ssh_make_milliseconds(session->opts.timeout,
- session->opts.timeout_usec);
- 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;
- }
- ssh_timestamp_init(&ts);
- tm = timeout;
- while(!fct(user)){
- ret = ssh_handle_packets(session, tm);
- if(ret == SSH_ERROR)
- break;
- if(ssh_timeout_elapsed(&ts,timeout))
- break;
- tm = ssh_timeout_update(&ts, timeout);
- }
- return ret;
+int ssh_handle_packets_termination(ssh_session session,
+ int timeout,
+ ssh_termination_function fct,
+ void *user)
+{
+ struct ssh_timestamp ts;
+ int ret = SSH_OK;
+ int tm;
+
+ if (timeout == SSH_TIMEOUT_USER) {
+ if (ssh_is_blocking(session)) {
+ timeout = ssh_make_milliseconds(session->opts.timeout,
+ session->opts.timeout_usec);
+ } 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;
+ }
+ }
+
+ ssh_timestamp_init(&ts);
+ tm = timeout;
+ while(!fct(user)) {
+ ret = ssh_handle_packets(session, tm);
+ if (ret == SSH_ERROR) {
+ break;
+ }
+ if (ssh_timeout_elapsed(&ts,timeout)) {
+ break;
+ }
+
+ tm = ssh_timeout_update(&ts, timeout);
+ }
+
+ return ret;
}
/**