[gvfs] Explicitly intialize mutexes on stack



commit 47a61b04fe209fc76b92de874c446d0a3f44c276
Author: Tomas Bzatek <tbzatek redhat com>
Date:   Mon Nov 14 19:42:02 2011 +0100

    Explicitly intialize mutexes on stack
    
    Turned out zeroing memory is not enough in some cases so let's be
    on the safe side and properly initialize all non-static mutexes.
    Also, don't initialize/clear the static ones.

 client/gvfsfusedaemon.c        |    2 +-
 common/gmountsource.c          |    6 ++++++
 common/gmounttracker.c         |    1 +
 daemon/gvfsbackendafc.c        |    2 ++
 daemon/gvfsbackendftp.c        |    2 ++
 daemon/gvfsbackendgphoto2.c    |    2 ++
 daemon/gvfsbackendnetwork.c    |    2 ++
 daemon/gvfsbackendobexftp.c    |    3 +++
 daemon/gvfsbackendsmbbrowse.c  |    3 +++
 daemon/gvfsdaemon.c            |    2 ++
 daemon/gvfsftpdircache.c       |    1 +
 daemon/trashlib/trashexpunge.c |    3 ---
 12 files changed, 25 insertions(+), 4 deletions(-)
---
diff --git a/client/gvfsfusedaemon.c b/client/gvfsfusedaemon.c
index 5e79638..d8a13e5 100644
--- a/client/gvfsfusedaemon.c
+++ b/client/gvfsfusedaemon.c
@@ -212,6 +212,7 @@ file_handle_new (const gchar *path)
 
   file_handle = g_new0 (FileHandle, 1);
   file_handle->refcount = 1;
+  g_mutex_init (&file_handle->mutex);
   file_handle->op = FILE_OP_NONE;
   file_handle->path = g_strdup (path);
 
@@ -2372,7 +2373,6 @@ vfs_destroy (gpointer param)
   mount_list_free ();
   if (subthread_main_loop != NULL) 
     g_main_loop_quit (subthread_main_loop);
-  g_mutex_clear (&mount_list_mutex);
   g_object_unref (gvfs);
 }
 
