~ubuntu-branches/debian/jessie/gamin/jessie

« back to all changes in this revision

Viewing changes to server/inotify-diag.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Banck
  • Date: 2007-03-23 14:43:49 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070323144349-1inpdk22uaneks9h
Tags: 0.1.8-2
* debian/control: Improve long description. (Closes: #405347)
* debian/patches/14_nfs-fix.patch: Fix gam_server startup for Thunar.
  Thanks to Maximiliano Curia. (Closes: #403247)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
 
2
 
 
3
/* inotify-helper.c - Gnome VFS Monitor based on inotify.
 
4
 
 
5
   Copyright (C) 2005 John McCutchan
 
6
 
 
7
   The Gnome Library is free software; you can redistribute it and/or
 
8
   modify it under the terms of the GNU Library General Public License as
 
9
   published by the Free Software Foundation; either version 2 of the
 
10
   License, or (at your option) any later version.
 
11
 
 
12
   The Gnome Library is distributed in the hope that it will be useful,
 
13
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
   Library General Public License for more details.
 
16
 
 
17
   You should have received a copy of the GNU Library General Public
 
18
   License along with the Gnome Library; see the file COPYING.LIB.  If not,
 
19
   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
20
   Boston, MA 02111-1307, USA.
 
21
 
 
22
   Authors: 
 
23
                 John McCutchan <john@johnmccutchan.com>
 
24
*/
 
25
 
 
26
#include "config.h"
 
27
#include <glib.h>
 
28
#include <sys/types.h>
 
29
#include <unistd.h>
 
30
#include "inotify-missing.h"
 
31
#include "inotify-path.h"
 
32
#include "inotify-diag.h"
 
33
 
 
34
#define DIAG_DUMP_TIME 20000 /* 20 seconds */
 
35
G_LOCK_EXTERN (inotify_lock);
 
36
 
 
37
gboolean id_dump (gpointer userdata)
 
38
{
 
39
        G_LOCK (inotify_lock);
 
40
        GIOChannel *ioc = NULL;
 
41
        pid_t pid = getpid();
 
42
        char *fname = g_strdup_printf("/tmp/gvfsid.%d", pid);
 
43
        ioc = g_io_channel_new_file (fname, "w", NULL);
 
44
        g_free (fname);
 
45
        if (!ioc)
 
46
        {
 
47
                G_UNLOCK (inotify_lock);
 
48
                return TRUE;
 
49
        }
 
50
 
 
51
        im_diag_dump (ioc);
 
52
 
 
53
        g_io_channel_shutdown (ioc, TRUE, NULL);
 
54
        g_io_channel_unref (ioc);
 
55
        G_UNLOCK (inotify_lock);
 
56
        return TRUE;
 
57
}
 
58
 
 
59
void id_startup ()
 
60
{
 
61
        if (!g_getenv ("GNOME_VFS_INOTIFY_DIAG"))
 
62
        {
 
63
                return;
 
64
        }
 
65
        
 
66
        g_timeout_add (DIAG_DUMP_TIME, id_dump, NULL);
 
67
}