diff --git a/gvfs-bgo531516-fuse-cleanup-when-killed.patch b/gvfs-bgo531516-fuse-cleanup-when-killed.patch deleted file mode 100644 index d0fedf0..0000000 --- a/gvfs-bgo531516-fuse-cleanup-when-killed.patch +++ /dev/null @@ -1,35 +0,0 @@ -Index: client/gvfsfusedaemon.c -=================================================================== ---- client/gvfsfusedaemon.c (revision 1774) -+++ client/gvfsfusedaemon.c (working copy) -@@ -2049,6 +2049,18 @@ dbus_filter_func (DBusConnection *connec - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - } - -+static gboolean -+shutdown_on_idle (void) -+{ -+ fuse_exit (fuse_get_context ()->fuse); -+ return FALSE; -+} -+ -+static void -+shutdown_signal (gint signum) -+{ -+ g_idle_add ((GSourceFunc) shutdown_on_idle, NULL); -+} - - static gpointer - vfs_init (struct fuse_conn_info *conn) -@@ -2102,6 +2114,11 @@ vfs_init (struct fuse_conn_info *conn) - volume_monitor = g_object_new (g_type_from_name ("GDaemonVolumeMonitor"), NULL); - - subthread_main_loop = g_main_loop_new (NULL, FALSE); -+ -+ signal (SIGHUP, shutdown_signal); -+ signal (SIGTERM, shutdown_signal); -+ signal (SIGINT, shutdown_signal); -+ - subthread = g_thread_create ((GThreadFunc) subthread_main, NULL, FALSE, NULL); - - return NULL; diff --git a/gvfs-bnc368628-fuse-robustness.patch b/gvfs-bnc368628-fuse-robustness.patch index 0288152..58f81ea 100644 --- a/gvfs-bnc368628-fuse-robustness.patch +++ b/gvfs-bnc368628-fuse-robustness.patch @@ -1,95 +1,274 @@ -diff -upr gvfs-0.2.3-pre/client/gvfsfusedaemon.c gvfs-0.2.3-post/client/gvfsfusedaemon.c ---- gvfs-0.2.3-pre/client/gvfsfusedaemon.c 2008-04-07 20:27:44.000000000 -0500 -+++ gvfs-0.2.3-post/client/gvfsfusedaemon.c 2008-05-08 00:12:40.000000000 -0500 -@@ -71,6 +71,8 @@ typedef enum { +--- gvfs-0-2-3/client/gvfsfusedaemon.c 2008-05-23 14:24:07.000000000 -0500 ++++ gvfs-2-22/client/gvfsfusedaemon.c 2008-05-23 14:17:36.000000000 -0500 +@@ -55,8 +55,8 @@ + + #define DEBUG_ENABLED 0 + +-#define GET_FILE_HANDLE(fi) (GUINT_TO_POINTER ((guint) (fi)->fh)) +-#define SET_FILE_HANDLE(fi, fh) ((fi)->fh = (guint64) GPOINTER_TO_UINT (fh)) ++#define GET_FILE_HANDLE(fi) ((gpointer) (fi)->fh) ++#define SET_FILE_HANDLE(fi, fh) ((fi)->fh = (guint64) (fh)) + + typedef struct { + time_t creation_time; +@@ -71,7 +71,10 @@ typedef enum { } FileOp; typedef struct { + gint refcount; + GMutex *mutex; ++ gchar *path; FileOp op; gpointer stream; -@@ -188,12 +190,26 @@ file_handle_new (void) + gint length; +@@ -183,18 +186,45 @@ errno_from_error (GError *error) + } + + static FileHandle * +-file_handle_new (void) ++file_handle_new (const gchar *path) + { FileHandle *file_handle; file_handle = g_new0 (FileHandle, 1); + file_handle->refcount = 1; file_handle->mutex = g_mutex_new (); file_handle->op = FILE_OP_NONE; - - return file_handle; - } ++ file_handle->path = g_strdup (path); ++ ++ return file_handle; ++} +static FileHandle * +file_handle_ref (FileHandle *file_handle) +{ + g_atomic_int_inc (&file_handle->refcount); -+ return file_handle; -+} -+ -+static gboolean -+file_handle_unref (FileHandle *file_handle) -+{ -+ return g_atomic_int_dec_and_test (&file_handle->refcount); -+} -+ - static void - file_handle_close_stream (FileHandle *file_handle) - { -@@ -278,21 +294,19 @@ reindex_file_handle_for_path (const gcha - g_static_mutex_unlock (&global_mutex); + return file_handle; } --static gboolean + static void ++file_handle_unref (FileHandle *file_handle) ++{ ++ if (g_atomic_int_dec_and_test (&file_handle->refcount)) ++ { ++ g_static_mutex_lock (&global_mutex); ++ ++ /* Test again, since e.g. get_file_handle_for_path() might have ++ * snatched the global mutex and revived the file handle between ++ * g_atomic_int_dec_and_test() and us obtaining the lock. */ ++ ++ if (g_atomic_int_get (&file_handle->refcount) == 0) ++ g_hash_table_remove (global_fh_table, file_handle->path); ++ ++ g_static_mutex_unlock (&global_mutex); ++ } ++} ++ +static void - free_file_handle_for_path (const gchar *path) + file_handle_close_stream (FileHandle *file_handle) + { + debug_print ("file_handle_close_stream\n"); +@@ -220,11 +250,13 @@ file_handle_close_stream (FileHandle *fi + } + } + ++/* Called on hash table removal */ + static void + file_handle_free (FileHandle *file_handle) + { + file_handle_close_stream (file_handle); + g_mutex_free (file_handle->mutex); ++ g_free (file_handle->path); + g_free (file_handle); + } + +@@ -234,7 +266,11 @@ get_file_handle_for_path (const gchar *p + FileHandle *fh; + + g_static_mutex_lock (&global_mutex); ++ + fh = g_hash_table_lookup (global_fh_table, path); ++ if (fh) ++ file_handle_ref (fh); ++ + g_static_mutex_unlock (&global_mutex); + + return fh; +@@ -245,15 +281,21 @@ get_or_create_file_handle_for_path (cons { FileHandle *fh; - fh = get_file_handle_for_path (path); +- if (!fh) +- { +- fh = file_handle_new (); + g_static_mutex_lock (&global_mutex); + +- g_static_mutex_lock (&global_mutex); +- g_hash_table_insert (global_fh_table, g_strdup (path), fh); +- g_static_mutex_unlock (&global_mutex); + fh = g_hash_table_lookup (global_fh_table, path); - if (fh) - { ++ ++ if (fh) ++ { ++ file_handle_ref (fh); + } ++ else ++ { ++ fh = file_handle_new (path); ++ g_hash_table_insert (global_fh_table, fh->path, fh); ++ } ++ ++ g_static_mutex_unlock (&global_mutex); + + return fh; + } +@@ -271,30 +313,15 @@ reindex_file_handle_for_path (const gcha + (gpointer *) &fh)) + goto out; + +- g_free (old_path_internal); +- g_hash_table_insert (global_fh_table, g_strdup (new_path), fh); ++ g_free (fh->path); ++ fh->path = g_strdup (new_path); ++ g_hash_table_steal (global_fh_table, old_path); ++ g_hash_table_insert (global_fh_table, fh->path, fh); + + out: + g_static_mutex_unlock (&global_mutex); + } + +-static gboolean +-free_file_handle_for_path (const gchar *path) +-{ +- FileHandle *fh; +- +- fh = get_file_handle_for_path (path); +- if (fh) +- { - g_static_mutex_lock (&global_mutex); - g_hash_table_remove (global_fh_table, path); - g_static_mutex_unlock (&global_mutex); - return TRUE; -+ if (file_handle_unref (fh)) -+ g_hash_table_remove (global_fh_table, path); - } +- } - - return FALSE; -+ g_static_mutex_unlock (&global_mutex); - } - +-} +- static MountRecord * -@@ -923,6 +937,7 @@ vfs_open (const gchar *path, struct fuse - - /* File exists */ + mount_record_new (GMount *mount) + { +@@ -795,7 +822,10 @@ vfs_getattr (const gchar *path, struct s + } -+ file_handle_ref (fh); - SET_FILE_HANDLE (fi, fh); + if (fh) +- g_mutex_unlock (fh->mutex); ++ { ++ g_mutex_unlock (fh->mutex); ++ file_handle_unref (fh); ++ } - debug_print ("vfs_open: flags=%o\n", fi->flags); -@@ -1013,6 +1028,7 @@ vfs_create (const gchar *path, mode_t mo + debug_print ("vfs_getattr: -> %s\n", strerror (-result)); - /* Success */ +@@ -933,6 +963,8 @@ vfs_open (const gchar *path, struct fuse + result = setup_output_stream (file, fh); + else + result = setup_input_stream (file, fh); ++ ++ /* The added reference to the file handle is released in vfs_release() */ + } + else if (file_type == G_FILE_TYPE_DIRECTORY) + { +@@ -1019,6 +1051,8 @@ vfs_create (const gchar *path, mode_t mo -+ file_handle_ref (fh); - SET_FILE_HANDLE (fi, fh); - - g_assert (fh->stream == NULL); -@@ -1047,7 +1063,10 @@ vfs_release (const gchar *path, struct f + fh->stream = file_output_stream; + fh->op = FILE_OP_WRITE; ++ ++ /* The added reference to the file handle is released in vfs_release() */ + } + else + { +@@ -1047,7 +1081,7 @@ vfs_release (const gchar *path, struct f debug_print ("vfs_release: %s\n", path); if (fh) - free_file_handle_for_path (path); -+ { -+ if (!file_handle_unref (fh)) -+ free_file_handle_for_path (path); -+ } ++ file_handle_unref (fh); return 0; } +@@ -1479,6 +1513,7 @@ vfs_rename (const gchar *old_path, const + if (fh) + { + g_mutex_unlock (fh->mutex); ++ file_handle_unref (fh); + } + + if (result == -EISDIR) +@@ -1530,6 +1565,7 @@ vfs_unlink (const gchar *path) + if (fh) + { + g_mutex_unlock (fh->mutex); ++ file_handle_unref (fh); + } + + if (error) +@@ -1748,7 +1784,10 @@ vfs_truncate (const gchar *path, off_t s + } + + if (fh) +- g_mutex_unlock (fh->mutex); ++ { ++ g_mutex_unlock (fh->mutex); ++ file_handle_unref (fh); ++ } + + g_object_unref (file); + } +@@ -1998,6 +2037,9 @@ subthread_main (gpointer data) + g_object_unref (volume_monitor); + volume_monitor = NULL; + ++ /* Tell the main thread to unmount. Using kill() is necessary according to FUSE maintainers. */ ++ kill (getpid (), SIGHUP); ++ + return NULL; + } + +@@ -2025,9 +2067,16 @@ dbus_filter_func (DBusConnection *connec + *new_owner == 0) + { + /* The daemon died, unmount */ +- kill (getpid(), SIGHUP); ++ g_main_loop_quit (subthread_main_loop); + } + } ++ else if (dbus_message_is_signal (message, ++ DBUS_INTERFACE_LOCAL, ++ "Disconnected")) ++ { ++ /* Session bus died, unmount */ ++ g_main_loop_quit (subthread_main_loop); ++ } + + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } +@@ -2046,7 +2094,7 @@ vfs_init (struct fuse_conn_info *conn) + + mount_list_mutex = g_mutex_new (); + global_fh_table = g_hash_table_new_full (g_str_hash, g_str_equal, +- g_free, (GDestroyNotify) file_handle_free); ++ NULL, (GDestroyNotify) file_handle_free); + + dbus_error_init (&error); + +@@ -2059,6 +2107,8 @@ vfs_init (struct fuse_conn_info *conn) + return NULL; + } + ++ dbus_connection_set_exit_on_disconnect (dbus_conn, FALSE); ++ + _g_dbus_connection_integrate_with_main (dbus_conn); + + dbus_bus_add_match (dbus_conn, diff --git a/gvfs.changes b/gvfs.changes index 42a2048..ace1b3d 100644 --- a/gvfs.changes +++ b/gvfs.changes @@ -1,3 +1,13 @@ +------------------------------------------------------------------- +Sat May 24 03:17:59 CEST 2008 - hpj@suse.de + +- Merge gvfs-bgo531516-fuse-cleanup-when-killed.patch into + gvfs-bnc368628-fuse-robustness.patch so as to avoid overlapping + patches. +- Add upstream fixes to thread locking and file handle life-cycles + to gvfs-bnc368628-fuse-robustness.patch. Prevents more crashes. +- Depend on libcdio-devel for building, so we get the CDDA backend. + ------------------------------------------------------------------- Thu May 22 00:05:26 CEST 2008 - hpj@suse.de diff --git a/gvfs.spec b/gvfs.spec index 616242f..f42f8dc 100644 --- a/gvfs.spec +++ b/gvfs.spec @@ -12,7 +12,7 @@ Name: gvfs -BuildRequires: bluez-utils fuse-devel gconf2-devel glib2-devel gnome-keyring-devel hal-devel intltool libarchive-devel libavahi-glib-devel libsmbclient-devel libsoup-devel pkg-config +BuildRequires: bluez-utils fuse-devel gconf2-devel glib2-devel gnome-keyring-devel hal-devel intltool libarchive-devel libavahi-glib-devel libcdio-devel libsmbclient-devel libsoup-devel pkg-config %if %suse_version > 1010 BuildRequires: libgphoto2-devel %else @@ -25,18 +25,16 @@ BuildRequires: extra-rpm-macros %endif Summary: VFS functionality for GLib Version: 0.2.3 -Release: 23 +Release: 24 License: LGPL v2.0 or later Group: Development/Libraries/C and C++ Source0: %{name}-%{version}.tar.bz2 # PATCH-FIX-UPSTREAM gvfs-no-shebang.patch bgo523420 maw@suse.de -- Is this even worth upstreaming? Patch0: gvfs-no-shebang.patch -# PATCH-FIX-UPSTREAM gvfs-bnc368628-fuse-robustness.patch bnc368628 hpj@novell.com +# PATCH-FIX-UPSTREAM gvfs-bnc368628-fuse-robustness.patch bnc368628 bgo531516 hpj@novell.com Patch1: gvfs-bnc368628-fuse-robustness.patch # PATCH-FIX-UPSTREAM gvfs-bnc382172-home-trash-monitoring.patch hpj@novell.com Patch2: gvfs-bnc382172-home-trash-monitoring.patch -# PATCH-FIX-UPSTREAM gvfs-bgo531516-fuse-cleanup-when-killed.patch bgo531516 bnc368628 hpj@novell.com -Patch3: gvfs-bgo531516-fuse-cleanup-when-killed.patch Url: http://www.gnome.org BuildRoot: %{_tmppath}/%{name}-%{version}-build AutoReqProv: on @@ -125,7 +123,6 @@ Authors: %patch0 -p1 %patch1 -p1 %patch2 -p1 -%patch3 -p0 %build export CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing" @@ -180,6 +177,13 @@ chmod -x $RPM_BUILD_ROOT/%{_sysconfdir}/profile.d/* %files lang -f %{name}.lang %changelog +* Sat May 24 2008 hpj@suse.de +- Merge gvfs-bgo531516-fuse-cleanup-when-killed.patch into + gvfs-bnc368628-fuse-robustness.patch so as to avoid overlapping + patches. +- Add upstream fixes to thread locking and file handle life-cycles + to gvfs-bnc368628-fuse-robustness.patch. Prevents more crashes. +- Depend on libcdio-devel for building, so we get the CDDA backend. * Thu May 22 2008 hpj@suse.de - Add gvfs-bgo531516-fuse-cleanup-when-killed.patch, which fixes the remaining issues covered by BNC #368628.