From 9317386e74c10362a4b95b250dcd8d353a3fca5f Mon Sep 17 00:00:00 2001 From: jsorg71 Date: Mon, 1 Dec 2008 09:37:08 +0000 Subject: [PATCH] add pid to event names --- common/os_calls.c | 5 ++--- xrdp/xrdp.c | 18 +++++++++++++----- xrdp/xrdp_listen.c | 6 +++++- xrdp/xrdp_process.c | 8 +++++--- xrdp/xrdp_wm.c | 8 +++++--- 5 files changed, 30 insertions(+), 15 deletions(-) diff --git a/common/os_calls.c b/common/os_calls.c index c29200ea..84bba282 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -1864,14 +1864,13 @@ g_exit(int exit_code) } /*****************************************************************************/ -/* does not work in win32 */ int APP_CC g_getpid(void) { #if defined(_WIN32) - return 0; + return (int)GetCurrentProcessId(); #else - return getpid(); + return (int)getpid(); #endif } diff --git a/xrdp/xrdp.c b/xrdp/xrdp.c index 344a80b7..64ac6cb5 100644 --- a/xrdp/xrdp.c +++ b/xrdp/xrdp.c @@ -204,6 +204,8 @@ VOID WINAPI MyServiceMain(DWORD dwArgc, LPTSTR* lpszArgv) { WSADATA w; + char text[256]; + int pid; //HANDLE event_han; // int fd; // char text[256]; @@ -218,8 +220,11 @@ MyServiceMain(DWORD dwArgc, LPTSTR* lpszArgv) WSAStartup(2, &w); g_sync_mutex = tc_mutex_create(); g_sync1_mutex = tc_mutex_create(); - g_term_event = g_create_wait_obj("xrdp_main_term"); - g_sync_event = g_create_wait_obj("xrdp_main_sync"); + pid = g_getpid(); + g_snprintf(text, 255, "xrdp_%8.8x_main_term", pid); + g_term_event = g_create_wait_obj(text); + g_snprintf(text, 255, "xrdp_%8.8x_main_sync", pid); + g_sync_event = g_create_wait_obj(text); g_memset(&g_service_status, 0, sizeof(SERVICE_STATUS)); g_service_status.dwServiceType = SERVICE_WIN32_OWN_PROCESS; g_service_status.dwCurrentState = SERVICE_RUNNING; @@ -275,7 +280,7 @@ main(int argc, char** argv) int pid; int fd; int no_daemon; - char text[32]; + char text[256]; #endif g_init(); @@ -567,8 +572,11 @@ main(int argc, char** argv) g_signal(15, xrdp_shutdown); /* SIGTERM */ g_sync_mutex = tc_mutex_create(); g_sync1_mutex = tc_mutex_create(); - g_term_event = g_create_wait_obj("xrdp_main_term"); - g_sync_event = g_create_wait_obj("xrdp_main_sync"); + pid = g_getpid(); + g_snprintf(text, 255, "xrdp_%8.8x_main_term", pid); + g_term_event = g_create_wait_obj(text); + g_snprintf(text, 255, "xrdp_%8.8x_main_sync", pid); + g_sync_event = g_create_wait_obj(text); if (g_term_event == 0) { g_writeln("error creating g_term_event"); diff --git a/xrdp/xrdp_listen.c b/xrdp/xrdp_listen.c index 4526d147..600feaf2 100644 --- a/xrdp/xrdp_listen.c +++ b/xrdp/xrdp_listen.c @@ -32,9 +32,13 @@ struct xrdp_listen* APP_CC xrdp_listen_create(void) { struct xrdp_listen* self; + int pid; + char text[256]; + pid = g_getpid(); self = (struct xrdp_listen*)g_malloc(sizeof(struct xrdp_listen), 1); - self->pro_done_event = g_create_wait_obj("xrdp_listen_pro_done_event"); + g_snprintf(text, 255, "xrdp_%8.8x_listen_pro_done_event", pid); + self->pro_done_event = g_create_wait_obj(text); self->process_list = list_create(); if (g_process_sem == 0) { diff --git a/xrdp/xrdp_process.c b/xrdp/xrdp_process.c index 50c8cbbb..fdc7974b 100644 --- a/xrdp/xrdp_process.c +++ b/xrdp/xrdp_process.c @@ -30,15 +30,17 @@ struct xrdp_process* APP_CC xrdp_process_create(struct xrdp_listen* owner, tbus done_event) { struct xrdp_process* self; - char event_name[64]; + char event_name[256]; + int pid; 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); + pid = g_getpid(); + g_snprintf(event_name, 255, "xrdp_%8.8x_process_self_term_event_%8.8x", + pid, self->session_id); self->self_term_event = g_create_wait_obj(event_name); return self; } diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c index 1d09cf69..3a7c52ab 100644 --- a/xrdp/xrdp_wm.c +++ b/xrdp/xrdp_wm.c @@ -28,7 +28,8 @@ xrdp_wm_create(struct xrdp_process* owner, struct xrdp_client_info* client_info) { struct xrdp_wm* self; - char event_name[64]; + char event_name[256]; + int pid; self = (struct xrdp_wm*)g_malloc(sizeof(struct xrdp_wm), 1); self->client_info = client_info; @@ -39,8 +40,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); + pid = g_getpid(); + g_snprintf(event_name, 255, "xrdp_%8.8x_wm_login_mode_event_%8.8x", + pid, 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);