From 0b5445b67651c1ee0f423934f3f7dde32fed6a71 Mon Sep 17 00:00:00 2001 From: matt335672 <30179339+matt335672@users.noreply.github.com> Date: Tue, 12 Oct 2021 14:37:28 +0100 Subject: [PATCH] Remove unnecessary error from neutrinordp log --- mc/mc.h | 3 ++- neutrinordp/xrdp-neutrinordp.c | 37 +++++++++++++++++++++++----------- neutrinordp/xrdp-neutrinordp.h | 3 ++- vnc/vnc.h | 3 ++- xrdp/xrdp.h | 2 ++ xrdp/xrdp_mm.c | 19 +++++++++++++++++ xrdp/xrdp_types.h | 3 ++- xup/xup.h | 3 ++- 8 files changed, 56 insertions(+), 17 deletions(-) diff --git a/mc/mc.h b/mc/mc.h index 8a22fdee..990ce7a5 100644 --- a/mc/mc.h +++ b/mc/mc.h @@ -79,6 +79,7 @@ struct mod int box_right, int box_bottom, int x, int y, char *data, int data_len); int (*server_reset)(struct mod *v, int width, int height, int bpp); + int (*server_get_channel_count)(struct mod *v); int (*server_query_channel)(struct mod *v, int index, char *channel_name, int *channel_flags); @@ -88,7 +89,7 @@ struct mod int total_data_len, int flags); int (*server_bell_trigger)(struct mod *v); int (*server_chansrv_in_use)(struct mod *v); - tintptr server_dumby[100 - 26]; /* align, 100 minus the number of server + tintptr server_dumby[100 - 27]; /* align, 100 minus the number of server functions above */ /* common */ tintptr handle; /* pointer to self as long */ diff --git a/neutrinordp/xrdp-neutrinordp.c b/neutrinordp/xrdp-neutrinordp.c index c99e329f..6f403e07 100644 --- a/neutrinordp/xrdp-neutrinordp.c +++ b/neutrinordp/xrdp-neutrinordp.c @@ -1749,21 +1749,34 @@ lfreerdp_pre_connect(freerdp *instance) LOG_DEVEL(LOG_LEVEL_INFO, "lfreerdp_pre_connect:"); mod = ((struct mod_context *)(instance->context))->modi; verifyColorMap(mod); - num_chans = 0; - index = 0; - error = mod->server_query_channel(mod, index, ch_name, &ch_flags); - while (error == 0) + num_chans = mod->server_get_channel_count(mod); + if (num_chans < 0) + { + LOG(LOG_LEVEL_ERROR, "lfreerdp_pre_connect: Can't get channel count"); + num_chans = 0; + } + + for (index = 0 ; index < num_chans; ++index) { - num_chans++; - LOG_DEVEL(LOG_LEVEL_DEBUG, "lfreerdp_pre_connect: got channel [%s], id [%d], flags [0x%8.8x]", - ch_name, index, ch_flags); - dst_ch_name = instance->settings->channels[index].name; - g_memset(dst_ch_name, 0, 8); - g_snprintf(dst_ch_name, 8, "%s", ch_name); - instance->settings->channels[index].options = ch_flags; - index++; error = mod->server_query_channel(mod, index, ch_name, &ch_flags); + if (error == 0) + { + LOG_DEVEL(LOG_LEVEL_DEBUG, "lfreerdp_pre_connect: " + "got channel [%s], id [%d], flags [0x%8.8x]", + ch_name, index, ch_flags); + dst_ch_name = instance->settings->channels[index].name; + g_memset(dst_ch_name, 0, 8); + g_snprintf(dst_ch_name, 8, "%s", ch_name); + instance->settings->channels[index].options = ch_flags; + } + else + { + LOG(LOG_LEVEL_ERROR, "lfreerdp_pre_connect: " + "Expected %d channels, got %d", + num_chans, index); + num_chans = index; + } } instance->settings->num_channels = num_chans; diff --git a/neutrinordp/xrdp-neutrinordp.h b/neutrinordp/xrdp-neutrinordp.h index 72451a7a..afe15b1f 100644 --- a/neutrinordp/xrdp-neutrinordp.h +++ b/neutrinordp/xrdp-neutrinordp.h @@ -131,6 +131,7 @@ struct mod int box_right, int box_bottom, int x, int y, char *data, int data_len); int (*server_reset)(struct mod *v, int width, int height, int bpp); + int (*server_get_channel_count)(struct mod *v); int (*server_query_channel)(struct mod *v, int index, char *channel_name, int *channel_flags); @@ -194,7 +195,7 @@ struct mod int flags, int frame_id); int (*server_session_info)(struct mod *v, const char *data, int data_bytes); - tintptr server_dumby[100 - 45]; /* align, 100 minus the number of server + tintptr server_dumby[100 - 46]; /* align, 100 minus the number of server functions above */ /* common */ tintptr handle; /* pointer to self as long */ diff --git a/vnc/vnc.h b/vnc/vnc.h index b34fda67..025d592f 100644 --- a/vnc/vnc.h +++ b/vnc/vnc.h @@ -123,6 +123,7 @@ struct vnc int box_right, int box_bottom, int x, int y, char *data, int data_len); int (*server_reset)(struct vnc *v, int width, int height, int bpp); + int (*server_get_channel_count)(struct vnc *v); int (*server_query_channel)(struct vnc *v, int index, char *channel_name, int *channel_flags); @@ -132,7 +133,7 @@ struct vnc int total_data_len, int flags); int (*server_bell_trigger)(struct vnc *v); int (*server_chansrv_in_use)(struct vnc *v); - tintptr server_dumby[100 - 26]; /* align, 100 minus the number of server + tintptr server_dumby[100 - 27]; /* align, 100 minus the number of server functions above */ /* common */ tintptr handle; /* pointer to self as long */ diff --git a/xrdp/xrdp.h b/xrdp/xrdp.h index 32da64db..43b1b8b1 100644 --- a/xrdp/xrdp.h +++ b/xrdp/xrdp.h @@ -513,6 +513,8 @@ server_reset(struct xrdp_mod *mod, int width, int height, int bpp); int is_channel_allowed(struct xrdp_wm *wm, int channel_id); int +server_get_channel_count(struct xrdp_mod *mod); +int server_query_channel(struct xrdp_mod *mod, int index, char *channel_name, int *channel_flags); int diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c index 704745ea..a371f082 100644 --- a/xrdp/xrdp_mm.c +++ b/xrdp/xrdp_mm.c @@ -448,6 +448,7 @@ xrdp_mm_setup_mod1(struct xrdp_mm *self) self->mod->server_add_char = server_add_char; self->mod->server_draw_text = server_draw_text; self->mod->server_reset = server_reset; + self->mod->server_get_channel_count = server_get_channel_count; self->mod->server_query_channel = server_query_channel; self->mod->server_get_channel_id = server_get_channel_id; self->mod->server_send_to_channel = server_send_to_channel; @@ -3568,6 +3569,24 @@ server_reset(struct xrdp_mod *mod, int width, int height, int bpp) return 0; } +/*****************************************************************************/ +/*return -1 if channels are controlled by chansrv */ +int +server_get_channel_count(struct xrdp_mod *mod) +{ + struct xrdp_wm *wm; + + wm = (struct xrdp_wm *)(mod->wm); + + if (wm->mm->usechansrv) + { + return -1; + } + + return libxrdp_get_channel_count(wm->session); +} + + /*****************************************************************************/ /*return 0 if the index is not found*/ int diff --git a/xrdp/xrdp_types.h b/xrdp/xrdp_types.h index 692a7190..b6bb7477 100644 --- a/xrdp/xrdp_types.h +++ b/xrdp/xrdp_types.h @@ -95,6 +95,7 @@ struct xrdp_mod int box_right, int box_bottom, int x, int y, char *data, int data_len); int (*server_reset)(struct xrdp_mod *v, int width, int height, int bpp); + int (*server_get_channel_count)(struct xrdp_mod *v); int (*server_query_channel)(struct xrdp_mod *v, int index, char *channel_name, int *channel_flags); @@ -159,7 +160,7 @@ struct xrdp_mod int flags, int frame_id); int (*server_session_info)(struct xrdp_mod *v, const char *data, int data_bytes); - tintptr server_dumby[100 - 45]; /* align, 100 minus the number of server + tintptr server_dumby[100 - 46]; /* align, 100 minus the number of server functions above */ /* common */ tintptr handle; /* pointer to self as int */ diff --git a/xup/xup.h b/xup/xup.h index 695536b1..767c459d 100644 --- a/xup/xup.h +++ b/xup/xup.h @@ -92,6 +92,7 @@ struct mod int box_right, int box_bottom, int x, int y, char *data, int data_len); int (*server_reset)(struct mod *v, int width, int height, int bpp); + int (*server_get_channel_count)(struct mod *v); int (*server_query_channel)(struct mod *v, int index, char *channel_name, int *channel_flags); @@ -152,7 +153,7 @@ struct mod char *data, int width, int height, int flags, int frame_id); - tintptr server_dumby[100 - 44]; /* align, 100 minus the number of server + tintptr server_dumby[100 - 45]; /* align, 100 minus the number of server functions above */ /* common */ tintptr handle; /* pointer to self as long */