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

More input thread cleanup. There was an errant lock in there.

parent fbd2315b
Branches
Tags
No related merge requests found
Pipeline #5898 passed
...@@ -109,7 +109,15 @@ close_sftp_channel(int chan) ...@@ -109,7 +109,15 @@ close_sftp_channel(int chan)
cryptSetAttribute(ssh_session, CRYPT_SESSINFO_SSH_CHANNEL_ACTIVE, 0); cryptSetAttribute(ssh_session, CRYPT_SESSINFO_SSH_CHANNEL_ACTIVE, 0);
} }
} }
sftp_channel = -1; if (chan == sftp_channel)
sftp_channel = -1;
else {
FlushData(ssh_session);
if (cryptStatusOK(cryptSetAttribute(ssh_session, CRYPT_SESSINFO_SSH_CHANNEL, sftp_channel))) {
cryptSetAttribute(ssh_session, CRYPT_SESSINFO_SSH_CHANNEL_ACTIVE, 0);
}
sftp_channel = -1;
}
oldstate = sftp_state; oldstate = sftp_state;
sftp_state = NULL; sftp_state = NULL;
pthread_mutex_unlock(&ssh_mutex); pthread_mutex_unlock(&ssh_mutex);
...@@ -161,6 +169,7 @@ ssh_input_thread(void *args) ...@@ -161,6 +169,7 @@ ssh_input_thread(void *args)
size_t buffer; size_t buffer;
int chan; int chan;
sftpc_state_t oldstate = NULL; sftpc_state_t oldstate = NULL;
bool both_gone = false;
SetThreadName("SSH Input"); SetThreadName("SSH Input");
conn_api.input_thread_running = 1; conn_api.input_thread_running = 1;
...@@ -178,15 +187,11 @@ ssh_input_thread(void *args) ...@@ -178,15 +187,11 @@ ssh_input_thread(void *args)
sftp_channel = -1; sftp_channel = -1;
} }
} }
if (ssh_channel == -1 && sftp_channel == -1) { if (ssh_channel == -1 && sftp_channel == -1)
if (oldstate != NULL) { both_gone = true;
sftpc_finish(oldstate);
oldstate = NULL;
}
pthread_mutex_unlock(&ssh_mutex);
break;
}
pthread_mutex_unlock(&ssh_mutex); pthread_mutex_unlock(&ssh_mutex);
if (both_gone)
break;
if (oldstate != NULL) { if (oldstate != NULL) {
sftpc_finish(oldstate); sftpc_finish(oldstate);
oldstate = NULL; oldstate = NULL;
...@@ -204,16 +209,15 @@ ssh_input_thread(void *args) ...@@ -204,16 +209,15 @@ ssh_input_thread(void *args)
} }
if (sftp_channel != -1) { if (sftp_channel != -1) {
if (!check_channel_open(&sftp_channel)) { if (!check_channel_open(&sftp_channel)) {
pthread_mutex_lock(&ssh_mutex);
sftpc_state_t oldstate = sftp_state; sftpc_state_t oldstate = sftp_state;
sftp_state = NULL; sftp_state = NULL;
sftp_channel = -1; sftp_channel = -1;
pthread_mutex_unlock(&ssh_mutex); pthread_mutex_unlock(&ssh_mutex);
sftpc_finish(oldstate); sftpc_finish(oldstate);
oldstate = NULL;
} }
} }
if (ssh_channel == -1 && sftp_channel == -1) { if (ssh_channel == -1 && sftp_channel == -1) {
fprintf(stderr, "All my friends are gone!\n");
pthread_mutex_unlock(&ssh_mutex); pthread_mutex_unlock(&ssh_mutex);
break; break;
} }
...@@ -296,6 +300,10 @@ ssh_input_thread(void *args) ...@@ -296,6 +300,10 @@ ssh_input_thread(void *args)
FlushData(ssh_session); FlushData(ssh_session);
pthread_mutex_unlock(&ssh_mutex); pthread_mutex_unlock(&ssh_mutex);
} }
if (oldstate != NULL) {
sftpc_finish(oldstate);
oldstate = NULL;
}
conn_api.input_thread_running = 2; conn_api.input_thread_running = 2;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment