diff options
-rw-r--r-- | include/libssh/libssh.h | 1 | ||||
-rw-r--r-- | include/libssh/session.h | 1 | ||||
-rw-r--r-- | libssh/client.c | 2 | ||||
-rw-r--r-- | libssh/server.c | 3 | ||||
-rw-r--r-- | libssh/session.c | 11 |
5 files changed, 10 insertions, 8 deletions
diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h index 97e1da9..9281e0c 100644 --- a/include/libssh/libssh.h +++ b/include/libssh/libssh.h @@ -345,6 +345,7 @@ LIBSSH_API const char *ssh_copyright(void); LIBSSH_API void ssh_disconnect(ssh_session session); LIBSSH_API char *ssh_dirname (const char *path); LIBSSH_API int ssh_finalize(void); +LIBSSH_API void ssh_free(ssh_session session); LIBSSH_API const char *ssh_get_disconnect_message(ssh_session session); LIBSSH_API const char *ssh_get_error(void *error); LIBSSH_API int ssh_get_error_code(void *error); diff --git a/include/libssh/session.h b/include/libssh/session.h index b9f425a..c59ba5f 100644 --- a/include/libssh/session.h +++ b/include/libssh/session.h @@ -113,6 +113,5 @@ struct ssh_session_struct { }; int ssh_handle_packets(ssh_session session); -void ssh_cleanup(ssh_session session); #endif /* SESSION_H_ */ diff --git a/libssh/client.c b/libssh/client.c index 84fbd84..5ca79be 100644 --- a/libssh/client.c +++ b/libssh/client.c @@ -647,6 +647,7 @@ int ssh_get_openssh_version(ssh_session session) { /** * @brief Disconnect from a session (client or server). + * The session can then be reused to open a new session. * * @param session The SSH session to disconnect. */ @@ -686,7 +687,6 @@ void ssh_disconnect(ssh_session session) { error: leave_function(); - ssh_cleanup(session); } const char *ssh_copyright(void) { diff --git a/libssh/server.c b/libssh/server.c index 986ec04..b29fa68 100644 --- a/libssh/server.c +++ b/libssh/server.c @@ -240,7 +240,6 @@ int ssh_bind_accept(ssh_bind sshbind, ssh_session session) { if (session->wanted_methods[i] == NULL) { privatekey_free(dsa); privatekey_free(rsa); - ssh_cleanup(session); return SSH_ERROR; } } @@ -253,7 +252,6 @@ int ssh_bind_accept(ssh_bind sshbind, ssh_session session) { if (session->bindaddr == NULL) { privatekey_free(dsa); privatekey_free(rsa); - ssh_cleanup(session); return SSH_ERROR; } } @@ -265,7 +263,6 @@ int ssh_bind_accept(ssh_bind sshbind, ssh_session session) { if (session->socket == NULL) { privatekey_free(dsa); privatekey_free(rsa); - ssh_cleanup(session); return SSH_ERROR; } ssh_socket_set_fd(session->socket, fd); diff --git a/libssh/session.c b/libssh/session.c index a03b765..a06c4f6 100644 --- a/libssh/session.c +++ b/libssh/session.c @@ -98,11 +98,16 @@ ssh_session ssh_new(void) { return session; err: - ssh_cleanup(session); + ssh_free(session); return NULL; } -void ssh_cleanup(ssh_session session) { +/** + * @brief deallocate a session handle + * @see ssh_disconnect() + * @see ssh_new() + */ +void ssh_free(ssh_session session) { int i; enter_function(); @@ -182,7 +187,7 @@ void ssh_silent_disconnect(ssh_session session) { ssh_socket_close(session->socket); session->alive = 0; ssh_disconnect(session); - /* FIXME: leave_function(); ??? */ + leave_function(); } /** \brief set the session in blocking/nonblocking mode |