client ssh session BUGFIX append new channel session immediatelly
So that freeing works correctly.
Fixes #134
diff --git a/src/session_client_ssh.c b/src/session_client_ssh.c
index b3fbcc5..27e7e47 100644
--- a/src/session_client_ssh.c
+++ b/src/session_client_ssh.c
@@ -1753,6 +1753,16 @@
new_session->ti.libssh.session = session->ti.libssh.session;
new_session->io_lock = session->io_lock;
+ /* append to the session ring list */
+ if (!session->ti.libssh.next) {
+ session->ti.libssh.next = new_session;
+ new_session->ti.libssh.next = session;
+ } else {
+ ptr = session->ti.libssh.next;
+ session->ti.libssh.next = new_session;
+ new_session->ti.libssh.next = ptr;
+ }
+
/* create the channel safely */
if (nc_session_io_lock(new_session, -1, __func__) != 1) {
goto fail;
@@ -1782,16 +1792,6 @@
new_session->port = session->port;
new_session->username = lydict_insert(ctx, session->username, 0);
- /* append to the session ring list */
- if (!session->ti.libssh.next) {
- session->ti.libssh.next = new_session;
- new_session->ti.libssh.next = session;
- } else {
- ptr = session->ti.libssh.next;
- session->ti.libssh.next = new_session;
- new_session->ti.libssh.next = ptr;
- }
-
return new_session;
fail: