diff options
author | jsorg71 <jsorg71> | 2005-08-18 00:32:11 +0000 |
---|---|---|
committer | jsorg71 <jsorg71> | 2005-08-18 00:32:11 +0000 |
commit | 9d2ce459daf384586ad7f9f24a8847eafe84108e (patch) | |
tree | 60b48ad4a5122cc556797d571c9f276085ed619b /xrdp/xrdp.c | |
parent | a4ce4c46c6479746ece90e78ffc7ffbfd60ff349 (diff) | |
download | xrdp-proprietary-9d2ce459daf384586ad7f9f24a8847eafe84108e.tar.gz xrdp-proprietary-9d2ce459daf384586ad7f9f24a8847eafe84108e.zip |
add new painter funcs
Diffstat (limited to 'xrdp/xrdp.c')
-rw-r--r-- | xrdp/xrdp.c | 113 |
1 files changed, 103 insertions, 10 deletions
diff --git a/xrdp/xrdp.c b/xrdp/xrdp.c index 52f8ac5a..28118d6d 100644 --- a/xrdp/xrdp.c +++ b/xrdp/xrdp.c @@ -32,13 +32,59 @@ static int g_threadid = 0; /* main threadid */ #if defined(_WIN32) static CRITICAL_SECTION g_term_mutex; +static CRITICAL_SECTION g_sync_mutex; +static CRITICAL_SECTION g_sync1_mutex; #else static pthread_mutex_t g_term_mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t g_sync_mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t g_sync1_mutex = PTHREAD_MUTEX_INITIALIZER; #endif static int g_term = 0; +/* syncronize stuff */ +static int g_sync_command = 0; +static long g_sync_result = 0; +static long g_sync_param1 = 0; +static long g_sync_param2 = 0; +static long (*g_sync_func)(long param1, long param2); /*****************************************************************************/ -void +long APP_CC +g_xrdp_sync(long (*sync_func)(long param1, long param2), long sync_param1, + long sync_param2) +{ + long sync_result; + int sync_command; + +#if defined(_WIN32) + EnterCriticalSection(&g_sync1_mutex); +#else + pthread_mutex_lock(&g_sync1_mutex); +#endif + g_lock(); + g_sync_param1 = sync_param1; + g_sync_param2 = sync_param2; + g_sync_func = sync_func; + g_sync_command = 100; + g_unlock(); + do + { + g_sleep(100); + g_lock(); + sync_command = g_sync_command; + sync_result = g_sync_result; + g_unlock(); + } + while (sync_command != 0); +#if defined(_WIN32) + LeaveCriticalSection(&g_sync1_mutex); +#else + pthread_mutex_unlock(&g_sync1_mutex); +#endif + return sync_result; +} + +/*****************************************************************************/ +void DEFAULT_CC xrdp_shutdown(int sig) { struct xrdp_listen* listen; @@ -56,15 +102,11 @@ xrdp_shutdown(int sig) g_set_term(1); g_sleep(1000); xrdp_listen_delete(listen); -#if defined(_WIN32) - WSACleanup(); - DeleteCriticalSection(&g_term_mutex); -#endif } } /*****************************************************************************/ -int +int APP_CC g_is_term(void) { int rv; @@ -82,7 +124,29 @@ g_is_term(void) } /*****************************************************************************/ -void +void APP_CC +g_lock(void) +{ +#if defined(_WIN32) + EnterCriticalSection(&g_sync_mutex); +#else + pthread_mutex_lock(&g_sync_mutex); +#endif +} + +/*****************************************************************************/ +void APP_CC +g_unlock(void) +{ +#if defined(_WIN32) + LeaveCriticalSection(&g_sync_mutex); +#else + pthread_mutex_unlock(&g_sync_mutex); +#endif +} + +/*****************************************************************************/ +void APP_CC g_set_term(int in_val) { #if defined(_WIN32) @@ -97,7 +161,7 @@ g_set_term(int in_val) } /*****************************************************************************/ -void +void DEFAULT_CC pipe_sig(int sig_num) { /* do nothing */ @@ -105,7 +169,26 @@ pipe_sig(int sig_num) } /*****************************************************************************/ -int +void APP_CC +g_loop(void) +{ + g_lock(); + if (g_sync_command != 0) + { + if (g_sync_func != 0) + { + if (g_sync_command == 100) + { + g_sync_result = g_sync_func(g_sync_param1, g_sync_param2); + } + } + g_sync_command = 0; + } + g_unlock(); +} + +/*****************************************************************************/ +int DEFAULT_CC main(int argc, char** argv) { int test; @@ -113,7 +196,7 @@ main(int argc, char** argv) #if defined(_WIN32) WSADATA w; #endif - + /* check compiled endian with actual edian */ test = 1; host_be = !((int)(*(unsigned char*)(&test))); @@ -141,6 +224,8 @@ main(int argc, char** argv) #if defined(_WIN32) WSAStartup(2, &w); InitializeCriticalSection(&g_term_mutex); + InitializeCriticalSection(&g_sync_mutex); + InitializeCriticalSection(&g_sync1_mutex); #endif g_threadid = g_get_threadid(); g_listen = xrdp_listen_create(); @@ -149,5 +234,13 @@ main(int argc, char** argv) g_signal(13, pipe_sig); /* sig pipe */ g_signal(15, xrdp_shutdown); /* SIGTERM */ xrdp_listen_main_loop(g_listen); +#if defined(_WIN32) + /* I don't think it ever gets here */ + WSACleanup(); + DeleteCriticalSection(&g_term_mutex); + DeleteCriticalSection(&g_sync_mutex); + DeleteCriticalSection(&g_sync1_mutex); + xrdp_listen_delete(g_listen); +#endif return 0; } |