diff --git a/common/gmountsource.c b/common/gmountsource.c
index af89ed2..cf567fc 100644
--- a/common/gmountsource.c
+++ b/common/gmountsource.c
@@ -380,6 +380,8 @@ g_mount_source_ask_password (GMountSource *source,
   AskSyncData data;
 
   memset (&data, 0, sizeof (data));
+  g_mutex_init (&data.mutex);
+  g_cond_init (&data.cond);
   g_mutex_lock (&data.mutex);
 
 
@@ -549,6 +551,8 @@ g_mount_source_ask_question (GMountSource *source,
   AskSyncData data;
   
   memset (&data, 0, sizeof (data));
+  g_mutex_init (&data.mutex);
+  g_cond_init (&data.cond);
   g_mutex_lock (&data.mutex);
 
   g_mount_source_ask_question_async (source,
@@ -842,6 +846,8 @@ g_mount_source_show_processes (GMountSource *source,
   AskSyncData data;
 
   memset (&data, 0, sizeof (data));
+  g_mutex_init (&data.mutex);
+  g_cond_init (&data.cond);
   g_mutex_lock (&data.mutex);
 
   g_mount_source_show_processes_async (source,
diff --git a/common/gmounttracker.c b/common/gmounttracker.c
index 135a2b2..3c6a8eb 100644
--- a/common/gmounttracker.c
+++ b/common/gmounttracker.c
@@ -541,6 +541,7 @@ init_connection (GMountTracker *tracker)
 static void
 g_mount_tracker_init (GMountTracker *tracker)
 {
+  g_mutex_init (&tracker->lock);
 }
 
 
diff --git a/daemon/gvfsbackendafc.c b/daemon/gvfsbackendafc.c
index 84227ed..cade065 100644
--- a/daemon/gvfsbackendafc.c
+++ b/daemon/gvfsbackendafc.c
@@ -2600,6 +2600,8 @@ g_vfs_backend_afc_init (GVfsBackendAfc *self)
       /* enable full debugging */
       idevice_set_debug_level (1);
     }
+
+  g_mutex_init (&self->apps_lock);
 }
 
 static void
diff --git a/daemon/gvfsbackendftp.c b/daemon/gvfsbackendftp.c
index 3883ca3..c92a9f9 100644
--- a/daemon/gvfsbackendftp.c
+++ b/daemon/gvfsbackendftp.c
@@ -395,6 +395,8 @@ g_vfs_backend_ftp_finalize (GObject *object)
 static void
 g_vfs_backend_ftp_init (GVfsBackendFtp *ftp)
 {
+  g_mutex_init (&ftp->mutex);
+  g_cond_init (&ftp->cond);
 }
 
 static void
diff --git a/daemon/gvfsbackendgphoto2.c b/daemon/gvfsbackendgphoto2.c
index 9a1b6d8..403d5e7 100644
--- a/daemon/gvfsbackendgphoto2.c
+++ b/daemon/gvfsbackendgphoto2.c
@@ -1712,6 +1712,8 @@ do_mount (GVfsBackend *backend,
 
   gphoto2_backend->free_space = -1;
 
+  g_mutex_init (&gphoto2_backend->lock);
+
   gphoto2_mount_spec = g_mount_spec_new ("gphoto2");
   g_mount_spec_set (gphoto2_mount_spec, "host", host);
   g_vfs_backend_set_mount_spec (backend, gphoto2_mount_spec);
diff --git a/daemon/gvfsbackendnetwork.c b/daemon/gvfsbackendnetwork.c
index 3c38514..b83f278 100644
--- a/daemon/gvfsbackendnetwork.c
+++ b/daemon/gvfsbackendnetwork.c
@@ -769,6 +769,8 @@ g_vfs_backend_network_init (GVfsBackendNetwork *network_backend)
   const char * const* supported_vfs;
   int i;
 
+  g_mutex_init (&network_backend->smb_mount_lock);
+
   supported_vfs = g_vfs_get_supported_uri_schemes (g_vfs_get_default ());
 
   network_backend->have_smb = FALSE;
diff --git a/daemon/gvfsbackendobexftp.c b/daemon/gvfsbackendobexftp.c
index 62fe32f..a27e55b 100644
--- a/daemon/gvfsbackendobexftp.c
+++ b/daemon/gvfsbackendobexftp.c
@@ -530,6 +530,9 @@ g_vfs_backend_obexftp_init (GVfsBackendObexftp *backend)
       return;
   }
 
+  g_mutex_init (&backend->mutex);
+  g_cond_init (&backend->cond);
+
   backend->manager_proxy = dbus_g_proxy_new_for_name (backend->connection,
                                                       "org.openobex",
                                                       "/org/openobex",
diff --git a/daemon/gvfsbackendsmbbrowse.c b/daemon/gvfsbackendsmbbrowse.c
index f1055c5..56de3a9 100644
--- a/daemon/gvfsbackendsmbbrowse.c
+++ b/daemon/gvfsbackendsmbbrowse.c
@@ -244,6 +244,9 @@ g_vfs_backend_smb_browse_init (GVfsBackendSmbBrowse *backend)
   char *workgroup;
   GSettings *settings;
 
+  g_mutex_init (&backend->entries_lock);
+  g_mutex_init (&backend->update_cache_lock);
+
   if (mount_tracker == NULL)
     mount_tracker = g_mount_tracker_new (NULL);
 
diff --git a/daemon/gvfsdaemon.c b/daemon/gvfsdaemon.c
index 4f59b94..8239923 100644
--- a/daemon/gvfsdaemon.c
+++ b/daemon/gvfsdaemon.c
@@ -158,6 +158,8 @@ g_vfs_daemon_init (GVfsDaemon *daemon)
   /* TODO: verify thread_pool != NULL in a nicer way */
   g_assert (daemon->thread_pool != NULL);
 
+  g_mutex_init (&daemon->lock);
+
   daemon->mount_counter = 0;
   
   daemon->jobs = NULL;
diff --git a/daemon/gvfsftpdircache.c b/daemon/gvfsftpdircache.c
index 49023b1..e316eac 100644
--- a/daemon/gvfsftpdircache.c
+++ b/daemon/gvfsftpdircache.c
@@ -114,6 +114,7 @@ g_vfs_ftp_dir_cache_new (const GVfsFtpDirFuncs *funcs)
                                               g_vfs_ftp_file_equal,
                                               (GDestroyNotify) g_vfs_ftp_file_free,
                                               (GDestroyNotify) g_vfs_ftp_dir_cache_entry_unref);
+  g_mutex_init (&cache->lock);
   cache->funcs = funcs;
 
   return cache;
diff --git a/daemon/trashlib/trashexpunge.c b/daemon/trashlib/trashexpunge.c
index 677fb81..db3e70c 100644
--- a/daemon/trashlib/trashexpunge.c
+++ b/daemon/trashlib/trashexpunge.c
@@ -107,9 +107,6 @@ trash_expunge (GFile *directory)
     {
       trash_expunge_queue = g_hash_table_new (g_file_hash,
                                               (GEqualFunc) g_file_equal);
-      g_mutex_init (&trash_expunge_lock);
-      g_cond_init (&trash_expunge_wait);
-
       g_once_init_leave (&trash_expunge_initialised, 1);
     }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]