mirror of
https://gitlab.freedesktop.org/xorg/lib/libx11.git
synced 2026-05-07 12:08:19 +02:00
_XDefaultIOError: Do better at detecting explicit shutdown
Currently, when the X server crashes or a client is disconnected with
XKillClient, you get a somewhat confusing error message from libX11
along the lines of:
XIO: fatal IO error 11 (Resource temporarily unavailable) on X server ":0"
after 98 requests (40 known processed) with 0 events remaining.
What's happening here is the previous recvmsg has thrown EAGAIN, since
the socket is non-blocking. In this case, check whether the socket has
any more data to read, and if not treat it like EPIPE.
Signed-off-by: Adam Jackson <ajax@redhat.com>
This commit is contained in:
parent
6d2cde9633
commit
5538b3e4ae
1 changed files with 28 additions and 1 deletions
|
|
@ -50,6 +50,8 @@ from The Open Group.
|
||||||
#ifdef XTHREADS
|
#ifdef XTHREADS
|
||||||
#include "locking.h"
|
#include "locking.h"
|
||||||
|
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
/* these pointers get initialized by XInitThreads */
|
/* these pointers get initialized by XInitThreads */
|
||||||
LockInfoPtr _Xglobal_lock = NULL;
|
LockInfoPtr _Xglobal_lock = NULL;
|
||||||
void (*_XCreateMutex_fn)(LockInfoPtr) = NULL;
|
void (*_XCreateMutex_fn)(LockInfoPtr) = NULL;
|
||||||
|
|
@ -1234,6 +1236,21 @@ _XWireToEvent(
|
||||||
return(True);
|
return(True);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
SocketBytesReadable(Display *dpy)
|
||||||
|
{
|
||||||
|
int bytes = 0, last_error;
|
||||||
|
#ifdef WIN32
|
||||||
|
last_error = WSAGetLastError();
|
||||||
|
ioctlsocket(ConnectionNumber(dpy), FIONREAD, &bytes);
|
||||||
|
WSASetLastError(last_error);
|
||||||
|
#else
|
||||||
|
last_error = errno;
|
||||||
|
ioctl(ConnectionNumber(dpy), FIONREAD, &bytes);
|
||||||
|
errno = last_error;
|
||||||
|
#endif
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _XDefaultIOError - Default fatal system error reporting routine. Called
|
* _XDefaultIOError - Default fatal system error reporting routine. Called
|
||||||
|
|
@ -1242,7 +1259,17 @@ _XWireToEvent(
|
||||||
_X_NORETURN int _XDefaultIOError(
|
_X_NORETURN int _XDefaultIOError(
|
||||||
Display *dpy)
|
Display *dpy)
|
||||||
{
|
{
|
||||||
if (ECHECK(EPIPE)) {
|
int killed = ECHECK(EPIPE);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the socket was closed on the far end, the final recvmsg in
|
||||||
|
* xcb will have thrown EAGAIN because we're non-blocking. Detect
|
||||||
|
* this to get the more informative error message.
|
||||||
|
*/
|
||||||
|
if (ECHECK(EAGAIN) && SocketBytesReadable(dpy) <= 0)
|
||||||
|
killed = True;
|
||||||
|
|
||||||
|
if (killed) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"X connection to %s broken (explicit kill or server shutdown).\r\n",
|
"X connection to %s broken (explicit kill or server shutdown).\r\n",
|
||||||
DisplayString (dpy));
|
DisplayString (dpy));
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue