Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 59f896e6 authored by rswindell's avatar rswindell

Create/use passthru_socket_activate() function which will purge the

client_socket_dup before activating the passthru_socket. This resolves the
issue of external programs receiving stale data from the previous passthru
session - data that was not sucessfully read by the last external program
invoked.
parent fba33a15
...@@ -2106,6 +2106,21 @@ void input_thread(void *arg) ...@@ -2106,6 +2106,21 @@ void input_thread(void *arg)
,sbbs->cfg.node_num, total_recv, total_pkts); ,sbbs->cfg.node_num, total_recv, total_pkts);
} }
// Flush the duplicate client_socket when activating the passthru socket
// to eliminate any stale data from the previous passthru session
void sbbs_t::passthru_socket_activate(bool activate)
{
if(activate) {
BOOL rd = FALSE;
while(socket_check(client_socket_dup, &rd, /* wr_p */NULL, /* timeout */0) && rd) {
char ch;
if(recv(client_socket_dup, &ch, sizeof(ch), /* flags: */0) != sizeof(ch))
break;
}
}
passthru_socket_active = activate;
}
/* /*
* This thread simply copies anything it manages to read from the * This thread simply copies anything it manages to read from the
* passthru_socket into the output ringbuffer. * passthru_socket into the output ringbuffer.
......
...@@ -332,6 +332,7 @@ public: ...@@ -332,6 +332,7 @@ public:
bool ssh_mode; bool ssh_mode;
SOCKET passthru_socket; SOCKET passthru_socket;
bool passthru_socket_active; bool passthru_socket_active;
void passthru_socket_activate(bool);
bool passthru_thread_running; bool passthru_thread_running;
scfg_t cfg; scfg_t cfg;
......
...@@ -678,7 +678,7 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir) ...@@ -678,7 +678,7 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir)
if(!(mode&EX_STDIN)) { if(!(mode&EX_STDIN)) {
if(passthru_thread_running) if(passthru_thread_running)
passthru_socket_active = true; passthru_socket_activate(true);
else else
pthread_mutex_lock(&input_thread_mutex); pthread_mutex_lock(&input_thread_mutex);
} }
...@@ -703,7 +703,7 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir) ...@@ -703,7 +703,7 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir)
XTRN_CLEANUP; XTRN_CLEANUP;
if(!(mode&EX_STDIN)) { if(!(mode&EX_STDIN)) {
if(passthru_thread_running) if(passthru_thread_running)
passthru_socket_active = false; passthru_socket_activate(false);
else else
pthread_mutex_unlock(&input_thread_mutex); pthread_mutex_unlock(&input_thread_mutex);
} }
...@@ -1074,7 +1074,7 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir) ...@@ -1074,7 +1074,7 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir)
if(native) { if(native) {
if(!(mode&EX_STDIN)) { if(!(mode&EX_STDIN)) {
if(passthru_thread_running) if(passthru_thread_running)
passthru_socket_active = false; passthru_socket_activate(false);
else else
pthread_mutex_unlock(&input_thread_mutex); pthread_mutex_unlock(&input_thread_mutex);
} }
...@@ -1656,7 +1656,7 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir) ...@@ -1656,7 +1656,7 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir)
if(!(mode&EX_STDIN)) { if(!(mode&EX_STDIN)) {
if(!(mode&EX_STDIN)) { if(!(mode&EX_STDIN)) {
if(passthru_thread_running) if(passthru_thread_running)
passthru_socket_active = true; passthru_socket_activate(true);
else else
pthread_mutex_lock(&input_thread_mutex); pthread_mutex_lock(&input_thread_mutex);
} }
...@@ -1687,7 +1687,7 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir) ...@@ -1687,7 +1687,7 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir)
if((pid=forkpty(&in_pipe[1],NULL,&term,&winsize))==-1) { if((pid=forkpty(&in_pipe[1],NULL,&term,&winsize))==-1) {
if(!(mode&EX_STDIN)) { if(!(mode&EX_STDIN)) {
if(passthru_thread_running) if(passthru_thread_running)
passthru_socket_active = false; passthru_socket_activate(false);
else else
pthread_mutex_unlock(&input_thread_mutex); pthread_mutex_unlock(&input_thread_mutex);
} }
...@@ -1712,7 +1712,7 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir) ...@@ -1712,7 +1712,7 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir)
if((pid=FORK())==-1) { if((pid=FORK())==-1) {
if(!(mode&EX_STDIN)) { if(!(mode&EX_STDIN)) {
if(passthru_thread_running) if(passthru_thread_running)
passthru_socket_active = false; passthru_socket_activate(false);
else else
pthread_mutex_unlock(&input_thread_mutex); pthread_mutex_unlock(&input_thread_mutex);
} }
...@@ -2011,7 +2011,7 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir) ...@@ -2011,7 +2011,7 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir)
if(!(mode&EX_STDIN)) { if(!(mode&EX_STDIN)) {
if(passthru_thread_running) if(passthru_thread_running)
passthru_socket_active = false; passthru_socket_activate(false);
else else
pthread_mutex_unlock(&input_thread_mutex); pthread_mutex_unlock(&input_thread_mutex);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment