diff options
author | Matthieu Herrb <matthieu@herrb.eu> | 2023-06-15 16:58:45 +0200 |
---|---|---|
committer | Matthieu Herrb <matthieu@herrb.eu> | 2023-06-15 16:58:45 +0200 |
commit | 6ac755aff400873a2a62f18948f32a14d8725bd8 (patch) | |
tree | 83e0d80c1f4c04f1026b89f1012db67edd60252c /Xtranssock.c | |
parent | 495fa1b46b2937e199052e1e40a2a2072dd11888 (diff) | |
parent | 3b3a3bd75d86aec78f6ef893b198c3efc378bc64 (diff) |
Merge remote-tracking branch 'origin/master' into obsd
Diffstat (limited to 'Xtranssock.c')
-rw-r--r-- | Xtranssock.c | 49 |
1 files changed, 18 insertions, 31 deletions
diff --git a/Xtranssock.c b/Xtranssock.c index 59b2924..4dca2d6 100644 --- a/Xtranssock.c +++ b/Xtranssock.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, Oracle and/or its affiliates. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -141,7 +141,7 @@ from the copyright holders. /* others don't need this */ #define SocketInitOnce() /**/ -#ifdef linux +#ifdef __linux__ #define HAVE_ABSTRACT_SOCKETS #endif @@ -196,6 +196,20 @@ static Sockettrans2dev Sockettrans2devtab[] = { static int TRANS(SocketINETClose) (XtransConnInfo ciptr); #endif +#if defined(TCPCONN) || defined(TRANS_REOPEN) +static int +is_numeric (const char *str) +{ + int i; + + for (i = 0; i < (int) strlen (str); i++) + if (!isdigit (str[i])) + return (0); + + return (1); +} +#endif + #ifdef UNIXCONN @@ -1825,12 +1839,6 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, struct sockaddr_un sockname; SOCKLEN_T namelen; - - int abstract = 0; -#ifdef HAVE_ABSTRACT_SOCKETS - abstract = ciptr->transptr->flags & TRANS_ABSTRACT; -#endif - prmsg (2,"SocketUNIXConnect(%d,%s,%s)\n", ciptr->fd, host, port); /* @@ -1866,7 +1874,7 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, sockname.sun_family = AF_UNIX; - if (set_sun_path(port, UNIX_PATH, sockname.sun_path, abstract) != 0) { + if (set_sun_path(port, UNIX_PATH, sockname.sun_path, 0) != 0) { prmsg (1, "SocketUNIXConnect: path too long\n"); return TRANS_CONNECT_FAILED; } @@ -1882,16 +1890,6 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, #endif - - /* - * Adjust the socket path if using abstract sockets. - * Done here because otherwise all the strlen() calls above would fail. - */ - - if (abstract) { - sockname.sun_path[0] = '\0'; - } - /* * Do the connect() */ @@ -1925,15 +1923,7 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, return TRANS_IN_PROGRESS; else if (olderrno == EINTR) return TRANS_TRY_CONNECT_AGAIN; - else if (olderrno == ENOENT || olderrno == ECONNREFUSED) { - /* If opening as abstract socket failed, try again normally */ - if (abstract) { - ciptr->transptr->flags &= ~(TRANS_ABSTRACT); - return TRANS_TRY_CONNECT_AGAIN; - } else { - return TRANS_CONNECT_FAILED; - } - } else { + else { prmsg (2,"SocketUNIXConnect: Can't connect: errno = %d\n", EGET()); @@ -1955,9 +1945,6 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, return TRANS_CONNECT_FAILED; } - if (abstract) - sockname.sun_path[0] = '@'; - ciptr->family = AF_UNIX; ciptr->addrlen = namelen; ciptr->peeraddrlen = namelen; |