branch: master
commit a861d7d5bd997d0776f840847186fc198e87e1d9
Author: Ludovic Courtès <l...@gnu.org>
Date:   Thu Feb 15 22:55:51 2018 +0100

    logging: "Defensive programming" for 'log-monitoring-stats'.
    
    I've seen 'scandir' report #f once, even though that's theoretically
    impossible.
    
    * src/cuirass/logging.scm (log-monitoring-stats): Return '() if
    'scandir' returns #f.
---
 src/cuirass/logging.scm | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/cuirass/logging.scm b/src/cuirass/logging.scm
index 12d156c..6258eed 100644
--- a/src/cuirass/logging.scm
+++ b/src/cuirass/logging.scm
@@ -71,6 +71,9 @@
                (/ (assoc-ref (gc-stats) 'heap-size) (expt 2. 20))
                (length (all-threads))
                (length
-                (scandir "/proc/self/fd"
-                         (lambda (file)
-                           (not (member file '("." ".."))))))))
+                ;; In theory 'scandir' cannot return #f, but in practice,
+                ;; we've seen it before.
+                (or (scandir "/proc/self/fd"
+                             (lambda (file)
+                               (not (member file '("." "..")))))
+                    '()))))

Reply via email to