[PATCH 1/2] OS support: fix writeable client vs IgnoreClient behavior

Jesse Barnes jbarnes at virtuousgeek.org
Mon Jun 28 20:14:16 PDT 2010


On Mon, 28 Jun 2010 19:22:39 -0700
Keith Packard <keithp at keithp.com> wrote:

> On Mon, 28 Jun 2010 19:14:41 -0700, Jesse Barnes <jbarnes at virtuousgeek.org> wrote:
> 
> > Thanks.  Do you want to apply it with that change or shall I send an
> > update?
> 
> Update with Rb line attached would be most excellent. We may want to see
> if others have comments before I apply it to master.

Here you go (assuming no objections).

Thanks,
-- 
Jesse Barnes, Intel Open Source Technology Center

From 2c1845751c96f260ec6650ef3dc9d95785e9c651 Mon Sep 17 00:00:00 2001
From: Jesse Barnes <jbarnes at virtuousgeek.org>
Date: Mon, 28 Jun 2010 20:11:18 -0700
Subject: [PATCH] OS support: fix writeable client vs IgnoreClient behavior

When ResetCurrentRequest is called, or IgnoreClient is called when a
client has input pending, IgnoredClientsWithInput will be set.  However,
a subsequent IgnoreClient request will clear the client fd from that fd
set, potentially causing the client to hang.

So add an Ignore/Attend count, and only apply the ignore logic on the
first ignore and the attend logic on the last attend.  This is
consistent with the comments for these functions; callers must pair
them.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=27035.

Reviewed-by: Keith Packard <keithp at keithp.com>
Signed-off-by: Jesse Barnes <jbarnes at virtuousgeek.org>
---
 include/dixstruct.h |    1 +
 os/connection.c     |   10 ++++++++++
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/include/dixstruct.h b/include/dixstruct.h
index 696b793..568ea1f 100644
--- a/include/dixstruct.h
+++ b/include/dixstruct.h
@@ -99,6 +99,7 @@ typedef struct _Client {
     int         clientGone;
     int         noClientException;	/* this client died or needs to be
 					 * killed */
+    int         ignoreCount;		/* count for Attend/IgnoreClient */
     SaveSetElt	*saveSet;
     int         numSaved;
     void	*unused_screenPrivate[16];
diff --git a/os/connection.c b/os/connection.c
index 61ba72a..dd48c11 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -1148,6 +1148,11 @@ IgnoreClient (ClientPtr client)
     int connection = oc->fd;
 
     isItTimeToYield = TRUE;
+
+    client->ignoreCount++;
+    if (client->ignoreCount > 1)
+	return;
+
     if (!GrabInProgress || FD_ISSET(connection, &AllClients))
     {
     	if (FD_ISSET (connection, &ClientsWithInput))
@@ -1181,6 +1186,11 @@ AttendClient (ClientPtr client)
 {
     OsCommPtr oc = (OsCommPtr)client->osPrivate;
     int connection = oc->fd;
+
+    client->ignoreCount--;
+    if (client->ignoreCount)
+	return;
+
     if (!GrabInProgress || GrabInProgress == client->index ||
 	FD_ISSET(connection, &GrabImperviousClients))
     {
-- 
1.6.6.1




More information about the xorg-devel mailing list