diff options
author | Aris Adamantiadis <aris@0xbadc0de.be> | 2008-06-16 23:02:49 +0000 |
---|---|---|
committer | Aris Adamantiadis <aris@0xbadc0de.be> | 2008-06-16 23:02:49 +0000 |
commit | 77603dbc5a5c55ecfa8d583c133db844673fb690 (patch) | |
tree | 96c4ad653c74e1d53791f4a73c49d43cdcb58359 /libssh/connect.c | |
parent | 5367581ce1d52518343bb8ede60738f4035e033a (diff) | |
download | libssh-77603dbc5a5c55ecfa8d583c133db844673fb690.tar.gz libssh-77603dbc5a5c55ecfa8d583c133db844673fb690.tar.xz libssh-77603dbc5a5c55ecfa8d583c133db844673fb690.zip |
Big changes :
refactoring of the socket class. Now the buffering happens in the socket class.
enhanced the logging system. Cleaned up some debugging messages.
Verified the working with ssh-1.
If this cleanup introduced bugs (it did but corrected the found ones) at least, they will be easier to find
also added the (c) and fixed dates for updated files
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@169 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh/connect.c')
-rw-r--r-- | libssh/connect.c | 44 |
1 files changed, 2 insertions, 42 deletions
diff --git a/libssh/connect.c b/libssh/connect.c index 8a42b0c1..a5156763 100644 --- a/libssh/connect.c +++ b/libssh/connect.c @@ -1,7 +1,7 @@ /* connect.c */ /* it handles connections to ssh servers */ /* -Copyright 2003 Aris Adamantiadis +Copyright (c) 2003-2008 Aris Adamantiadis This file is part of the SSH Library @@ -220,47 +220,7 @@ socket_t ssh_connect_host(SSH_SESSION *session, const char *host, const char * \return 1 if it is possible to read, 0 otherwise, -1 on error */ int ssh_fd_poll(SSH_SESSION *session, int *write, int *except){ - struct timeval sometime; - fd_set rdes; // read set - fd_set wdes; // writing set - fd_set edes; // exception set - int fdmax=-1; - enter_function(); - FD_ZERO(&rdes); - FD_ZERO(&wdes); - FD_ZERO(&edes); - - if(!session->alive || !ssh_socket_is_open(session->socket)){ - *except=1; - *write=0; - session->alive=0; - leave_function(); - return 0; - } - if(!session->data_to_read) - ssh_socket_fd_set(session->socket,&rdes,&fdmax); - if(!session->data_to_write) - ssh_socket_fd_set(session->socket,&wdes,&fdmax); - ssh_socket_fd_set(session->socket,&edes,&fdmax); - - /* Set to return immediately (no blocking) */ - sometime.tv_sec = 0; - sometime.tv_usec = 0; - - /* Make the call, and listen for errors */ - if (select(fdmax, &rdes,&wdes,&edes, &sometime) < 0) { - ssh_set_error(session,SSH_FATAL, "select: %s", strerror(errno)); - leave_function(); - return -1; - } - if(!session->data_to_read) - session->data_to_read=ssh_socket_fd_isset(session->socket,&rdes); - if(!session->data_to_write) - session->data_to_write=ssh_socket_fd_isset(session->socket,&wdes); - *except=ssh_socket_fd_isset(session->socket,&edes); - *write=session->data_to_write; - leave_function(); - return session->data_to_read; + return ssh_socket_poll(session->socket,write,except); } |