diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-06-30 20:52:50 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-06-30 20:52:50 +0900 |
commit | c5101a06fdc49d358924245b0ad4da1ec94da26d (patch) | |
tree | 0b5e8e712102bd89921c4d2b933e7a9dc103d250 /buildstream/_fuse | |
parent | 426bbcbc744be8097a8324d7ca111336e8427801 (diff) | |
download | buildstream-c5101a06fdc49d358924245b0ad4da1ec94da26d.tar.gz |
_fuse/mount.py: Check exit status of fuse mount process
And raise exception if that process crashed for any reason.
Diffstat (limited to 'buildstream/_fuse')
-rw-r--r-- | buildstream/_fuse/mount.py | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/buildstream/_fuse/mount.py b/buildstream/_fuse/mount.py index 33fe48b50..f4c7ed254 100644 --- a/buildstream/_fuse/mount.py +++ b/buildstream/_fuse/mount.py @@ -21,6 +21,7 @@ import os import signal import time +import sys from fuse import FUSE from contextlib import contextmanager @@ -28,6 +29,13 @@ from multiprocessing import Process from .. import _signals +# Just a custom exception to raise here, for identifying possible +# bugs with a fuse layer implementation +# +class FuseMountError(Exception): + pass + + # This is a convenience class which takes care of synchronizing the # startup of FUSE and shutting it down. # @@ -113,13 +121,10 @@ class Mount(): self.__process.terminate() self.__process.join() - # Not sure why this can happen, but sometimes subsequent checks - # on the directory can fail with "transport endpoint not connected", - # this code is an attempt to ensure we synchronize subsequent accesses - # to an unmounted directory, so that we wait until the OS really - # unmounts it before proceeding. - while os.path.ismount(self.__mountpoint): - time.sleep(1 / 100) + # Report an error if ever the underlying operations crashed for some reason. + if self.__process.exitcode != 0: + raise FuseMountError("{} reported exit code {} when unmounting" + .format(type(self).__name__, self.__process.exitcode)) self.__mountpoint = None self.__process = None @@ -180,3 +185,8 @@ class Mount(): # will handle SIGTERM and gracefully exit it's own little main loop. # FUSE(self.__operations, self.__mountpoint, nothreads=True, foreground=True, nonempty=True) + + # Explicit 0 exit code, if the operations crashed for some reason, the exit + # code will not be 0, and we want to know about it. + # + sys.exit(0) |