From 1d69f26f58e72ceaab5aeda7df874faf7b46a5f3 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Wed, 3 Jul 2019 12:43:13 +0000 Subject: Remove s6-fdholder-*c programs The doc still needs to be updated. --- src/fdholder/s6-fdholder-transferdump.c | 73 ++++++++++++--------------------- 1 file changed, 27 insertions(+), 46 deletions(-) (limited to 'src/fdholder/s6-fdholder-transferdump.c') diff --git a/src/fdholder/s6-fdholder-transferdump.c b/src/fdholder/s6-fdholder-transferdump.c index 9cd7ca8..83d1e80 100644 --- a/src/fdholder/s6-fdholder-transferdump.c +++ b/src/fdholder/s6-fdholder-transferdump.c @@ -1,26 +1,23 @@ /* ISC license. */ -#include #include -#include -#include #include -#include -#include -#include +#include +#include +#include +#include #define USAGE "s6-fdholder-transferdump [ -t timeoutfrom:timeoutto ] socketfrom socketto" #define dieusage() strerr_dieusage(100, USAGE) -int main (int argc, char const *const *argv, char const *const *envp) +int main (int argc, char const *const *argv) { - char const *newargv[24] ; - unsigned int timeoutfrom = 0, timeoutto = 0 ; - unsigned int m = 0 ; - char fmtfrom[UINT_FMT] ; - char fmtto[UINT_FMT] ; - PROG = "s6-fdholder-setdump" ; + s6_fdholder_t a = S6_FDHOLDER_ZERO ; + genalloc dump = GENALLOC_ZERO ; /* array of s6_fdholder_fd_t */ + tain_t deadline, totto ; + PROG = "s6-fdholder-transferdump" ; { + unsigned int timeoutfrom = 0, timeoutto = 0 ; subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { @@ -49,40 +46,24 @@ int main (int argc, char const *const *argv, char const *const *envp) } } argc -= l.ind ; argv += l.ind ; + if (timeoutfrom) tain_from_millisecs(&deadline, timeoutfrom) ; + else deadline = tain_infinite_relative ; + if (timeoutto) tain_from_millisecs(&totto, timeoutto) ; + else totto = tain_infinite_relative ; } if (argc < 2) dieusage() ; - newargv[m++] = S6_BINPREFIX "s6-ipcclient" ; - newargv[m++] = "-l0" ; - newargv[m++] = "--" ; - newargv[m++] = argv[0] ; - newargv[m++] = EXECLINE_EXTBINPREFIX "fdclose" ; - newargv[m++] = "7" ; - newargv[m++] = EXECLINE_EXTBINPREFIX "fdmove" ; - newargv[m++] = "0" ; - newargv[m++] = "6" ; - newargv[m++] = S6_BINPREFIX "s6-ipcclient" ; - newargv[m++] = "-l0" ; - newargv[m++] = "--" ; - newargv[m++] = argv[1] ; - newargv[m++] = EXECLINE_EXTBINPREFIX "fdclose" ; - newargv[m++] = "6" ; - newargv[m++] = EXECLINE_EXTBINPREFIX "fdmove" ; - newargv[m++] = "1" ; - newargv[m++] = "7" ; - newargv[m++] = S6_BINPREFIX "s6-fdholder-transferdumpc" ; - if (timeoutfrom) - { - fmtfrom[uint_fmt(fmtfrom, timeoutfrom)] = 0 ; - newargv[m++] = "-t" ; - newargv[m++] = fmtfrom ; - } - if (timeoutto) - { - fmtto[uint_fmt(fmtto, timeoutto)] = 0 ; - newargv[m++] = "-T" ; - newargv[m++] = fmtto ; - } - newargv[m++] = 0 ; - xpathexec_run(newargv[0], newargv, envp) ; + tain_now_g() ; + tain_add_g(&deadline, &deadline) ; + if (!s6_fdholder_start_g(&a, argv[0], &deadline)) + strerr_diefu2sys(111, "connect to a source fd-holder daemon at ", argv[0]) ; + if (!s6_fdholder_getdump_g(&a, &dump, &deadline)) + strerr_diefu1sys(1, "get dump") ; + s6_fdholder_end(&a) ; + tain_add_g(&deadline, &totto) ; + if (!s6_fdholder_start_g(&a, argv[1], &deadline)) + strerr_diefu2sys(111, "connect to a destination fd-holder daemon at ", argv[1]) ; + if (!s6_fdholder_setdump_g(&a, genalloc_s(s6_fdholder_fd_t, &dump), genalloc_len(s6_fdholder_fd_t, &dump), &deadline)) + strerr_diefu1sys(1, "set dump") ; + return 0 ; } -- cgit v1.2.3