diff options
author | Andreas Schneider <mail@cynapses.org> | 2009-04-14 14:46:04 +0000 |
---|---|---|
committer | Andreas Schneider <mail@cynapses.org> | 2009-04-14 14:46:04 +0000 |
commit | 16084e548ed60ff474887a762c0cd146bfd64fd0 (patch) | |
tree | 31ec5bca0ee67b710f3593e4d33e5e3c7597919f /libssh/session.c | |
parent | 118d4ee131314f58616f53c3ad15783525850d08 (diff) | |
download | libssh-16084e548ed60ff474887a762c0cd146bfd64fd0.tar.gz libssh-16084e548ed60ff474887a762c0cd146bfd64fd0.tar.xz libssh-16084e548ed60ff474887a762c0cd146bfd64fd0.zip |
Cleanup ssh_handle_packets().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@474 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh/session.c')
-rw-r--r-- | libssh/session.c | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/libssh/session.c b/libssh/session.c index e3f8e4a..60e4768 100644 --- a/libssh/session.c +++ b/libssh/session.c @@ -232,26 +232,33 @@ void ssh_set_fd_except(SSH_SESSION *session) { /** \warning I don't remember if this should be internal or not */ /* looks if there is data to read on the socket and parse it. */ -int ssh_handle_packets(SSH_SESSION *session){ - int w,err,r,i=0; - enter_function(); - do { - r=ssh_socket_poll(session->socket,&w,&err); - if(r<=0){ - leave_function(); - return r; // error or no data available - } - /* if an exception happened, it will be trapped by packet_read() */ - if ((packet_read(session) != SSH_OK) || - (packet_translate(session) != SSH_OK)) { - leave_function(); - return -1; - } - packet_parse(session); - ++i; - } while(r>0); - leave_function(); - return r; +int ssh_handle_packets(SSH_SESSION *session) { + int w = 0; + int e = 0; + int rc = -1; + + enter_function(); + + do { + rc = ssh_socket_poll(session->socket, &w, &e); + if (rc <= 0) { + /* error or no data available */ + leave_function(); + return rc; + } + + /* if an exception happened, it will be trapped by packet_read() */ + if ((packet_read(session) != SSH_OK) || + (packet_translate(session) != SSH_OK)) { + leave_function(); + return -1; + } + + packet_parse(session); + } while(rc > 0); + + leave_function(); + return rc; } /** \brief get session status |