1
0

- u_os-connections-Check-for-stale-FDs.patch

Ignore file descriptor if socket or devices dies.
  This prevents the Xserver to loop at 100% when
  dbus dies (boo#954433).

OBS-URL: https://build.opensuse.org/package/show/X11:XOrg/xorg-x11-server?expand=0&rev=614
This commit is contained in:
Egbert Eich 2016-03-04 18:45:51 +00:00 committed by Git OBS Bridge
parent 33b0155469
commit 5b355be2a2
3 changed files with 123 additions and 1 deletions

View File

@ -0,0 +1,112 @@
From: Egbert Eich <eich@freedesktop.org>
Date: Fri Jan 29 11:05:46 2016 +0100
Subject: [PATCH]os/connections: Check for stale FDs
Patch-mainline: to be upstreamed
Git-repo: git://anongit.freedesktop.org/git/xorg/xserver
References: bsc#954433
Signed-off-by: Egbert Eich <eich@suse.com>
So far we've only checked for stale client connections.
However, our main select loop checks file descriptors
of devices and sockets of services like dbus.
These file descriptors may become stale as well, for instance,
when the underlying service has died. In this case, select
will return immediately with EBADF. Without removing these
stale FDs, the Xserver will loop rapidly in WaitFor().
Thus, simply remove the respective bit from AllSockets.
Signed-off-by: Egbert Eich <eich@freedesktop.org>
---
include/os.h | 3 +++
os/WaitFor.c | 5 +++++
os/connection.c | 37 +++++++++++++++++++++++++++++++++++++
3 files changed, 45 insertions(+)
diff --git a/include/os.h b/include/os.h
index 461d5d6..a3e433c 100644
--- a/include/os.h
+++ b/include/os.h
@@ -51,6 +51,7 @@ SOFTWARE.
#include <stdarg.h>
#include <stdint.h>
#include <string.h>
+#include <sys/types.h>
#define SCREEN_SAVER_ON 0
#define SCREEN_SAVER_OFF 1
@@ -141,6 +142,8 @@ extern _X_EXPORT const char *ClientAuthorized(ClientPtr /*client */ ,
extern _X_EXPORT void CheckConnections(void);
+extern _X_EXPORT void CheckFDs(fd_set *);
+
extern _X_EXPORT void CloseDownConnection(ClientPtr /*client */ );
extern _X_EXPORT void AddGeneralSocket(int /*fd */ );
diff --git a/os/WaitFor.c b/os/WaitFor.c
index e839d61..6cc967e 100644
--- a/os/WaitFor.c
+++ b/os/WaitFor.c
@@ -229,7 +229,12 @@ WaitForSomething(int *pClientsReady)
return 0;
if (i < 0) {
if (selecterr == EBADF) { /* Some client disconnected */
+ fd_set mask;
+ XFD_COPYSET(&LastSelectMask, &mask);
+ XFD_UNSET(&mask, &AllClients);
CheckConnections();
+ if (XFD_ANYSET(&mask))
+ CheckFDs(&mask);
if (!XFD_ANYSET(&AllClients))
return 0;
}
diff --git a/os/connection.c b/os/connection.c
index 4c1ba4b..d6943f2 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -1022,6 +1022,43 @@ CheckConnections(void)
}
/*****************
+ * CheckFDs
+ *****************/
+void
+CheckFDs(fd_set *fdbits)
+{
+ fd_mask mask;
+ fd_set tmask;
+ int curbit, curoff;
+ int i;
+ struct timeval notime;
+ int r;
+ notime.tv_sec = 0;
+ notime.tv_usec = 0;
+
+ for (i = 0; i < howmany(XFD_SETSIZE, NFDBITS); i++) {
+ mask = fdbits->fds_bits[i];
+ while (mask) {
+ curoff = mffs(mask) - 1;
+ curbit = curoff + (i * (sizeof(fd_mask) * 8));
+ FD_ZERO(&tmask);
+ FD_SET(curbit, &tmask);
+ do {
+ r = Select(curbit + 1, &tmask, NULL, NULL, &notime);
+ } while (r < 0 && (errno == EINTR || errno == EAGAIN));
+ if (r < 0 && errno == EBADF) {
+ //RemoveNotifyFd(curbit);
+ FD_CLR(curbit, &EnabledDevices);
+ FD_CLR(curbit, &AllSockets);
+ if (GrabInProgress)
+ FD_CLR(curbit, &SavedAllSockets);
+ }
+ mask &= ~((fd_mask) 1 << curoff);
+ }
+ }
+}
+
+/*****************
* CloseDownConnection
* Delete client from AllClients and free resources
*****************/

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Fri Mar 4 18:42:10 UTC 2016 - eich@suse.com
- u_os-connections-Check-for-stale-FDs.patch
Ignore file descriptor if socket or devices dies.
This prevents the Xserver to loop at 100% when
dbus dies (boo#954433).
-------------------------------------------------------------------
Thu Feb 25 20:54:32 UTC 2016 - eich@suse.com

View File

@ -183,6 +183,7 @@ Patch160: u_vesa-Add-VBEDPMSGetCapabilities-VBEDPMSGet.patch
Patch206: u_busfault_sigaction-Only-initialize-pointer-when-matched.patch
Patch208: u_Panning-Set-panning-state-in-xf86RandR12ScreenSetSize.patch
Patch209: u_pci-primary-Fix-up-primary-PCI-device-detection-for-the-platfrom-bus.patch
Patch210: u_os-connections-Check-for-stale-FDs.patch
Patch1000: n_xserver-optimus-autoconfig-hack.patch
@ -271,7 +272,7 @@ sh %{SOURCE92} --verify . %{SOURCE91}
%patch6 -p0
#
%patch100 -p1
%patch101 -p1
#%patch101 -p1
%patch102 -p1
%patch104 -p1
%patch106 -p1
@ -288,6 +289,7 @@ sh %{SOURCE92} --verify . %{SOURCE91}
%patch206 -p1
%patch208 -p1
%patch209 -p1
%patch210 -p1
%patch1000 -p1