diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/xterm.c | 100 |
1 files changed, 8 insertions, 92 deletions
diff --git a/src/xterm.c b/src/xterm.c index 991b66995cf..d798f10fb1c 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -121,10 +121,6 @@ extern void _XEditResCheckMessages (); | |||
| 121 | #include <string.h> | 121 | #include <string.h> |
| 122 | #endif | 122 | #endif |
| 123 | 123 | ||
| 124 | #ifdef SOLARIS2 | ||
| 125 | #define X_CONNECTION_LOCK_FLAG XlibDisplayWriting | ||
| 126 | #endif | ||
| 127 | |||
| 128 | #ifndef min | 124 | #ifndef min |
| 129 | #define min(a,b) ((a)<(b) ? (a) : (b)) | 125 | #define min(a,b) ((a)<(b) ? (a) : (b)) |
| 130 | #endif | 126 | #endif |
| @@ -4580,55 +4576,19 @@ x_io_error_quitter (display) | |||
| 4580 | 4576 | ||
| 4581 | /* Handle SIGPIPE, which can happen when the connection to a server | 4577 | /* Handle SIGPIPE, which can happen when the connection to a server |
| 4582 | simply goes away. SIGPIPE is handled by x_connection_signal. | 4578 | simply goes away. SIGPIPE is handled by x_connection_signal. |
| 4583 | It works by sending a no-op command to each X server connection. | 4579 | Don't need to do anything, because the write which caused the |
| 4584 | When we try a connection that has closed, we get SIGPIPE again. | 4580 | SIGPIPE will fail, causing Xlib to invoke the X IO error handler, |
| 4585 | But this time, it is handled by x_connection_signal_1. | 4581 | which will do the appropriate cleanup for us. */ |
| 4586 | That function knows which connection we were testing, | ||
| 4587 | so it closes that one. | ||
| 4588 | 4582 | ||
| 4589 | x_connection_closed never returns, | ||
| 4590 | so if more than one connection was lost at once, | ||
| 4591 | we only find one. But XTread_socket keeps trying them all, | ||
| 4592 | so it will notice the other closed one sooner or later. */ | ||
| 4593 | |||
| 4594 | |||
| 4595 | static struct x_display_info *x_connection_signal_dpyinfo; | ||
| 4596 | |||
| 4597 | static SIGTYPE x_connection_signal (); | ||
| 4598 | |||
| 4599 | static SIGTYPE | ||
| 4600 | x_connection_signal_1 (signalnum) /* If we don't have an argument, */ | ||
| 4601 | int signalnum; /* some compilers complain in signal calls. */ | ||
| 4602 | { | ||
| 4603 | signal (SIGPIPE, x_connection_signal); | ||
| 4604 | x_connection_closed (x_connection_signal_dpyinfo->display, | ||
| 4605 | "connection was lost"); | ||
| 4606 | } | ||
| 4607 | |||
| 4608 | static SIGTYPE | 4583 | static SIGTYPE |
| 4609 | x_connection_signal (signalnum) /* If we don't have an argument, */ | 4584 | x_connection_signal (signalnum) /* If we don't have an argument, */ |
| 4610 | int signalnum; /* some compilers complain in signal calls. */ | 4585 | int signalnum; /* some compilers complain in signal calls. */ |
| 4611 | { | 4586 | { |
| 4612 | x_connection_signal_dpyinfo = x_display_list; | 4587 | #ifdef USG |
| 4613 | 4588 | /* USG systems forget handlers when they are used; | |
| 4614 | sigunblock (sigmask (SIGPIPE)); | 4589 | must reestablish each time */ |
| 4615 | 4590 | signal (signalnum, x_connection_signal); | |
| 4616 | while (x_connection_signal_dpyinfo) | 4591 | #endif /* USG */ |
| 4617 | { | ||
| 4618 | signal (SIGPIPE, x_connection_signal_1); | ||
| 4619 | |||
| 4620 | x_connection_close_if_hung (x_connection_signal_dpyinfo); | ||
| 4621 | |||
| 4622 | XNoOp (x_connection_signal_dpyinfo->display); | ||
| 4623 | |||
| 4624 | XSync (x_connection_signal_dpyinfo->display, False); | ||
| 4625 | |||
| 4626 | /* Each time we get here, cycle through the displays now open. */ | ||
| 4627 | x_connection_signal_dpyinfo = x_connection_signal_dpyinfo->next; | ||
| 4628 | } | ||
| 4629 | |||
| 4630 | /* We should have found some closed connection. */ | ||
| 4631 | abort (); | ||
| 4632 | } | 4592 | } |
| 4633 | 4593 | ||
| 4634 | /* A buffer for storing X error messages. */ | 4594 | /* A buffer for storing X error messages. */ |
| @@ -6244,49 +6204,5 @@ syms_of_xterm () | |||
| 6244 | staticpro (&Qvendor_specific_keysyms); | 6204 | staticpro (&Qvendor_specific_keysyms); |
| 6245 | Qvendor_specific_keysyms = intern ("vendor-specific-keysyms"); | 6205 | Qvendor_specific_keysyms = intern ("vendor-specific-keysyms"); |
| 6246 | } | 6206 | } |
| 6247 | |||
| 6248 | /* Avoid warnings or errors from including Xlibint.h. | ||
| 6249 | We don't need these functions for the rest of this file. */ | ||
| 6250 | #undef bzero | ||
| 6251 | #undef bcopy | ||
| 6252 | #undef bcmp | ||
| 6253 | #undef min | ||
| 6254 | #undef max | ||
| 6255 | |||
| 6256 | #ifdef X_CONNECTION_LOCK_FLAG | ||
| 6257 | #define free loserfree | ||
| 6258 | #define malloc losermalloc | ||
| 6259 | #define exit loserexit | ||
| 6260 | #define abort loserabort | ||
| 6261 | /* For XlibDisplayWriting */ | ||
| 6262 | #include <X11/Xlibint.h> | ||
| 6263 | #endif | ||
| 6264 | |||
| 6265 | /* Check whether display connection DPYINFO is hung | ||
| 6266 | because its thread-interlock is locked. | ||
| 6267 | If it is, close the connection. | ||
| 6268 | Do nothing if this system does not have a thread interlock. */ | ||
| 6269 | |||
| 6270 | x_connection_close_if_hung (dpyinfo) | ||
| 6271 | struct x_display_info *dpyinfo; | ||
| 6272 | { | ||
| 6273 | /* This tests (1) whether X_CONNECTION_LOCK_FLAG is defined at all, | ||
| 6274 | and (2) whether the name it is defined as is itself defined. | ||
| 6275 | (It ought to have been defined by Xlibint.h. */ | ||
| 6276 | #if X_CONNECTION_LOCK_FLAG | ||
| 6277 | |||
| 6278 | if (dpyinfo->display->flags & X_CONNECTION_LOCK_FLAG) | ||
| 6279 | { | ||
| 6280 | /* If the thread-interlock is locked, assume this connection is dead. | ||
| 6281 | This assumes that the library does not make other threads | ||
| 6282 | that can be locking the display legitimately. */ | ||
| 6283 | |||
| 6284 | dpyinfo->display->flags &= ~X_CONNECTION_LOCK_FLAG; | ||
| 6285 | x_connection_closed (dpyinfo->display, "connection was lost"); | ||
| 6286 | } | ||
| 6287 | #endif /* X_CONNECTION_LOCK_FLAG */ | ||
| 6288 | } | ||
| 6289 | |||
| 6290 | /* Don't put any additional functions here! */ | ||
| 6291 | 6207 | ||
| 6292 | #endif /* not HAVE_X_WINDOWS */ | 6208 | #endif /* not HAVE_X_WINDOWS */ |