From 33c7733e35eef7337f426403b4069faea41c4b11 Mon Sep 17 00:00:00 2001
From: robk-tahoe <robk-tahoe@allmydata.com>
Date: Fri, 29 Feb 2008 20:18:15 -0700
Subject: [PATCH] macfuse: increase default timeout in ui launched mounts

when an operation takes 'too long', on 10.4 the user gets a dialog about
the problem with a 'force eject / keep trying' choice. on 10.5 the fuse
system seems to summarily unmount the drive.

this showed up in 10.5 testing because the time to open() a file depended
upon the size of the file, and an 8Mb test file took long enough for the
node to download that the open() call didn't respond within 60s and fuse
spontaneously ejected the drive, quitting the plugin (and cancelling the
download).

this changes the fuse options passed to the plugin by the ui when the
'mount filesystem' window is used.  command line users should check out
the '-odaemon_timeout=...' option.  this changes the default timeout from
60s to 300s (5min) for ui launched plugins.

this will be addressed in a deeper manner at a later date, with a more
advanced fuse subsystem which can interleave open()/read() with the
actual download of the file, only blocking when data is not downloaded
yet.
---
 src/allmydata/gui/macapp.py | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/allmydata/gui/macapp.py b/src/allmydata/gui/macapp.py
index e8f10577..58b470a3 100644
--- a/src/allmydata/gui/macapp.py
+++ b/src/allmydata/gui/macapp.py
@@ -20,6 +20,7 @@ from allmydata.gui.confwiz import ConfWizApp, ACCOUNT_PAGE, DEFAULT_SERVER_URL
 from allmydata.uri import NewDirectoryURI
 import amdicon
 
+DEFAULT_FUSE_TIMEOUT = 300
 
 TRY_TO_INSTALL_TAHOE_SCRIPT = True
 TAHOE_SCRIPT = '''#!/bin/bash
@@ -331,13 +332,19 @@ class MountPanel(wx.Panel):
         bin_path = sys.executable[:-6] + 'Allmydata Tahoe'
         log.msg('%r exists: %r' % (bin_path, os.path.exists(bin_path),))
 
+        foptions = []
+        foptions.append('-ovolname=%s' % (cap_name,))
+
+        timeout = DEFAULT_FUSE_TIMEOUT
+        # [ ] TODO: make this configurable
+        if timeout:
+            foptions.append('-odaemon_timeout=%d' % (timeout,))
+
         icns_path = os.path.join(self.app.basedir, 'private', cap_name+'.icns')
         if os.path.exists(icns_path):
-            icon_arg = ['-ovolicon=%s' % (icns_path,)]
-        else:
-            icon_arg = []
+            foptions.append('-ovolicon=%s' % (icns_path,))
 
-        command = [bin_path, 'fuse', cap_name] + icon_arg + [mountpoint]
+        command = [bin_path, 'fuse', cap_name] + foptions + [mountpoint]
         log.msg('spawning command %r' % (command,))
         proc = subprocess.Popen(command,
                                 cwd=self.app.basedir,
-- 
2.45.2