From 979046fdee76d70792750f5a1a9afd2bba5f127f Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Thu, 13 Aug 2015 14:09:25 +0000 Subject: Debug a bit --- INSTALL | 2 +- doc/index.html | 2 +- src/libs6rc/s6rc_db_read.c | 17 ++++++++--------- src/s6-rc/s6-rc-compile.c | 45 +++++++++++++++++++++------------------------ 4 files changed, 31 insertions(+), 35 deletions(-) diff --git a/INSTALL b/INSTALL index b2c9d03..ed7522f 100644 --- a/INSTALL +++ b/INSTALL @@ -7,7 +7,7 @@ Build Instructions - A POSIX-compliant C development environment - GNU make version 4.0 or later - skalibs version 2.3.6.1 or later: http://skarnet.org/software/skalibs/ - - execline version 2.1.3.1 or later: http://skarnet.org/software/execline/ + - execline version 2.1.4.0 or later: http://skarnet.org/software/execline/ - s6 version 2.2.0.1 or later: http://skarnet.org/software/s6/ This software will run on any operating system that implements diff --git a/doc/index.html b/doc/index.html index de0d23d..4a749ad 100644 --- a/doc/index.html +++ b/doc/index.html @@ -49,7 +49,7 @@ scripts are also run in a controlled environment.
  • skalibs version 2.3.6.1 or later
  • execline version -2.1.3.1 or later
  • +2.1.4.0 or later
  • s6 version 2.2.0.1 or later
  • diff --git a/src/libs6rc/s6rc_db_read.c b/src/libs6rc/s6rc_db_read.c index 50e1f78..254ffa1 100644 --- a/src/libs6rc/s6rc_db_read.c +++ b/src/libs6rc/s6rc_db_read.c @@ -50,13 +50,13 @@ static inline int s6rc_db_read_deps (buffer *b, unsigned int max, uint32 *deps, static inline int s6rc_db_read_services (buffer *b, s6rc_db_t *db) { unsigned int n = db->nshort + db->nlong ; - s6rc_service_t *sv = db->services ; unsigned int nargvs = db->nargvs ; unsigned int argvpos = 0 ; register unsigned int i = 0 ; for (; i < n ; i++) { - DBG("iteration %u/%u remaining", i+1, n) ; + s6rc_service_t *sv = db->services + i ; + DBG("service %u/%u", i, n) ; if (!s6rc_db_read_uint32(b, &sv->name)) return -1 ; DBG(" name is %u: %s", sv->name, db->string + sv->name) ; if (sv->name >= db->stringlen) return 0 ; @@ -95,21 +95,21 @@ static inline int s6rc_db_read_services (buffer *b, s6rc_db_t *db) } else { - unsigned int i = 0 ; + unsigned int j = 0 ; DBG(" oneshot") ; - for (; i < 2 ; i++) + for (; j < 2 ; j++) { uint32 pos, argc ; if (!s6rc_db_read_uint32(b, &argc)) return -1 ; - DBG(" argc[%u] is %u, nargvs is %u", i, argc, nargvs) ; + DBG(" argc[%u] is %u, nargvs is %u", j, argc, nargvs) ; if (argc > nargvs) return 0 ; if (!s6rc_db_read_uint32(b, &pos)) return -1 ; - DBG(" pos[%u] is %u", i, pos) ; + DBG(" pos[%u] is %u", j, pos) ; if (!s6rc_db_check_valid_strings(db->string, db->stringlen, pos, argc)) return 0 ; if (!env_make((char const **)db->argvs + argvpos, argc, db->string + pos, db->stringlen - pos)) return -1 ; DBG(" first arg is %s", db->argvs[argvpos]) ; - sv->x.oneshot.argv[i] = argvpos ; - sv->x.oneshot.argc[i] = argc ; + sv->x.oneshot.argv[j] = argvpos ; + sv->x.oneshot.argc[j] = argc ; argvpos += argc ; nargvs -= argc ; if (!nargvs--) return 0 ; db->argvs[argvpos++] = 0 ; } @@ -119,7 +119,6 @@ static inline int s6rc_db_read_services (buffer *b, s6rc_db_t *db) if (buffer_get(b, &c, 1) < 1) return -1 ; if (c != '\376') return 0 ; } - sv++ ; } if (nargvs) return 0 ; return 1 ; diff --git a/src/s6-rc/s6-rc-compile.c b/src/s6-rc/s6-rc-compile.c index a1ffdee..57edec9 100644 --- a/src/s6-rc/s6-rc-compile.c +++ b/src/s6-rc/s6-rc-compile.c @@ -276,6 +276,7 @@ static unsigned int add_internal_oneshot (before_t *be, char const *name, char c || !stralloc_catb(&keep, ups, upn)) dienomem() ; add_name_nocheck(be, S6RC_INTERNALS, name, SVTYPE_ONESHOT, &pos, &service.common.kname) ; if (!genalloc_append(oneshot_t, &be->oneshots, &service)) dienomem() ; + be->nargvs += service.argc[0] + service.argc[1] + 2 ; return pos ; } @@ -296,32 +297,32 @@ static unsigned int add_storepipe (before_t *be, char const *name) add_word("0") ; add_word("1") ; add_word(EXECLINE_EXTBINPREFIX "if") ; - add_word(" " S6_EXTBINPREFIX "s6-fdholder-store") ; - add_word(" ../s6rc-fdholder/s") ; - add_word(" pipe:s6rc-r-") ; satmp.len-- ; add_word(name) ; - add_word("") ; + add_word(EXECLINE_BLOCK_QUOTE_STRING S6_EXTBINPREFIX "s6-fdholder-store") ; + add_word(EXECLINE_BLOCK_QUOTE_STRING "../s6rc-fdholder/s") ; + add_word(EXECLINE_BLOCK_QUOTE_STRING "pipe:s6rc-r-") ; satmp.len-- ; add_word(name) ; + add_word(EXECLINE_BLOCK_END_STRING) ; add_word(EXECLINE_EXTBINPREFIX "if") ; add_word("-nt") ; - add_word(" " S6_EXTBINPREFIX "s6-fdholder-store") ; - add_word(" -d1") ; - add_word(" ./s6rc-fdholder/s") ; - add_word(" pipe:s6rc-w-") ; satmp.len-- ; add_word(name) ; - add_word("") ; + add_word(EXECLINE_BLOCK_QUOTE_STRING S6_EXTBINPREFIX "s6-fdholder-store") ; + add_word(EXECLINE_BLOCK_QUOTE_STRING "-d1") ; + add_word(EXECLINE_BLOCK_QUOTE_STRING "../s6rc-fdholder/s") ; + add_word(EXECLINE_BLOCK_QUOTE_STRING "pipe:s6rc-w-") ; satmp.len-- ; add_word(name) ; + add_word(EXECLINE_BLOCK_END_STRING) ; add_word(EXECLINE_EXTBINPREFIX "exit") ; add_word("1") ; sep = satmp.len ; add_word(EXECLINE_EXTBINPREFIX "foreground") ; - add_word(" " S6_EXTBINPREFIX "s6-fdholder-delete") ; - add_word(" ../s6rc-fdholder/s") ; - add_word(" pipe:s6rc-w-") ; satmp.len-- ; add_word(name) ; - add_word("") ; + add_word(EXECLINE_BLOCK_QUOTE_STRING S6_EXTBINPREFIX "s6-fdholder-delete") ; + add_word(EXECLINE_BLOCK_QUOTE_STRING "../s6rc-fdholder/s") ; + add_word(EXECLINE_BLOCK_QUOTE_STRING "pipe:s6rc-w-") ; satmp.len-- ; add_word(name) ; + add_word(EXECLINE_BLOCK_END_STRING) ; add_word(EXECLINE_EXTBINPREFIX "foreground") ; - add_word(" " S6_EXTBINPREFIX "s6-fdholder-delete") ; - add_word(" ../s6rc-fdholder/s") ; - add_word(" pipe:s6rc-r-") ; satmp.len-- ; add_word(name) ; - add_word("") ; + add_word(EXECLINE_BLOCK_QUOTE_STRING S6_EXTBINPREFIX "s6-fdholder-delete") ; + add_word(EXECLINE_BLOCK_QUOTE_STRING "../s6rc-fdholder/s") ; + add_word(EXECLINE_BLOCK_QUOTE_STRING "pipe:s6rc-r-") ; satmp.len-- ; add_word(name) ; + add_word(EXECLINE_BLOCK_END_STRING) ; add_word(EXECLINE_EXTBINPREFIX "exit") ; add_word("0") ; @@ -513,16 +514,12 @@ static inline void add_longrun (before_t *be, int dirfd, char const *srcdir, cha } if (add_namelist(be, dirfd, srcdir, name, "consumer-for", &relatedindex, &n)) { - unsigned int namelen = str_len(name) ; - char svname[16 + namelen] ; if (n != 1) strerr_dief5x(1, srcdir, "/", name, "/consumer-for", " should only contain one service name") ; service.pipeline[0] = genalloc_s(unsigned int, &be->indices)[relatedindex] ; - byte_copy(svname, 15, "s6rc-storepipe-") ; - byte_copy(svname + 15, namelen + 1, name) ; if (verbosity >= 3) strerr_warni3x(name, " is a consumer for ", data.s + service.pipeline[0]) ; - n = add_storepipe(be, svname) ; + n = add_storepipe(be, name) ; genalloc_s(unsigned int, &be->indices)[relatedindex] = n ; service.common.ndeps++ ; fd = 0 ; @@ -1223,7 +1220,7 @@ static inline void write_run_wrapper (char const *compiled, char const *fn, s6rc if (!stralloc_cats(&satmp, "#!" EXECLINE_SHEBANGPREFIX "execlineb -P\n")) dienomem() ; if (db->services[i].x.longrun.pipeline[0] < db->nlong) { - if (!stralloc_cats(&satmp, EXECLINE_EXTBINPREFIX "s6-fdholder-retrieve ../s6rc-fdholder/s \"pipe:s6rc-r-") + if (!stralloc_cats(&satmp, S6_EXTBINPREFIX "s6-fdholder-retrieve ../s6rc-fdholder/s \"pipe:s6rc-r-") || !string_quote_nodelim(&satmp, db->string + db->services[i].name, str_len(db->string + db->services[i].name)) || !stralloc_cats(&satmp, "\"\n")) dienomem() ; } @@ -1233,7 +1230,7 @@ static inline void write_run_wrapper (char const *compiled, char const *fn, s6rc if (!stralloc_cats(&satmp, EXECLINE_EXTBINPREFIX "fdmove ") || !stralloc_cats(&satmp, fd == 3 ? "4" : "3") || !stralloc_cats(&satmp, " 0\n" - EXECLINE_EXTBINPREFIX "s6-fdholder-retrieve ../s6rc-fdholder/s \"pipe:s6rc-w-") + S6_EXTBINPREFIX "s6-fdholder-retrieve ../s6rc-fdholder/s \"pipe:s6rc-w-") || !string_quote_nodelim(&satmp, consumername, str_len(consumername)) || !stralloc_cats(&satmp, "\"\n" EXECLINE_EXTBINPREFIX "fdmove 1 0\n" -- cgit v1.2.3