View | Details | Raw Unified | Return to bug 368628
Collapse All | Expand All

(-)gvfs-0.2.3-pre/client/gvfsfusedaemon.c (-9 / +28 lines)
Lines 71-76 typedef enum { Link Here
71
} FileOp;
71
} FileOp;
72
72
73
typedef struct {
73
typedef struct {
74
  gint      refcount;
75
74
  GMutex   *mutex;
76
  GMutex   *mutex;
75
  FileOp    op;
77
  FileOp    op;
76
  gpointer  stream;
78
  gpointer  stream;
Lines 188-199 file_handle_new (void) Link Here
188
  FileHandle *file_handle;
190
  FileHandle *file_handle;
189
191
190
  file_handle = g_new0 (FileHandle, 1);
192
  file_handle = g_new0 (FileHandle, 1);
193
  file_handle->refcount = 1;
191
  file_handle->mutex = g_mutex_new ();
194
  file_handle->mutex = g_mutex_new ();
192
  file_handle->op = FILE_OP_NONE;
195
  file_handle->op = FILE_OP_NONE;
193
196
194
  return file_handle;
197
  return file_handle;
195
}
198
}
196
199
200
static FileHandle *
201
file_handle_ref (FileHandle *file_handle)
202
{
203
  g_atomic_int_inc (&file_handle->refcount);
204
  return file_handle;
205
}
206
207
static gboolean
208
file_handle_unref (FileHandle *file_handle)
209
{
210
  return g_atomic_int_dec_and_test (&file_handle->refcount);
211
}
212
197
static void
213
static void
198
file_handle_close_stream (FileHandle *file_handle)
214
file_handle_close_stream (FileHandle *file_handle)
199
{
215
{
Lines 278-298 reindex_file_handle_for_path (const gcha Link Here
278
  g_static_mutex_unlock (&global_mutex);
294
  g_static_mutex_unlock (&global_mutex);
279
}
295
}
280
296
281
static gboolean
297
static void
282
free_file_handle_for_path (const gchar *path)
298
free_file_handle_for_path (const gchar *path)
283
{
299
{
284
  FileHandle *fh;
300
  FileHandle *fh;
285
301
286
  fh = get_file_handle_for_path (path);
302
  g_static_mutex_lock (&global_mutex);
303
  fh = g_hash_table_lookup (global_fh_table, path);
287
  if (fh)
304
  if (fh)
288
    {
305
    {
289
      g_static_mutex_lock (&global_mutex);
306
      if (file_handle_unref (fh))
290
      g_hash_table_remove (global_fh_table, path);
307
        g_hash_table_remove (global_fh_table, path);
291
      g_static_mutex_unlock (&global_mutex);
292
      return TRUE;
293
    }
308
    }
294
309
  g_static_mutex_unlock (&global_mutex);
295
  return FALSE;
296
}
310
}
297
311
298
static MountRecord *
312
static MountRecord *
Lines 923-928 vfs_open (const gchar *path, struct fuse Link Here
923
              
937
              
924
              /* File exists */
938
              /* File exists */
925
939
940
              file_handle_ref (fh);
926
              SET_FILE_HANDLE (fi, fh);
941
              SET_FILE_HANDLE (fi, fh);
927
942
928
              debug_print ("vfs_open: flags=%o\n", fi->flags);
943
              debug_print ("vfs_open: flags=%o\n", fi->flags);
Lines 1013-1018 vfs_create (const gchar *path, mode_t mo Link Here
1013
1028
1014
              /* Success */
1029
              /* Success */
1015
1030
1031
              file_handle_ref (fh);
1016
              SET_FILE_HANDLE (fi, fh);
1032
              SET_FILE_HANDLE (fi, fh);
1017
1033
1018
              g_assert (fh->stream == NULL);
1034
              g_assert (fh->stream == NULL);
Lines 1047-1053 vfs_release (const gchar *path, struct f Link Here
1047
  debug_print ("vfs_release: %s\n", path);
1063
  debug_print ("vfs_release: %s\n", path);
1048
1064
1049
  if (fh)
1065
  if (fh)
1050
    free_file_handle_for_path (path);
1066
    {
1067
      if (!file_handle_unref (fh))
1068
        free_file_handle_for_path (path);
1069
    }
1051
1070
1052
  return 0;
1071
  return 0;
1053
}
1072
}

Return to bug 368628