summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/trans.c23
-rw-r--r--common/trans.h2
-rw-r--r--sesman/chansrv/chansrv.c14
-rw-r--r--sesman/chansrv/chansrv.h3
-rw-r--r--sesman/chansrv/smartcard_pcsc.c4
-rw-r--r--sesman/chansrv/sound.c3
-rw-r--r--xrdp/xrdp.c2
-rw-r--r--xrdp/xrdp.h2
-rw-r--r--xrdp/xrdp_listen.c4
-rw-r--r--xrdp/xrdp_mm.c3
10 files changed, 52 insertions, 8 deletions
diff --git a/common/trans.c b/common/trans.c
index e862249e..0b672168 100644
--- a/common/trans.c
+++ b/common/trans.c
@@ -142,6 +142,7 @@ trans_check_wait_objs(struct trans *self)
in_trans->sck = in_sck;
in_trans->type1 = TRANS_TYPE_SERVER;
in_trans->status = TRANS_STATUS_UP;
+ in_trans->is_term = self->is_term;
if (self->trans_conn_in(self, in_trans) != 0)
{
@@ -226,9 +227,18 @@ trans_force_read_s(struct trans *self, struct stream *in_s, int size)
{
if (g_tcp_last_error_would_block(self->sck))
{
- if (!g_tcp_can_recv(self->sck, 10))
+ if (!g_tcp_can_recv(self->sck, 100))
{
/* check for term here */
+ if (self->is_term != 0)
+ {
+ if (self->is_term())
+ {
+ /* term */
+ self->status = TRANS_STATUS_DOWN;
+ return 1;
+ }
+ }
}
}
else
@@ -285,9 +295,18 @@ trans_force_write_s(struct trans *self, struct stream *out_s)
{
if (g_tcp_last_error_would_block(self->sck))
{
- if (!g_tcp_can_send(self->sck, 10))
+ if (!g_tcp_can_send(self->sck, 100))
{
/* check for term here */
+ if (self->is_term != 0)
+ {
+ if (self->is_term())
+ {
+ /* term */
+ self->status = TRANS_STATUS_DOWN;
+ return 1;
+ }
+ }
}
}
else
diff --git a/common/trans.h b/common/trans.h
index 8daa980a..4b8e3b42 100644
--- a/common/trans.h
+++ b/common/trans.h
@@ -38,6 +38,7 @@ struct trans; /* forward declaration */
typedef int (*ttrans_data_in)(struct trans* self);
typedef int (*ttrans_conn_in)(struct trans* self, struct trans* new_self);
+typedef int (*tis_term)(void);
struct trans
{
@@ -52,6 +53,7 @@ struct trans
struct stream* in_s;
struct stream* out_s;
char* listen_filename;
+ tis_term is_term; /* used to test for exit */
};
struct trans* APP_CC
diff --git a/sesman/chansrv/chansrv.c b/sesman/chansrv/chansrv.c
index 388d0273..26d4182e 100644
--- a/sesman/chansrv/chansrv.c
+++ b/sesman/chansrv/chansrv.c
@@ -77,6 +77,13 @@ int g_exec_pid = 0;
tui32 g_dvc_chan_id = 100;
/*****************************************************************************/
+int DEFAULT_CC
+g_is_term(void)
+{
+ return g_is_wait_obj_set(g_term_event);
+}
+
+/*****************************************************************************/
/* add data to chan_item, on its way to the client */
/* returns error */
static int APP_CC
@@ -844,13 +851,15 @@ setup_listen(void)
if (g_use_unix_socket)
{
- g_lis_trans = trans_create(2, 8192, 8192);
+ g_lis_trans = trans_create(TRANS_MODE_UNIX, 8192, 8192);
+ g_lis_trans->is_term = g_is_term;
g_snprintf(port, 255, "/tmp/.xrdp/xrdp_chansrv_socket_%d",
7200 + g_display_num);
}
else
{
- g_lis_trans = trans_create(1, 8192, 8192);
+ g_lis_trans = trans_create(TRANS_MODE_TCP, 8192, 8192);
+ g_lis_trans->is_term = g_is_term;
g_snprintf(port, 255, "%d", 7200 + g_display_num);
}
@@ -875,6 +884,7 @@ setup_api_listen(void)
int error = 0;
g_api_lis_trans = trans_create(TRANS_MODE_UNIX, 8192 * 4, 8192 * 4);
+ g_api_lis_trans->is_term = g_is_term;
g_snprintf(port, 255, "/tmp/.xrdp/xrdpapi_%d", g_display_num);
g_api_lis_trans->trans_conn_in = my_api_trans_conn_in;
error = trans_listen(g_api_lis_trans, port);
diff --git a/sesman/chansrv/chansrv.h b/sesman/chansrv/chansrv.h
index bca30ca4..12162dd1 100644
--- a/sesman/chansrv/chansrv.h
+++ b/sesman/chansrv/chansrv.h
@@ -54,6 +54,9 @@ struct xrdp_api_data
int is_connected;
};
+int DEFAULT_CC
+g_is_term(void);
+
int APP_CC send_channel_data(int chan_id, char *data, int size);
int APP_CC main_cleanup(void);
int APP_CC find_empty_slot_in_dvc_channels();
diff --git a/sesman/chansrv/smartcard_pcsc.c b/sesman/chansrv/smartcard_pcsc.c
index a3a269d7..909c7df3 100644
--- a/sesman/chansrv/smartcard_pcsc.c
+++ b/sesman/chansrv/smartcard_pcsc.c
@@ -24,6 +24,7 @@
#define PCSC_STANDIN 1
+#include "chansrv.h"
#include "os_calls.h"
#include "smartcard.h"
#include "log.h"
@@ -258,7 +259,8 @@ scard_pcsc_init(void)
if (g_lis == 0)
{
- g_lis = trans_create(2, 8192, 8192);
+ g_lis = trans_create(TRANS_MODE_UNIX, 8192, 8192);
+ g_lis->is_term = g_is_term;
g_snprintf(g_pcsc_directory, 255, "/tmp/.xrdp/pcsc%d", g_display_num);
if (g_directory_exist(g_pcsc_directory))
{
diff --git a/sesman/chansrv/sound.c b/sesman/chansrv/sound.c
index 9ee3c8c3..2e85f1f2 100644
--- a/sesman/chansrv/sound.c
+++ b/sesman/chansrv/sound.c
@@ -551,7 +551,8 @@ sound_init(void)
LOG(0, ("sound_init:"));
sound_send_server_formats();
- g_audio_l_trans = trans_create(2, 128 * 1024, 8192);
+ g_audio_l_trans = trans_create(TRANS_MODE_UNIX, 128 * 1024, 8192);
+ g_audio_l_trans->is_term = g_is_term;
g_snprintf(port, 255, CHANSRV_PORT_STR, g_display_num);
g_audio_l_trans->trans_conn_in = sound_trans_audio_conn_in;
error = trans_listen(g_audio_l_trans, port);
diff --git a/xrdp/xrdp.c b/xrdp/xrdp.c
index 0c340e55..887ada68 100644
--- a/xrdp/xrdp.c
+++ b/xrdp/xrdp.c
@@ -138,7 +138,7 @@ xrdp_child_fork(void)
}
/*****************************************************************************/
-int APP_CC
+int DEFAULT_CC
g_is_term(void)
{
return g_is_wait_obj_set(g_term_event);
diff --git a/xrdp/xrdp.h b/xrdp/xrdp.h
index 99d5743b..081adf3c 100644
--- a/xrdp/xrdp.h
+++ b/xrdp/xrdp.h
@@ -41,7 +41,7 @@
long APP_CC
g_xrdp_sync(long (*sync_func)(long param1, long param2), long sync_param1,
long sync_param2);
-int APP_CC
+int DEFAULT_CC
g_is_term(void);
void APP_CC
g_set_term(int in_val);
diff --git a/xrdp/xrdp_listen.c b/xrdp/xrdp_listen.c
index 965aa50d..e34fcd8a 100644
--- a/xrdp/xrdp_listen.c
+++ b/xrdp/xrdp_listen.c
@@ -66,6 +66,10 @@ xrdp_listen_create(void)
{
log_message(LOG_LEVEL_ERROR,"xrdp_listen_create: trans_create failed");
}
+ else
+ {
+ self->listen_trans->is_term = g_is_term;
+ }
return self;
}
diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c
index 0a79810b..391ea306 100644
--- a/xrdp/xrdp_mm.c
+++ b/xrdp/xrdp_mm.c
@@ -797,11 +797,13 @@ xrdp_mm_connect_chansrv(struct xrdp_mm *self, char *ip, char *port)
{
/* unix socket */
self->chan_trans = trans_create(TRANS_MODE_UNIX, 8192, 8192);
+ self->chan_trans->is_term = g_is_term;
}
else
{
/* tcp */
self->chan_trans = trans_create(TRANS_MODE_TCP, 8192, 8192);
+ self->chan_trans->is_term = g_is_term;
}
self->chan_trans->trans_data_in = xrdp_mm_chan_data_in;
@@ -1486,6 +1488,7 @@ xrdp_mm_connect(struct xrdp_mm *self)
ok = 0;
trans_delete(self->sesman_trans);
self->sesman_trans = trans_create(TRANS_MODE_TCP, 8192, 8192);
+ self->sesman_trans->is_term = g_is_term;
xrdp_mm_get_sesman_port(port, sizeof(port));
g_snprintf(text, 255, "connecting to sesman ip %s port %s", ip, port);
xrdp_wm_log_msg(self->wm, text);