summaryrefslogtreecommitdiff
path: root/packages/xorg-lib/xtrans/abstract_socket_fix.patch
blob: 197da0735dbd08a6de12ecfcbd8b41b0bdbe613a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
From 556a351de83fc6f401b02213dae95731553c216d Mon Sep 17 00:00:00 2001
From: Loïc Minier <lool@dooz.org>
Date: Mon, 24  Mar  2008  19:38:27  +0000
Subject: Bug #10489: Don't retry unix socket connect()s on ENOENT.

If the socket isn't there, it's not gonna magically appear.  Either it's
a server socket and you should have just waited for the SIGUSR1 from the
server, or it's a stale reference to an ICE socket.

However, do retry once, so fallback from abstract to filesystem namespace
works.

Originally Debian bug #385976.
---
diff --git a/Xtranssock.c b/Xtranssock.c
index 8a7d2ec..da4afe9 100644
--- a/Xtranssock.c
+++ b/Xtranssock.c
@@ -2146,8 +2146,13 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port)
 	    errno = olderrno;
 	    
 	    /*
-	     * If the error was ENOENT, the server may be starting up
-	     * and we should try again.
+	     * If the error was ENOENT, the server may be starting up; we used
+	     * to suggest to try again in this case with
+	     * TRANS_TRY_CONNECT_AGAIN, but this introduced problems for
+	     * processes still referencing stale sockets in their environment.
+	     * Hence, we now return a hard error, TRANS_CONNECT_FAILED, and it
+	     * is suggested that higher level stacks handle retries on their
+	     * level when they face a slow starting server.
 	     *
 	     * If the error was EWOULDBLOCK or EINPROGRESS then the socket
 	     * was non-blocking and we should poll using select
@@ -2161,14 +2166,14 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port)
 	    else if (olderrno == EINTR)
 		return TRANS_TRY_CONNECT_AGAIN;
 	    else if (olderrno == ENOENT) {
-		/*
-		* If opening as abstract socket failed, try again "normally"
-		*/
-		if (abstract)
+		/* If opening as abstract socket failed, try again normally */
+		if (abstract) {
 		    ciptr->transptr->flags &= ~(TRANS_ABSTRACT);
-		return TRANS_TRY_CONNECT_AGAIN;
-	    }
-	    else {
+		    return TRANS_TRY_CONNECT_AGAIN;
+		} else {
+		    return TRANS_CONNECT_FAILED;
+		}
+	    } else {
 		PRMSG (2,"SocketUNIXConnect: Can't connect: errno = %d\n",
 		       EGET(),0, 0);
 
--
cgit v0.7.2-37-g538c