aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2009-10-09 22:50:48 +0200
committerAris Adamantiadis <aris@0xbadc0de.be>2009-10-09 22:50:48 +0200
commit6ec65c6f9d1aefddaccf0a9816dae0b68a46ea33 (patch)
tree58b094ae5b46b1d85cbd95f30dcddc2b041d2712
parent71ab0cf6ccad12ff8454005cbe9a62cf1f9ae91d (diff)
downloadlibssh-6ec65c6f9d1aefddaccf0a9816dae0b68a46ea33.tar.gz
libssh-6ec65c6f9d1aefddaccf0a9816dae0b68a46ea33.tar.xz
libssh-6ec65c6f9d1aefddaccf0a9816dae0b68a46ea33.zip
ssh_disconnect doesn't free the session anymore
-rw-r--r--include/libssh/libssh.h1
-rw-r--r--include/libssh/session.h1
-rw-r--r--libssh/client.c2
-rw-r--r--libssh/server.c3
-rw-r--r--libssh/session.c11
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