fuse mount: fix unlocking of repository at umount time, fixes #331

there were 2 issues:
lock used another pid and tid than release because daemonize() made it different processes/threads.
solved by just determining PID only once and not using TID any more.

the other issue was that the repo needed and explicit closing.
This commit is contained in:
Thomas Waldmann 2015-10-27 22:37:36 +01:00
parent b787ac6ea1
commit dd577bf4ac
2 changed files with 22 additions and 16 deletions

View file

@ -348,18 +348,21 @@ Type "Yes I am sure" if you understand this and want to continue.\n""")
return self.exit_code
repository = self.open_repository(args.src)
manifest, key = Manifest.load(repository)
if args.src.archive:
archive = Archive(repository, key, manifest, args.src.archive)
else:
archive = None
operations = FuseOperations(key, repository, manifest, archive)
self.print_verbose("Mounting filesystem")
try:
operations.mount(args.mountpoint, args.options, args.foreground)
except RuntimeError:
# Relevant error message already printed to stderr by fuse
self.exit_code = EXIT_ERROR
manifest, key = Manifest.load(repository)
if args.src.archive:
archive = Archive(repository, key, manifest, args.src.archive)
else:
archive = None
operations = FuseOperations(key, repository, manifest, archive)
self.print_verbose("Mounting filesystem")
try:
operations.mount(args.mountpoint, args.options, args.foreground)
except RuntimeError:
# Relevant error message already printed to stderr by fuse
self.exit_code = EXIT_ERROR
finally:
repository.close()
return self.exit_code
def do_list(self, args):

View file

@ -2,7 +2,6 @@ import errno
import json
import os
import socket
import threading
import time
from borg.helpers import Error
@ -10,13 +9,17 @@ from borg.helpers import Error
ADD, REMOVE = 'add', 'remove'
SHARED, EXCLUSIVE = 'shared', 'exclusive'
# only determine the PID and hostname once.
# for FUSE mounts, we fork a child process that needs to release
# the lock made by the parent, so it needs to use the same PID for that.
_pid = os.getpid()
_hostname = socket.gethostname()
def get_id():
"""Get identification tuple for 'us'"""
hostname = socket.gethostname()
pid = os.getpid()
tid = threading.current_thread().ident & 0xffffffff
return hostname, pid, tid
thread_id = 0
return _hostname, _pid, thread_id
class TimeoutTimer: