From c21d912a027056c30ee86c1ce021322e89f474c3 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 29 Apr 2019 21:39:38 +0200 Subject: processes: 'process-open-files' ignores disappeared /proc/PID/fd entries. Previously, 'process-open-files' would throw ENOENT if an entry had vanished after the 'scandir' call and before the 'readlink' call. * guix/scripts/processes.scm (process-open-files): Catch ENOENT errors from 'readlink'. --- guix/scripts/processes.scm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'guix') diff --git a/guix/scripts/processes.scm b/guix/scripts/processes.scm index 6a2f603599..2dd3bbf30a 100644 --- a/guix/scripts/processes.scm +++ b/guix/scripts/processes.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2018 Ludovic Courtès +;;; Copyright © 2018, 2019 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -103,9 +103,16 @@ processes." (let ((directory (string-append "/proc/" (number->string (process-id process)) "/fd"))) - (map (lambda (fd) - (readlink (string-append directory "/" fd))) - (or (scandir directory string->number) '())))) + (filter-map (lambda (fd) + ;; There's a TOCTTOU race here, hence the 'catch'. + (catch 'system-error + (lambda () + (readlink (string-append directory "/" fd))) + (lambda args + (if (= ENOENT (system-error-errno args)) + #f + (apply throw args))))) + (or (scandir directory string->number) '())))) ;; Daemon session. (define-record-type -- cgit v1.2.3 From c20d4cac1fb72afe26a3e534b92e9a9691936458 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 29 Apr 2019 21:42:04 +0200 Subject: processes: Gracefully handle daemons without clients. Fixes . Reported by Mark H Weaver . The problem could be reproduced by running, on one hand: sh -c 'exec -a guix-daemon sleep 777' and on the other hand: guix processes If there is no process with PID 777, 'guix processes' would barf as it stumbles upon a record whose client is #f. * guix/scripts/processes.scm (daemon-sessions)[child-process->session]: New procedure, with lambda formerly passed to 'map'. Handle #f returns from 'lookup-process'. Call 'child-process->session' within 'filter-map', not just 'map'. --- guix/scripts/processes.scm | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'guix') diff --git a/guix/scripts/processes.scm b/guix/scripts/processes.scm index 2dd3bbf30a..a2ab017490 100644 --- a/guix/scripts/processes.scm +++ b/guix/scripts/processes.scm @@ -158,15 +158,22 @@ active sessions, and the master 'guix-daemon' process." (= pid (process-parent-id process)))) processes)) - (values (map (lambda (process) - (match (process-command process) - ((argv0 (= string->number client) _ ...) - (let ((files (process-open-files process))) - (daemon-session process - (lookup-process client) - (lookup-children (process-id process)) - (filter lock-file? files)))))) - children) + (define (child-process->session process) + (match (process-command process) + ((argv0 (= string->number client) _ ...) + (let ((files (process-open-files process)) + (client (lookup-process client))) + ;; After a client has died, there's a window during which its + ;; corresponding 'guix-daemon' process is still alive, in which + ;; case 'lookup-process' returns #f. In that case ignore the + ;; session. + (and client + (daemon-session process client + (lookup-children + (process-id process)) + (filter lock-file? files))))))) + + (values (filter-map child-process->session children) master))) (define (daemon-session->recutils session port) -- cgit v1.2.3 From 757e633d57a7b994759d69e41dd759a39f1a34ae Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 1 May 2019 11:05:47 +0200 Subject: build: Change default substitute server to "ci.guix.gnu.org". * config-daemon.ac: Replace "ci.guix.info" with "ci.guix.gnu.org". * doc/guix.texi (SUBSTITUTE-SERVER): Likewise. * etc/substitutes/ci.guix.gnu.org.pub: New file. * Makefile.am (dist_pkgdata_DATA): Add it. * guix/scripts/build.scm (%default-log-urls): Update. * guix/scripts/substitute.scm (%default-substitute-urls): Likewise. * guix/store.scm (%default-substitute-urls): Likewise. * guix/self.scm (miscellaneous-files): Add "ci.guix.gnu.org". --- Makefile.am | 1 + config-daemon.ac | 2 +- doc/guix.texi | 2 +- etc/substitutes/ci.guix.gnu.org.pub | 1 + guix/scripts/build.scm | 2 +- guix/scripts/substitute.scm | 2 +- guix/self.scm | 2 ++ guix/store.scm | 2 +- 8 files changed, 9 insertions(+), 5 deletions(-) create mode 120000 etc/substitutes/ci.guix.gnu.org.pub (limited to 'guix') diff --git a/Makefile.am b/Makefile.am index deec100c3c..0494452386 100644 --- a/Makefile.am +++ b/Makefile.am @@ -487,6 +487,7 @@ check-system: $(GOBJECTS) dist_pkgdata_DATA = \ etc/substitutes/hydra.gnu.org.pub \ etc/substitutes/berlin.guixsd.org.pub \ + etc/substitutes/ci.guix.gnu.org.pub \ etc/substitutes/ci.guix.info.pub # Bash completion file. diff --git a/config-daemon.ac b/config-daemon.ac index e5b0ee082c..f1ad10acff 100644 --- a/config-daemon.ac +++ b/config-daemon.ac @@ -120,7 +120,7 @@ if test "x$guix_build_daemon" = "xyes"; then dnl Determine the appropriate default list of substitute URLs (GnuTLS dnl is required so we can default to 'https'.) - guix_substitute_urls="https://ci.guix.info" + guix_substitute_urls="https://ci.guix.gnu.org" AC_MSG_CHECKING([for default substitute URLs]) AC_MSG_RESULT([$guix_substitute_urls]) diff --git a/doc/guix.texi b/doc/guix.texi index fcee57d9cd..7cda06de5c 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -17,7 +17,7 @@ @set BASE-URL https://ftp.gnu.org/gnu/guix @c The official substitute server used by default. -@set SUBSTITUTE-SERVER ci.guix.info +@set SUBSTITUTE-SERVER ci.guix.gnu.org @set SUBSTITUTE-URL https://@value{SUBSTITUTE-SERVER} @copying diff --git a/etc/substitutes/ci.guix.gnu.org.pub b/etc/substitutes/ci.guix.gnu.org.pub new file mode 120000 index 0000000000..b1d1e4d763 --- /dev/null +++ b/etc/substitutes/ci.guix.gnu.org.pub @@ -0,0 +1 @@ +berlin.guixsd.org.pub \ No newline at end of file diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm index ba143ad16b..8d5411ed43 100644 --- a/guix/scripts/build.scm +++ b/guix/scripts/build.scm @@ -65,7 +65,7 @@ (define %default-log-urls ;; Default base URLs for build logs. - '("http://ci.guix.info/log")) + '("http://ci.guix.gnu.org/log")) ;; XXX: The following procedure cannot be in (guix store) because of the ;; dependency on (guix derivations). diff --git a/guix/scripts/substitute.scm b/guix/scripts/substitute.scm index 797a76db3f..135398ba48 100755 --- a/guix/scripts/substitute.scm +++ b/guix/scripts/substitute.scm @@ -1061,7 +1061,7 @@ found." (#f ;; This can only happen when this script is not invoked by the ;; daemon. - '("http://ci.guix.info")))) + '("http://ci.guix.gnu.org")))) (define substitute-urls ;; List of substitute URLs. diff --git a/guix/self.scm b/guix/self.scm index 68b87051e9..7098e4ea29 100644 --- a/guix/self.scm +++ b/guix/self.scm @@ -588,6 +588,8 @@ load path." ("share/guix/berlin.guixsd.org.pub" ,(file-append* source "/etc/substitutes/berlin.guixsd.org.pub")) + ("share/guix/ci.guix.gnu.org.pub" ;alias + ,(file-append* source "/etc/substitutes/berlin.guixsd.org.pub")) ("share/guix/ci.guix.info.pub" ;alias ,(file-append* source "/etc/substitutes/berlin.guixsd.org.pub"))))) diff --git a/guix/store.scm b/guix/store.scm index 1b485ab5fa..5c6e4e0ca6 100644 --- a/guix/store.scm +++ b/guix/store.scm @@ -746,7 +746,7 @@ encoding conversion errors." (map (if (false-if-exception (resolve-interface '(gnutls))) (cut string-append "https://" <>) (cut string-append "http://" <>)) - '("ci.guix.info"))) + '("ci.guix.gnu.org"))) (define* (set-build-options server #:key keep-failed? keep-going? fallback? -- cgit v1.2.3