changeset 30680:c80c16a8a0b0

chg: support long socket path This patch replaces UNIX_PATH_MAX (108) with PATH_MAX (4096) so we can have long unix path.
author Jun Wu <quark@fb.com>
date Fri, 23 Dec 2016 16:26:40 +0000
parents b83bddfc8048
children caf7e1c5efe4
files contrib/chg/chg.c tests/test-chg.t
diffstat 2 files changed, 20 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/chg/chg.c	Fri Dec 23 16:16:44 2016 +0000
+++ b/contrib/chg/chg.c	Fri Dec 23 16:26:40 2016 +0000
@@ -25,14 +25,14 @@
 #include "hgclient.h"
 #include "util.h"
 
-#ifndef UNIX_PATH_MAX
-#define UNIX_PATH_MAX (sizeof(((struct sockaddr_un *)NULL)->sun_path))
+#ifndef PATH_MAX
+#define PATH_MAX 4096
 #endif
 
 struct cmdserveropts {
-	char sockname[UNIX_PATH_MAX];
-	char initsockname[UNIX_PATH_MAX];
-	char redirectsockname[UNIX_PATH_MAX];
+	char sockname[PATH_MAX];
+	char initsockname[PATH_MAX];
+	char redirectsockname[PATH_MAX];
 	size_t argsize;
 	const char **args;
 };
@@ -130,7 +130,7 @@
 static void setcmdserveropts(struct cmdserveropts *opts)
 {
 	int r;
-	char sockdir[UNIX_PATH_MAX];
+	char sockdir[PATH_MAX];
 	const char *envsockname = getenv("CHGSOCKNAME");
 	if (!envsockname) {
 		/* by default, put socket file in secure directory
--- a/tests/test-chg.t	Fri Dec 23 16:16:44 2016 +0000
+++ b/tests/test-chg.t	Fri Dec 23 16:26:40 2016 +0000
@@ -16,6 +16,20 @@
   [255]
 
   $ cp $HGRCPATH.orig $HGRCPATH
+
+long socket path
+
+  $ sockpath=$TESTTMP/this/path/should/be/longer/than/one-hundred-and-seven/characters/where/107/is/the/typical/size/limit/of/unix-domain-socket
+  $ mkdir -p $sockpath
+  $ bakchgsockname=$CHGSOCKNAME
+  $ CHGSOCKNAME=$sockpath/server
+  $ export CHGSOCKNAME
+  $ chg root
+  $TESTTMP/foo
+  $ rm -rf $sockpath
+  $ CHGSOCKNAME=$bakchgsockname
+  $ export CHGSOCKNAME
+
   $ cd ..
 
 server lifecycle