diff options
author | jsorg71 <jsorg71> | 2009-08-21 17:30:14 +0000 |
---|---|---|
committer | jsorg71 <jsorg71> | 2009-08-21 17:30:14 +0000 |
commit | c7838641cfb169bb09872ec676fb240db4846534 (patch) | |
tree | 13afe33b902aaf0301c02b9bea71d09517d4d24f /sesman | |
parent | 359a1908509f213372987c314b13e963bbb9961a (diff) | |
download | xrdp-proprietary-c7838641cfb169bb09872ec676fb240db4846534.tar.gz xrdp-proprietary-c7838641cfb169bb09872ec676fb240db4846534.zip |
handle X server crash better
Diffstat (limited to 'sesman')
-rw-r--r-- | sesman/chansrv/chansrv.c | 23 | ||||
-rw-r--r-- | sesman/chansrv/clipboard.c | 35 |
2 files changed, 29 insertions, 29 deletions
diff --git a/sesman/chansrv/chansrv.c b/sesman/chansrv/chansrv.c index d1f8c3d2..8e6c83b6 100644 --- a/sesman/chansrv/chansrv.c +++ b/sesman/chansrv/chansrv.c @@ -17,6 +17,7 @@ Copyright (C) Jay Sorg 2009 */ +#include <X11/Xlib.h> #include "arch.h" #include "os_calls.h" #include "thread_calls.h" @@ -42,6 +43,8 @@ int g_cliprdr_chan_id = -1; /* cliprdr */ int g_rdpsnd_chan_id = -1; /* rdpsnd */ int g_rdpdr_chan_id = -1; /* rdpdr */ +Display* g_display = 0; + /*****************************************************************************/ /* returns error */ int APP_CC @@ -551,6 +554,19 @@ get_display_num_from_display(char* display_text) } /*****************************************************************************/ +/* The X server had an internal error. This is the last function called. + Do any cleanup that needs to be done on exit, like removing temporary files. + Don't worry about memory leaks */ +int DEFAULT_CC +my_fatal_handler(Display* dis) +{ + g_writeln("xrdp-chansrv: fatal error, exiting"); + g_delete_wait_obj(g_term_event); + g_delete_wait_obj(g_thread_done_event); + return 0; +} + +/*****************************************************************************/ int DEFAULT_CC main(int argc, char** argv) { @@ -574,6 +590,13 @@ main(int argc, char** argv) return 1; } g_writeln("xrdp-chansrv: main: using DISPLAY %d", g_display_num); + g_display = XOpenDisplay(0); + if (g_display == 0) + { + g_writeln("xrdp-chansrv: main: XOpenDisplay failed"); + return 1; + } + XSetIOErrorHandler(my_fatal_handler); g_snprintf(text, 255, "xrdp_chansrv_%8.8x_main_term", pid); g_term_event = g_create_wait_obj(text); g_snprintf(text, 255, "xrdp_chansrv_%8.8x_thread_done", pid); diff --git a/sesman/chansrv/clipboard.c b/sesman/chansrv/clipboard.c index d9dcd60d..00c13193 100644 --- a/sesman/chansrv/clipboard.c +++ b/sesman/chansrv/clipboard.c @@ -30,7 +30,6 @@ #include "os_calls.h" #include "chansrv.h" -static Display* g_display = 0; static Atom g_clipboard_atom = 0; static Atom g_clip_property_atom = 0; static Atom g_timestamp_atom = 0; @@ -45,7 +44,6 @@ static Window g_wnd = 0; static Screen* g_screen = 0; static int g_screen_num = 0; static int g_xfixes_event_base = 0; -static int g_sck_closed = 0; static int g_last_clip_size = 0; static char* g_last_clip_data = 0; @@ -55,6 +53,7 @@ static int g_got_selection = 0; /* boolean */ static Time g_selection_time = 0; extern int g_cliprdr_chan_id; /* in chansrv.c */ +extern Display* g_display; /*****************************************************************************/ /* returns time in miliseconds @@ -86,13 +85,6 @@ clipboard_init(void) return 0; } rv = 0; - g_sleep(500); - g_display = XOpenDisplay(0); - if (g_display == 0) - { - g_writeln("xrdp-chansrv: clipboard_init: XOpenDisplay failed"); - rv = 1; - } if (rv == 0) { g_x_socket = XConnectionNumber(g_display); @@ -185,17 +177,11 @@ clipboard_deinit(void) { return 0; } - if (!g_sck_closed) - { - g_delete_wait_obj_from_socket(g_x_wait_obj); - g_x_wait_obj = 0; - XDestroyWindow(g_display, g_wnd); - g_wnd = 0; - XCloseDisplay(g_display); - g_display = 0; - g_x_socket = 0; - g_sck_closed = 1; - } + g_delete_wait_obj_from_socket(g_x_wait_obj); + g_x_wait_obj = 0; + XDestroyWindow(g_display, g_wnd); + g_wnd = 0; + g_x_socket = 0; g_free(g_last_clip_data); g_last_clip_data = 0; g_clip_up = 0; @@ -700,10 +686,6 @@ clipboard_get_wait_objs(tbus* objs, int* count, int* timeout) { return 0; } - if (g_sck_closed) - { - return 0; - } lcount = *count; objs[lcount] = g_x_wait_obj; lcount++; @@ -721,17 +703,12 @@ clipboard_check_wait_objs(void) { return 0; } - if (g_sck_closed) - { - return 0; - } if (g_is_wait_obj_set(g_x_wait_obj)) { if (XPending(g_display) < 1) { /* something is wrong, should not get here */ g_writeln("xrdp-chansrv: clipboard_check_wait_objs: sck closed"); - g_sck_closed = 1; return 0; } while (XPending(g_display) > 0) |