diff options
author | norrarvid <norrarvid@gmail.com> | 2012-05-29 13:24:23 +0200 |
---|---|---|
committer | norrarvid <norrarvid@gmail.com> | 2012-05-29 13:24:23 +0200 |
commit | 2109d7a044430ee4ad5b51f2c18cc496be0e7fd8 (patch) | |
tree | 17d9b9852a05fe9f9a67540670bef1b3c3d14b69 /xrdp/xrdp_listen.c | |
parent | 60b052965634be151d88f7011149d0edc71f23d8 (diff) | |
parent | a45f993bfe74aed27245454f1ae32302b0528d9f (diff) | |
download | xrdp-proprietary-2109d7a044430ee4ad5b51f2c18cc496be0e7fd8.tar.gz xrdp-proprietary-2109d7a044430ee4ad5b51f2c18cc496be0e7fd8.zip |
merge comments defines and simplified function
Diffstat (limited to 'xrdp/xrdp_listen.c')
-rw-r--r-- | xrdp/xrdp_listen.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/xrdp/xrdp_listen.c b/xrdp/xrdp_listen.c index bbdd729a..b79ce1c2 100644 --- a/xrdp/xrdp_listen.c +++ b/xrdp/xrdp_listen.c @@ -37,6 +37,10 @@ xrdp_listen_create_pro_done(struct xrdp_listen* self) pid = g_getpid(); g_snprintf(text, 255, "xrdp_%8.8x_listen_pro_done_event", pid); self->pro_done_event = g_create_wait_obj(text); + if(self->pro_done_event == 0) + { + g_writeln("Failure creating pro_done_event"); + } return 0; } @@ -295,7 +299,7 @@ xrdp_listen_main_loop(struct xrdp_listen* self) { self->listen_trans->trans_conn_in = xrdp_listen_conn_in; self->listen_trans->callback_data = self; - term_obj = g_get_term_event(); + term_obj = g_get_term_event(); /*Global termination event */ sync_obj = g_get_sync_event(); done_obj = self->pro_done_event; cont = 1; @@ -307,31 +311,33 @@ xrdp_listen_main_loop(struct xrdp_listen* self) robjs[robjs_count++] = sync_obj; robjs[robjs_count++] = done_obj; timeout = -1; - if (trans_get_wait_objs(self->listen_trans, robjs, &robjs_count, - &timeout) != 0) + if (trans_get_wait_objs(self->listen_trans, robjs, &robjs_count) != 0) { + g_writeln("Listening socket is in wrong state we terminate listener") ; break; } - /* wait */ + /* wait - timeout -1 means wait indefinitely*/ if (g_obj_wait(robjs, robjs_count, 0, 0, timeout) != 0) { /* error, should not get here */ g_sleep(100); } - if (g_is_wait_obj_set(term_obj)) /* term */ + if (g_is_wait_obj_set(term_obj)) /* termination called */ { break; } - if (g_is_wait_obj_set(sync_obj)) /* sync */ + if (g_is_wait_obj_set(sync_obj)) /* some function must be processed by this thread */ { g_reset_wait_obj(sync_obj); - g_loop(); + g_process_waiting_function(); /* run the function */ } if (g_is_wait_obj_set(done_obj)) /* pro_done_event */ { - g_reset_wait_obj(done_obj); + g_reset_wait_obj(done_obj); + /* a process has died remove it from lists*/ xrdp_listen_delete_done_pro(self); } + /* Run the callback when accept() returns a new socket*/ if (trans_check_wait_objs(self->listen_trans) != 0) { break; @@ -348,20 +354,21 @@ xrdp_listen_main_loop(struct xrdp_listen* self) { break; } + timeout = -1; /* 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) + /* wait - timeout -1 means wait indefinitely*/ + if (g_obj_wait(robjs, robjs_count, 0, 0, timeout) != 0) { /* error, should not get here */ g_sleep(100); } - if (g_is_wait_obj_set(sync_obj)) /* sync */ + if (g_is_wait_obj_set(sync_obj)) /* some function must be processed by this thread */ { g_reset_wait_obj(sync_obj); - g_loop(); + g_process_waiting_function(); /* run the function that is waiting*/ } if (g_is_wait_obj_set(done_obj)) /* pro_done_event */ { |