# HG changeset patch # User Jun Wu # Date 1460328960 -3600 # Node ID 7b5f5a1b4b41598fc4d4289c5b7e234a0dff8e9a # Parent 584e0716c7afe40f544fd1f955ace608ff872820 chg: add sockdirfd to cmdserveropts As part of the series to support long socket paths, we need to add the fd of the directory to the cmdserveropts structure so we can use basenames instead of full paths for sockname, redirectsockname, and lockfile. diff -r 584e0716c7af -r 7b5f5a1b4b41 contrib/chg/chg.c --- a/contrib/chg/chg.c Sun Apr 10 21:56:05 2016 +0100 +++ b/contrib/chg/chg.c Sun Apr 10 23:56:00 2016 +0100 @@ -36,17 +36,23 @@ size_t argsize; const char **args; int lockfd; + int sockdirfd; }; static void initcmdserveropts(struct cmdserveropts *opts) { memset(opts, 0, sizeof(struct cmdserveropts)); opts->lockfd = -1; + opts->sockdirfd = AT_FDCWD; } static void freecmdserveropts(struct cmdserveropts *opts) { free(opts->args); opts->args = NULL; opts->argsize = 0; + if (opts->sockdirfd != AT_FDCWD) { + close(opts->sockdirfd); + opts->sockdirfd = AT_FDCWD; + } } /*