summaryrefslogtreecommitdiffstats
path: root/xrdp/xrdp_listen.c
diff options
context:
space:
mode:
authorArvidNorr <norrarvid@gmail.com>2012-06-17 23:14:40 -0700
committerArvidNorr <norrarvid@gmail.com>2012-06-17 23:14:40 -0700
commit1011b4a25656fed871ddb6e8d782f65fa0e97d9f (patch)
treeb67ba22d0ca3151c24eaa4409b3cbe1e49af6c85 /xrdp/xrdp_listen.c
parent4ba8cdc343d96cd449c18c107f623e8e73d2d470 (diff)
parent31a5dd33ddfa86e195469dff776e7ca1cf4d7b06 (diff)
downloadxrdp-proprietary-1011b4a25656fed871ddb6e8d782f65fa0e97d9f.tar.gz
xrdp-proprietary-1011b4a25656fed871ddb6e8d782f65fa0e97d9f.zip
Merge pull request #22 from ArvidNorr/moduleload
Moduleload
Diffstat (limited to 'xrdp/xrdp_listen.c')
-rw-r--r--xrdp/xrdp_listen.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/xrdp/xrdp_listen.c b/xrdp/xrdp_listen.c
index 312ae5e4..f6dba5c8 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;
}
@@ -294,7 +298,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;
@@ -306,31 +310,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;
@@ -347,20 +353,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 */
{