Code changes are integrated in Solaris and now I am trying to give back to 
community. If Socket is getting interrupted with signal EINTR, we should keep 
socket in progress state(TRANS_IN_PROGRESS) instead of trying again to 
connect(TRANS_TRY_CONNECT_AGAIN). When we close the socket connection on signal 
EINTR and retry, we will end up in same old state and stuck in loop. As per 
documentation if Connect() is interrupted by a signal that is caught, while 
blocked waiting to establish a connection, connect() shall fail and set 
connect() to [EINTR], but the connection request shall not be aborted, and the 
connection shall be established asynchronously. When the connection has been 
established asynchronously, select() and poll() shall indicate that the file 
descriptor for the socket is ready for writing.

Refer http://www.madore.org/~david/computers/connect-intr.html

Signed-off-by: Arvind Umrao <[email protected]>
---
 Xtranssock.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Xtranssock.c b/Xtranssock.c
index dfa41cf..6736cc8 100644
--- a/Xtranssock.c
+++ b/Xtranssock.c
@@ -1727,7 +1727,7 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char 
*host, char *port)
         * only affect one of a set of addresses.
         */
 
-       if (olderrno == ECONNREFUSED || olderrno == EINTR
+       if (olderrno == ECONNREFUSED 
 #if defined(IPv6) && defined(AF_INET6)
          || (((addrlist->addr->ai_next != NULL) ||
                (addrlist->addr != addrlist->firstaddr)) &&
@@ -1740,7 +1740,7 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char 
*host, char *port)
 #endif
            )
            res = TRANS_TRY_CONNECT_AGAIN;
-       else if (olderrno == EWOULDBLOCK || olderrno == EINPROGRESS)
+       else if (olderrno == EWOULDBLOCK || olderrno == EINPROGRESS || olderrno 
== EINTR)
            res = TRANS_IN_PROGRESS;
        else
        {
@@ -2028,7 +2028,7 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char 
*host, char *port)
            if (olderrno == EWOULDBLOCK || olderrno == EINPROGRESS)
                return TRANS_IN_PROGRESS;
            else if (olderrno == EINTR)
-               return TRANS_TRY_CONNECT_AGAIN;
+               return TRANS_IN_PROGRESS;
            else if (olderrno == ENOENT || olderrno == ECONNREFUSED) {
                /* If opening as abstract socket failed, try again normally */
                if (abstract) {
-- 
1.7.9.2

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to