From 4ebb544cd889b9bf8ecfbc30969a86a48680085b Mon Sep 17 00:00:00 2001 From: jsorg71 Date: Sat, 5 Apr 2008 08:25:49 +0000 Subject: [PATCH] main loop changes, not so chatty --- xrdp/xrdp.c | 4 +- xrdp/xrdp.h | 9 ++- xrdp/xrdp_listen.c | 136 +++++++++++++++++++++++------------------- xrdp/xrdp_login_wnd.c | 4 +- xrdp/xrdp_mm.c | 33 +++++----- xrdp/xrdp_process.c | 94 ++++++++++++++++++++--------- xrdp/xrdp_types.h | 11 +++- xrdp/xrdp_wm.c | 127 ++++++++++++++++++++++++++++++++++++--- 8 files changed, 297 insertions(+), 121 deletions(-) diff --git a/xrdp/xrdp.c b/xrdp/xrdp.c index e4e0de58..8ce0c7bc 100644 --- a/xrdp/xrdp.c +++ b/xrdp/xrdp.c @@ -549,8 +549,8 @@ main(int argc, char** argv) xrdp_listen_delete(g_listen); tc_mutex_delete(g_sync_mutex); tc_mutex_delete(g_sync1_mutex); - g_destroy_wait_obj(g_term_event); - g_destroy_wait_obj(g_sync_event); + g_delete_wait_obj(g_term_event); + g_delete_wait_obj(g_sync_event); #if defined(_WIN32) /* I don't think it ever gets here */ /* when running in win32 app mode, control c exits right away */ diff --git a/xrdp/xrdp.h b/xrdp/xrdp.h index ad3af894..e41c050a 100644 --- a/xrdp/xrdp.h +++ b/xrdp/xrdp.h @@ -118,11 +118,16 @@ callback(long id, int msg, long param1, long param2, long param3, long param4); int APP_CC xrdp_wm_delete_all_childs(struct xrdp_wm* self); int APP_CC -xrdp_wm_idle(struct xrdp_wm* self); -int APP_CC xrdp_wm_app_sck_signal(struct xrdp_wm* self, int app_sck); int APP_CC xrdp_wm_log_msg(struct xrdp_wm* self, char* msg); +int APP_CC +xrdp_wm_get_wait_objs(struct xrdp_wm* self, tbus* robjs, int* rc, + tbus* wobjs, int* wc, int* timeout); +int APP_CC +xrdp_wm_check_wait_objs(struct xrdp_wm* self); +int APP_CC +xrdp_wm_set_login_mode(struct xrdp_wm* self, int login_mode); /* xrdp_process.c */ struct xrdp_process* APP_CC diff --git a/xrdp/xrdp_listen.c b/xrdp/xrdp_listen.c index d7e63b7d..4526d147 100644 --- a/xrdp/xrdp_listen.c +++ b/xrdp/xrdp_listen.c @@ -34,9 +34,12 @@ xrdp_listen_create(void) struct xrdp_listen* self; self = (struct xrdp_listen*)g_malloc(sizeof(struct xrdp_listen), 1); - g_process_sem = tc_sem_create(0); self->pro_done_event = g_create_wait_obj("xrdp_listen_pro_done_event"); self->process_list = list_create(); + if (g_process_sem == 0) + { + g_process_sem = tc_sem_create(0); + } return self; } @@ -44,53 +47,16 @@ xrdp_listen_create(void) void APP_CC xrdp_listen_delete(struct xrdp_listen* self) { - tc_sem_delete(g_process_sem); - g_destroy_wait_obj(self->pro_done_event); + if (g_process_sem != 0) + { + tc_sem_delete(g_process_sem); + g_process_sem = 0; + } + g_delete_wait_obj(self->pro_done_event); list_delete(self->process_list); g_free(self); } -/*****************************************************************************/ -static int APP_CC -xrdp_listen_term_processes(struct xrdp_listen* self) -{ - int i; - struct xrdp_process* pro; - - /* tell all xrdp processes to end */ - for (i = self->process_list->count - 1; i >= 0; i--) - { - pro = (struct xrdp_process*)list_get_item(self->process_list, i); - if (pro != 0) - { - pro->term = 1; - } - } - /* make sure they are done */ - for (i = self->process_list->count - 1; i >= 0; i--) - { - pro = (struct xrdp_process*)list_get_item(self->process_list, i); - if (pro != 0) - { - while (pro->status > 0) - { - g_sleep(10); - } - } - } - /* free them all */ - for (i = self->process_list->count - 1; i >= 0; i--) - { - pro = (struct xrdp_process*)list_get_item(self->process_list, i); - if (pro != 0) - { - xrdp_process_delete(pro); - list_remove_item(self->process_list, i); - } - } - return 0; -} - /*****************************************************************************/ /* returns error */ static int APP_CC @@ -195,10 +161,14 @@ xrdp_listen_main_loop(struct xrdp_listen* self) int robjs_count; int cont; char port[8]; - tbus robjs[4]; + tbus robjs[8]; + tbus term_obj; + tbus sync_obj; + tbus sck_obj; + tbus done_obj; + struct xrdp_process* process; self->status = 1; - robjs_count = 0; xrdp_listen_get_port(port, sizeof(port)); self->sck = g_tcp_socket(); g_tcp_set_non_blocking(self->sck); @@ -213,57 +183,99 @@ xrdp_listen_main_loop(struct xrdp_listen* self) error = g_tcp_listen(self->sck); if (error == 0) { - robjs[0] = g_get_term_event(); - robjs[1] = g_get_sync_event(); - robjs[2] = g_create_wait_obj_from_socket(self->sck, 0); - robjs[3] = self->pro_done_event; - robjs_count = 4; + term_obj = g_get_term_event(); + sync_obj = g_get_sync_event(); + sck_obj = g_create_wait_obj_from_socket(self->sck, 0); + done_obj = self->pro_done_event; cont = 1; while (cont) { + /* build the wait obj list */ + robjs_count = 0; + robjs[robjs_count++] = term_obj; + robjs[robjs_count++] = sync_obj; + robjs[robjs_count++] = sck_obj; + robjs[robjs_count++] = done_obj; + /* wait */ if (g_obj_wait(robjs, robjs_count, 0, 0, -1) != 0) { + /* error, should not get here */ g_sleep(100); } - if (g_is_wait_obj_set(robjs[0])) /* term */ + if (g_is_wait_obj_set(term_obj)) /* term */ { break; } - if (g_is_wait_obj_set(robjs[1])) /* sync */ + if (g_is_wait_obj_set(sync_obj)) /* sync */ { - g_reset_wait_obj(robjs[1]); + g_reset_wait_obj(sync_obj); g_loop(); } - if (g_is_wait_obj_set(robjs[2])) /* incomming connection */ + if (g_is_wait_obj_set(sck_obj)) /* incomming connection */ { error = g_tcp_accept(self->sck); if ((error == -1) && g_tcp_last_error_would_block(self->sck)) { + /* should not get here */ g_sleep(100); } else if (error == -1) { + /* error, should not get here */ break; } else { - g_process = xrdp_process_create(self, self->pro_done_event); - if (xrdp_listen_add_pro(self, g_process) == 0) + process = xrdp_process_create(self, self->pro_done_event); + if (xrdp_listen_add_pro(self, process) == 0) { /* start thread */ - g_process->sck = error; + process->sck = error; + g_process = process; tc_thread_create(xrdp_process_run, 0); tc_sem_dec(g_process_sem); /* this will wait */ } else { - xrdp_process_delete(g_process); + xrdp_process_delete(process); } } } - if (g_is_wait_obj_set(robjs[3])) /* pro_done_event */ + if (g_is_wait_obj_set(done_obj)) /* pro_done_event */ { - g_reset_wait_obj(robjs[3]); + g_reset_wait_obj(done_obj); + xrdp_listen_delete_done_pro(self); + } + } + /* stop listening */ + g_delete_wait_obj_from_socket(sck_obj); + g_tcp_close(self->sck); + /* second loop to wait for all process threads to close */ + cont = 1; + while (cont) + { + if (self->process_list->count == 0) + { + break; + } + /* build the wait obj list */ + robjs_count = 0; + robjs[robjs_count++] = sync_obj; + robjs[robjs_count++] = done_obj; + /* wait */ + if (g_obj_wait(robjs, robjs_count, 0, 0, -1) != 0) + { + /* error, should not get here */ + g_sleep(100); + } + if (g_is_wait_obj_set(sync_obj)) /* sync */ + { + g_reset_wait_obj(sync_obj); + g_loop(); + } + if (g_is_wait_obj_set(done_obj)) /* pro_done_event */ + { + g_reset_wait_obj(done_obj); xrdp_listen_delete_done_pro(self); } } @@ -272,8 +284,6 @@ xrdp_listen_main_loop(struct xrdp_listen* self) { DEBUG(("listen error in xrdp_listen_main_loop")); } - xrdp_listen_term_processes(self); - g_tcp_close(self->sck); self->status = -1; return 0; } diff --git a/xrdp/xrdp_login_wnd.c b/xrdp/xrdp_login_wnd.c index 690efd71..bc15d940 100644 --- a/xrdp/xrdp_login_wnd.c +++ b/xrdp/xrdp_login_wnd.c @@ -173,7 +173,7 @@ xrdp_wm_cancel_clicked(struct xrdp_bitmap* wnd) { if (wnd->wm->pro_layer != 0) { - wnd->wm->pro_layer->term = 1; + g_set_wait_obj(wnd->wm->pro_layer->self_term_event); } } } @@ -219,7 +219,7 @@ xrdp_wm_ok_clicked(struct xrdp_bitmap* wnd) /* gota copy these cause dialog gets freed */ list_append_list_strdup(mod_data->names, wm->mm->login_names, 0); list_append_list_strdup(mod_data->values, wm->mm->login_values, 0); - wm->login_mode = 2; + xrdp_wm_set_login_mode(wm, 2); } } return 0; diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c index 7f3b8a2c..9c123d0a 100644 --- a/xrdp/xrdp_mm.c +++ b/xrdp/xrdp_mm.c @@ -89,6 +89,11 @@ xrdp_mm_delete(struct xrdp_mm* self) } /* free any module stuff */ xrdp_mm_module_cleanup(self); + if (self->sck_obj != 0) + { + g_delete_wait_obj_from_socket(self->sck_obj); + self->sck_obj = 0; + } if (self->sck != 0) { g_tcp_close(self->sck); @@ -396,16 +401,16 @@ xrdp_mm_setup_mod2(struct xrdp_mm* self) rv = 1; text[0] = 0; - if (!(self->wm->pro_layer->term)) + if (!g_is_wait_obj_set(self->wm->pro_layer->self_term_event)) { if (self->mod->mod_start(self->mod, self->wm->screen->width, self->wm->screen->height, self->wm->screen->bpp) != 0) { - self->wm->pro_layer->term = 1; /* kill session */ + g_set_wait_obj(self->wm->pro_layer->self_term_event); /* kill session */ } } - if (!(self->wm->pro_layer->term)) + if (!g_is_wait_obj_set(self->wm->pro_layer->self_term_event)) { if (self->display > 0) { @@ -419,11 +424,11 @@ xrdp_mm_setup_mod2(struct xrdp_mm* self) } else { - self->wm->pro_layer->term = 1; /* kill session */ + g_set_wait_obj(self->wm->pro_layer->self_term_event); /* kill session */ } } } - if (!(self->wm->pro_layer->term)) + if (!g_is_wait_obj_set(self->wm->pro_layer->self_term_event)) { /* this adds the port to the end of the list, it will already be in the list as -1 @@ -500,8 +505,7 @@ xrdp_mm_process_login_response(struct xrdp_mm* self, struct stream* s) { if (xrdp_mm_setup_mod2(self) == 0) { - self->wm->login_mode = 10; - self->wm->pro_layer->app_sck = self->mod->sck; + xrdp_wm_set_login_mode(self->wm, 10); self->wm->dragging = 0; } } @@ -511,13 +515,14 @@ xrdp_mm_process_login_response(struct xrdp_mm* self, struct stream* s) xrdp_wm_log_msg(self->wm, "login failed"); } /* close socket */ + g_delete_wait_obj_from_socket(self->sck_obj); + self->sck_obj = 0; g_tcp_close(self->sck); self->sck = 0; self->connected_state = 0; if (self->wm->login_mode != 10) { - self->wm->pro_layer->app_sck = 0; - self->wm->login_mode = 11; + xrdp_wm_set_login_mode(self->wm, 11); xrdp_mm_module_cleanup(self); } return rv; @@ -567,6 +572,7 @@ xrdp_mm_connect(struct xrdp_mm* self) ok = 0; errstr[0] = 0; self->sck = g_tcp_socket(); + self->sck_obj = g_create_wait_obj_from_socket(self->sck, 0); g_tcp_set_non_blocking(self->sck); g_snprintf(text, 255, "connecting to sesman ip %s port 3350", ip); xrdp_wm_log_msg(self->wm, text); @@ -604,12 +610,13 @@ xrdp_mm_connect(struct xrdp_mm* self) /* fully connect */ xrdp_wm_log_msg(self->wm, "sesman connect ok"); self->connected_state = 1; - self->wm->pro_layer->app_sck = self->sck; rv = xrdp_mm_send_login(self); } else { xrdp_wm_log_msg(self->wm, errstr); + g_delete_wait_obj_from_socket(self->sck_obj); + self->sck_obj = 0; g_tcp_close(self->sck); self->sck = 0; rv = 1; @@ -621,14 +628,12 @@ xrdp_mm_connect(struct xrdp_mm* self) { if (xrdp_mm_setup_mod2(self) == 0) { - self->wm->login_mode = 10; - self->wm->pro_layer->app_sck = self->mod->sck; + xrdp_wm_set_login_mode(self->wm, 10); } } if (self->wm->login_mode != 10) { - self->wm->pro_layer->app_sck = 0; - self->wm->login_mode = 11; + xrdp_wm_set_login_mode(self->wm, 11); xrdp_mm_module_cleanup(self); } } diff --git a/xrdp/xrdp_process.c b/xrdp/xrdp_process.c index d2e0aaeb..50c8cbbb 100644 --- a/xrdp/xrdp_process.c +++ b/xrdp/xrdp_process.c @@ -22,15 +22,24 @@ #include "xrdp.h" +static int g_session_id = 0; + /*****************************************************************************/ +/* always called from xrdp_listen thread */ struct xrdp_process* APP_CC xrdp_process_create(struct xrdp_listen* owner, tbus done_event) { struct xrdp_process* self; + char event_name[64]; self = (struct xrdp_process*)g_malloc(sizeof(struct xrdp_process), 1); self->lis_layer = owner; self->done_event = done_event; + g_session_id++; + self->session_id = g_session_id; + g_snprintf(event_name, 63, "xrdp_process_self_term_event_%8.8x", + self->session_id); + self->self_term_event = g_create_wait_obj(event_name); return self; } @@ -42,6 +51,7 @@ xrdp_process_delete(struct xrdp_process* self) { return; } + g_delete_wait_obj(self->self_term_event); libxrdp_exit(self->session); xrdp_wm_delete(self->wm); g_free(self); @@ -63,7 +73,8 @@ xrdp_process_loop(struct xrdp_process* self) DEBUG(("calling xrdp_wm_init and creating wm")); self->wm = xrdp_wm_create(self, self->session->client_info); /* at this point the wm(window manager) is create and wm::login_mode is - zero so xrdp_wm_init should be called by xrdp_wm_idle */ + zero and login_mode_event is set so xrdp_wm_init should be called by + xrdp_wm_check_wait_objs */ } return rv; } @@ -77,11 +88,38 @@ xrdp_is_term(void) return g_is_term(); } +/*****************************************************************************/ +static int APP_CC +xrdp_process_mod_end(struct xrdp_process* self) +{ + if (self->wm != 0) + { + if (self->wm->mm != 0) + { + if (self->wm->mm->mod != 0) + { + if (self->wm->mm->mod->mod_end != 0) + { + return self->wm->mm->mod->mod_end(self->wm->mm->mod); + } + } + } + } + return 0; +} + /*****************************************************************************/ int APP_CC xrdp_process_main_loop(struct xrdp_process* self) { - int sel_r; + int robjs_count; + int wobjs_count; + int cont; + int timeout; + tbus robjs[32]; + tbus wobjs[32]; + tbus term_obj; + tbus sck_obj; self->status = 1; self->session = libxrdp_init((long)self, self->sck); @@ -93,48 +131,50 @@ xrdp_process_main_loop(struct xrdp_process* self) g_tcp_set_no_delay(self->sck); if (libxrdp_process_incomming(self->session) == 0) { - while (!g_is_term() && !self->term) + term_obj = g_get_term_event(); + sck_obj = g_create_wait_obj_from_socket(self->sck, 0); + cont = 1; + while (cont) { - sel_r = g_tcp_select(self->sck, self->app_sck); - if (sel_r == 0) /* no data on any stream */ + /* build the wait obj list */ + timeout = -1; + robjs_count = 0; + wobjs_count = 0; + robjs[robjs_count++] = term_obj; + robjs[robjs_count++] = sck_obj; + robjs[robjs_count++] = self->self_term_event; + xrdp_wm_get_wait_objs(self->wm, robjs, &robjs_count, + wobjs, &wobjs_count, &timeout); + /* wait */ + if (g_obj_wait(robjs, robjs_count, wobjs, wobjs_count, timeout) != 0) { - xrdp_wm_idle(self->wm); + /* error, should not get here */ + g_sleep(100); } - else if (sel_r < 0) + if (g_is_wait_obj_set(term_obj)) /* term */ { break; } - if (sel_r & 1) + if (g_is_wait_obj_set(self->self_term_event)) + { + break; + } + if (g_is_wait_obj_set(sck_obj)) /* incomming client data */ { if (xrdp_process_loop(self) != 0) { break; } } - if (sel_r & 2) /* mod socket fired */ + if (xrdp_wm_check_wait_objs(self->wm) != 0) { - if (xrdp_wm_app_sck_signal(self->wm, self->app_sck) != 0) - { - break; - } + break; } } + g_delete_wait_obj_from_socket(sck_obj); libxrdp_disconnect(self->session); - g_sleep(500); - } - if (self->wm != 0) - { - if (self->wm->mm != 0) - { - if (self->wm->mm->mod != 0) - { - if (self->wm->mm->mod->mod_end != 0) - { - self->wm->mm->mod->mod_end(self->wm->mm->mod); - } - } - } } + xrdp_process_mod_end(self); libxrdp_exit(self->session); self->session = 0; g_tcp_close(self->sck); diff --git a/xrdp/xrdp_types.h b/xrdp/xrdp_types.h index c1178366..20884b1b 100644 --- a/xrdp/xrdp_types.h +++ b/xrdp/xrdp_types.h @@ -33,7 +33,11 @@ struct xrdp_mod int (*mod_signal)(struct xrdp_mod* v); int (*mod_end)(struct xrdp_mod* v); int (*mod_set_param)(struct xrdp_mod* v, char* name, char* value); - long mod_dumby[100 - 6]; /* align, 100 minus the number of mod + int (*mod_session_change)(struct xrdp_mod* v, int, int); + int (*mod_get_wait_objs)(struct xrdp_mod* v, tbus* read_objs, int* rcount, + tbus* write_objs, int* wcount, int* timeout); + int (*mod_check_wait_objs)(struct xrdp_mod* v); + long mod_dumby[100 - 9]; /* align, 100 minus the number of mod functions above */ /* server functions */ int (*server_begin_update)(struct xrdp_mod* v); @@ -160,6 +164,7 @@ struct xrdp_mm struct xrdp_wm* wm; /* owner */ int connected_state; int sck; + tbus sck_obj; int sck_closed; struct list* login_names; struct list* login_values; @@ -233,6 +238,7 @@ struct xrdp_wm struct list* log; struct xrdp_bitmap* log_wnd; int login_mode; + tbus login_mode_event; struct xrdp_mm* mm; struct xrdp_font* default_font; struct xrdp_keymap keymap; @@ -243,13 +249,14 @@ struct xrdp_process { int status; int sck; - int term; + tbus self_term_event; struct xrdp_listen* lis_layer; /* owner */ struct xrdp_session* session; /* create these when up and running */ struct xrdp_wm* wm; int app_sck; tbus done_event; + int session_id; }; /* rdp listener */ diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c index 1918e4ab..fe432825 100644 --- a/xrdp/xrdp_wm.c +++ b/xrdp/xrdp_wm.c @@ -28,6 +28,7 @@ xrdp_wm_create(struct xrdp_process* owner, struct xrdp_client_info* client_info) { struct xrdp_wm* self; + char event_name[64]; self = (struct xrdp_wm*)g_malloc(sizeof(struct xrdp_wm), 1); self->client_info = client_info; @@ -38,6 +39,9 @@ xrdp_wm_create(struct xrdp_process* owner, self->screen->wm = self; self->pro_layer = owner; self->session = owner->session; + g_snprintf(event_name, 63, "xrdp_wm_login_mode_event_%8.8x", + owner->session_id); + self->login_mode_event = g_create_wait_obj(event_name); self->painter = xrdp_painter_create(self, self->session); self->cache = xrdp_cache_create(self, self->session, self->client_info); self->log = list_create(); @@ -46,6 +50,7 @@ xrdp_wm_create(struct xrdp_process* owner, self->default_font = xrdp_font_create(self); /* this will use built in keymap or load from file */ get_keymaps(self->session->client_info->keylayout, &(self->keymap)); + xrdp_wm_set_login_mode(self, 0); return self; } @@ -65,6 +70,7 @@ xrdp_wm_delete(struct xrdp_wm* self) list_delete(self->log); /* free default font */ xrdp_font_delete(self->default_font); + g_delete_wait_obj(self->login_mode_event); /* free self */ g_free(self); } @@ -404,7 +410,7 @@ xrdp_wm_init(struct xrdp_wm* self) list_add_item(self->mm->login_values, (long)g_strdup(r)); } } - self->login_mode = 2; + xrdp_wm_set_login_mode(self, 2); } list_delete(names); list_delete(values); @@ -417,7 +423,7 @@ xrdp_wm_init(struct xrdp_wm* self) /* clear screen */ xrdp_bitmap_invalidate(self->screen, 0); xrdp_wm_set_focused(self, self->login_window); - self->login_mode = 1; + xrdp_wm_set_login_mode(self, 1); } return 0; } @@ -1290,10 +1296,9 @@ callback(long id, int msg, long param1, long param2, long param3, long param4) /******************************************************************************/ /* returns error */ /* this gets called when there is nothing on any socket */ -int APP_CC -xrdp_wm_idle(struct xrdp_wm* self) +static int APP_CC +xrdp_wm_login_mode_changed(struct xrdp_wm* self) { - g_sleep(10); if (self == 0) { return 0; @@ -1301,7 +1306,7 @@ xrdp_wm_idle(struct xrdp_wm* self) if (self->login_mode == 0) { /* this is the inital state of the login window */ - self->login_mode = 1; /* put the wm in login mode */ + xrdp_wm_set_login_mode(self, 1); /* put the wm in login mode */ list_clear(self->log); xrdp_wm_delete_all_childs(self); self->dragging = 0; @@ -1309,7 +1314,7 @@ xrdp_wm_idle(struct xrdp_wm* self) } else if (self->login_mode == 2) { - self->login_mode = 3; /* put the wm in connected mode */ + xrdp_wm_set_login_mode(self, 3); /* put the wm in connected mode */ xrdp_wm_delete_all_childs(self); self->dragging = 0; xrdp_mm_connect(self->mm); @@ -1318,7 +1323,7 @@ xrdp_wm_idle(struct xrdp_wm* self) { xrdp_wm_delete_all_childs(self); self->dragging = 0; - self->login_mode = 11; + xrdp_wm_set_login_mode(self, 11); } return 0; } @@ -1392,7 +1397,7 @@ xrdp_wm_log_wnd_notify(struct xrdp_bitmap* wnd, { /* make sure autologin is off */ wm->session->client_info->rdp_autologin = 0; - wm->login_mode = 0; /* reset session */ + xrdp_wm_set_login_mode(wm, 0); /* reset session */ } } } @@ -1450,3 +1455,107 @@ xrdp_wm_log_msg(struct xrdp_wm* self, char* msg) g_sleep(100); return 0; } + +/*****************************************************************************/ +static int APP_CC +xrdp_wm_mod_get_wait_objs(struct xrdp_wm* self, + tbus* read_objs, int* rcount, + tbus* write_objs, int* wcount, int* timeout) +{ + if (self->mm != 0) + { + if (self->mm->mod != 0) + { + if (self->mm->mod->mod_get_wait_objs != 0) + { + return self->mm->mod->mod_get_wait_objs + (self->mm->mod, read_objs, rcount, + write_objs, wcount, timeout); + } + } + } + return 0; +} + +/*****************************************************************************/ +static int APP_CC +xrdp_wm_mod_check_wait_objs(struct xrdp_wm* self) +{ + if (self->mm != 0) + { + if (self->mm->mod != 0) + { + if (self->mm->mod->mod_check_wait_objs != 0) + { + return self->mm->mod->mod_check_wait_objs(self->mm->mod); + } + } + } + return 0; +} + +/*****************************************************************************/ +int APP_CC +xrdp_wm_get_wait_objs(struct xrdp_wm* self, tbus* robjs, int* rc, + tbus* wobjs, int* wc, int* timeout) +{ + int i; + + if (self == 0) + { + return 0; + } + i = *rc; + robjs[i++] = self->login_mode_event; + if (self->mm != 0) + { + if (self->mm->sck_obj != 0) + { + robjs[i++] = self->mm->sck_obj; + } + } + *rc = i; + return xrdp_wm_mod_get_wait_objs(self, robjs, rc, wobjs, wc, timeout); +} + +/******************************************************************************/ +int APP_CC +xrdp_wm_check_wait_objs(struct xrdp_wm* self) +{ + int rv; + + if (self == 0) + { + return 0; + } + rv = 0; + if (g_is_wait_obj_set(self->login_mode_event)) + { + g_reset_wait_obj(self->login_mode_event); + xrdp_wm_login_mode_changed(self); + } + if (self->mm != 0) + { + if (self->mm->sck_obj != 0) + { + if (g_is_wait_obj_set(self->mm->sck_obj)) + { + rv = xrdp_mm_signal(self->mm); + } + } + } + if (rv == 0) + { + rv = xrdp_wm_mod_check_wait_objs(self); + } + return rv; +} + +/*****************************************************************************/ +int APP_CC +xrdp_wm_set_login_mode(struct xrdp_wm* self, int login_mode) +{ + self->login_mode = login_mode; + g_set_wait_obj(self->login_mode_event); + return 0; +}