This came up with an upgrade of my machine to Mac OS 10.6.
APPROVE COMMIT
NOTE: This patch has been committed.
# HG changeset patch
# User Aidan Kehoe <kehoea(a)parhasard.net>
# Date 1307122857 -3600
# Node ID 3cc7470ea71c67a24a19e0185caa0271fe46933a
# Parent 5e128eda1d1f4be901c67698b214a2d51fb80ba4
gnuclient: if TMPDIR was set and connect failed, try again with /tmp
2011-06-03 Aidan Kehoe <kehoea(a)parhasard.net>
* gnuslib.c (connect_to_unix_server):
Retry with /tmp as a directory in which to search for Unix sockets
if an attempt to connect with some other directory failed (which
may be because gnuclient and gnuserv don't share an environment
value for TMPDIR, or because gnuserv was compiled with USE_TMPDIR
turned off).
diff -r 5e128eda1d1f -r 3cc7470ea71c lib-src/ChangeLog
--- a/lib-src/ChangeLog Wed Jun 01 14:53:44 2011 +0200
+++ b/lib-src/ChangeLog Fri Jun 03 18:40:57 2011 +0100
@@ -1,3 +1,12 @@
+2011-06-03 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * gnuslib.c (connect_to_unix_server):
+ Retry with /tmp as a directory in which to search for Unix sockets
+ if an attempt to connect with some other directory failed (which
+ may be because gnuclient and gnuserv don't share an environment
+ value for TMPDIR, or because gnuserv was compiled with USE_TMPDIR
+ turned off).
+
2011-05-20 Jerry James <james(a)xemacs.org>
* Makefile.in.in: Default DESTDIR to the empty string, and use it in
diff -r 5e128eda1d1f -r 3cc7470ea71c lib-src/gnuslib.c
--- a/lib-src/gnuslib.c Wed Jun 01 14:53:44 2011 +0200
+++ b/lib-src/gnuslib.c Fri Jun 03 18:40:57 2011 +0100
@@ -266,26 +266,52 @@
{
int s; /* connected socket descriptor */
struct sockaddr_un server; /* for unix connections */
+ char *ctus_tmpdir = tmpdir;
- if ((s = socket(AF_UNIX,SOCK_STREAM,0)) < 0) {
- perror(progname);
- fprintf(stderr,"%s: unable to create socket\n",progname);
- exit(1);
- }; /* if */
+ do
+ {
+ if ((s = socket(AF_UNIX,SOCK_STREAM,0)) < 0) {
+ perror(progname);
+ fprintf(stderr,"%s: unable to create socket\n",progname);
+ exit(1);
+ }; /* if */
- server.sun_family = AF_UNIX;
+ server.sun_family = AF_UNIX;
+
#ifdef HIDE_UNIX_SOCKET
- sprintf(server.sun_path,"%s/gsrvdir%d/gsrv",tmpdir,(int)geteuid());
+ sprintf(server.sun_path,"%s/gsrvdir%d/gsrv", ctus_tmpdir,
+ (int)geteuid());
#else /* HIDE_UNIX_SOCKET */
- sprintf(server.sun_path,"%s/gsrv%d",tmpdir,(int)geteuid());
+ sprintf(server.sun_path,"%s/gsrv%d", ctus_tmpdir,
+ (int)geteuid());
#endif /* HIDE_UNIX_SOCKET */
- if (connect(s,(struct sockaddr *)&server,strlen(server.sun_path)+2) < 0) {
- perror(progname);
- fprintf(stderr,"%s: unable to connect to local\n",progname);
- exit(1);
- }; /* if */
+ if (connect(s,(struct sockaddr *)&server,strlen(server.sun_path)+2) < 0) {
+#ifndef WIN32_NATIVE
+#ifdef USE_TMPDIR
+ if (0 != strcmp (ctus_tmpdir, "/tmp"))
+ {
+ /* Try again; the server may have no environment value for
+ TMPDIR, or it may have been compiled without USE_TMPDIR, and
+ in both those cases it's useful to retry with /tmp.
- return(s);
+ In the case where the server was compiled with USE_TMPDIR and
+ it has a value for TMPDIR distinct from ours, we have no way of
+ working out what that value is, so it's appropriate to give
+ up. */
+ close (s);
+ ctus_tmpdir = "/tmp";
+ continue;
+ }
+#endif /* USE_TMPDIR */
+#endif /* !WIN32_NATIVE */
+ perror(progname);
+ fprintf(stderr,"%s: %s: unable to connect to local\n", progname,
+ server.sun_path);
+ exit(1);
+ }; /* if */
+
+ return(s);
+ } while (1);
} /* connect_to_unix_server */
#endif /* UNIX_DOMAIN_SOCKETS */
--
‘Iodine deficiency was endemic in parts of the UK until, through what has been
described as “an unplanned and accidental public health triumph”, iodine was
added to cattle feed to improve milk production in the 1930s.’
(EN Pearce, Lancet, June 2011)
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-patches