Skip to content
Snippets Groups Projects
Commit 80c10879 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Move sftp_channel under the ssh_mutex completely.

parent b855aa17
Branches
Tags
No related merge requests found
Pipeline #5839 passed
...@@ -270,8 +270,9 @@ ssh_input_thread(void *args) ...@@ -270,8 +270,9 @@ ssh_input_thread(void *args)
* and will deadlock. * and will deadlock.
*/ */
if (rd > 0 && !sftpc_recv(sftp_state, conn_api.rd_buf, rd)) { if (rd > 0 && !sftpc_recv(sftp_state, conn_api.rd_buf, rd)) {
int sc = sftp_channel;
pthread_mutex_unlock(&ssh_mutex); pthread_mutex_unlock(&ssh_mutex);
close_sftp_channel(sftp_channel); close_sftp_channel(sc);
pthread_mutex_lock(&ssh_mutex); pthread_mutex_lock(&ssh_mutex);
FlushData(ssh_session); FlushData(ssh_session);
pthread_mutex_unlock(&ssh_mutex); pthread_mutex_unlock(&ssh_mutex);
...@@ -566,6 +567,7 @@ add_public_key(void *vpriv) ...@@ -566,6 +567,7 @@ add_public_key(void *vpriv)
pubkey_thread_running = false; pubkey_thread_running = false;
return; return;
} }
int sc = sftp_channel;
pthread_mutex_unlock(&ssh_mutex); pthread_mutex_unlock(&ssh_mutex);
pthread_mutex_unlock(&ssh_tx_mutex); pthread_mutex_unlock(&ssh_tx_mutex);
active = 0; active = 0;
...@@ -580,7 +582,7 @@ add_public_key(void *vpriv) ...@@ -580,7 +582,7 @@ add_public_key(void *vpriv)
SLEEP(10); SLEEP(10);
} }
if (!active) { if (!active) {
close_sftp_channel(sftp_channel); close_sftp_channel(sc);
free(priv); free(priv);
pubkey_thread_running = false; pubkey_thread_running = false;
return; return;
...@@ -611,7 +613,7 @@ add_public_key(void *vpriv) ...@@ -611,7 +613,7 @@ add_public_key(void *vpriv)
pthread_mutex_unlock(&ssh_mutex); pthread_mutex_unlock(&ssh_mutex);
pthread_mutex_unlock(&ssh_tx_mutex); pthread_mutex_unlock(&ssh_tx_mutex);
if (sftp_state == NULL) { if (sftp_state == NULL) {
close_sftp_channel(sftp_channel); close_sftp_channel(new_sftp_channel);
free(priv); free(priv);
pubkey_thread_running = false; pubkey_thread_running = false;
return; return;
...@@ -639,7 +641,7 @@ add_public_key(void *vpriv) ...@@ -639,7 +641,7 @@ add_public_key(void *vpriv)
if (oldstate) if (oldstate)
sftpc_finish(oldstate); sftpc_finish(oldstate);
} }
close_sftp_channel(sftp_channel); close_sftp_channel(new_sftp_channel);
} }
else { else {
pthread_mutex_unlock(&ssh_mutex); pthread_mutex_unlock(&ssh_mutex);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment