[gamin] gamin cleanup patch



Here is another gamin clean up patch.

- cleans out TREADING code
- use automake conditionals
- get rid of gam_inotify.c #ifdef
- --enable-debug now sets -DGAMIN_DEBUG_ENABLED
- gamin_find_server_path returns $GAMIN_DEBUG_SERVER if set

John
Index: configure.in
===================================================================
RCS file: /cvs/gnome/gamin/configure.in,v
retrieving revision 1.10
diff -u -r1.10 configure.in
--- configure.in	10 Aug 2004 08:55:52 -0000	1.10
+++ configure.in	11 Aug 2004 00:18:59 -0000
@@ -137,7 +137,14 @@
 
 AC_ARG_ENABLE(debug,
 [  --enable-debug  Enable debugging messages],
-AC_DEFINE([MARMOT_DEBUG], 1, [Enable debugging messages]),)
+[case "${enableval}" in
+	yes) debug=yes ;;
+	no) debug=no ;;
+	*) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
+esac],[debug=no])
+
+AC_DEFINE([GAMIN_DEBUG], test x$debug = xyes, [Enable debugging messages])
+AM_CONDITIONAL(GAMIN_DEBUG, test x$debug = xyes)
 
 AC_ARG_ENABLE(docs,
 [  --enable-docs   Build documentation (requires Doxygen)],
@@ -175,9 +182,11 @@
 esac])
 
 if test x$backend = xinotify; then
-    AC_DEFINE(USE_INOTIFY,1,[Use inotify as backend])
+    AC_DEFINE(ENABLE_INOTIFY,1,[Use inotify as backend])
 fi
 
+AM_CONDITIONAL(ENABLE_INOTIFY, test x$backend = xinotify)
+
 dnl check for flavours of varargs macros (test from GLib)
 AC_MSG_CHECKING(for ISO C99 varargs macros in C)
 AC_TRY_COMPILE([],[
Index: lib/Makefile.am
===================================================================
RCS file: /cvs/gnome/gamin/lib/Makefile.am,v
retrieving revision 1.1
diff -u -r1.1 Makefile.am
--- lib/Makefile.am	10 Aug 2004 08:55:52 -0000	1.1
+++ lib/Makefile.am	11 Aug 2004 00:18:59 -0000
@@ -1,8 +1,11 @@
 INCLUDES =						\
 	$(default_includes)				\
 	-I$(top_builddir) 				\
-	-I$(top_srcdir)/lib				\
-	-DGAM_DEBUG_ENABLED
+	-I$(top_srcdir)/lib				
+
+if GAMIN_DEBUG
+INCLUDES += -DGAM_DEBUG_ENABLED
+endif
 
 lib_LIBRARIES = libgamin_shared.a
 
Index: libgamin/Makefile.am
===================================================================
RCS file: /cvs/gnome/gamin/libgamin/Makefile.am,v
retrieving revision 1.6
diff -u -r1.6 Makefile.am
--- libgamin/Makefile.am	10 Aug 2004 08:55:52 -0000	1.6
+++ libgamin/Makefile.am	11 Aug 2004 00:18:59 -0000
@@ -3,8 +3,12 @@
 	-I$(top_builddir) 				\
 	-I$(top_srcdir)/lib				\
 	-DBINDIR=\""$(bindir)"\"			\
-	-DBUILDDIR=\""$(top_builddir)"\"		\
-	-DGAM_DEBUG_ENABLED
+	-DBUILDDIR=\""$(top_builddir)"\"		
+
+
+if GAMIN_DEBUG
+INCLUDES += -DGAM_DEBUG_ENABLED
+endif
 
 EXTRA_DIST = 						\
 	gamin_sym.version
Index: libgamin/gam_fork.c
===================================================================
RCS file: /cvs/gnome/gamin/libgamin/gam_fork.c,v
retrieving revision 1.5
diff -u -r1.5 gam_fork.c
--- libgamin/gam_fork.c	10 Aug 2004 08:55:52 -0000	1.5
+++ libgamin/gam_fork.c	11 Aug 2004 00:18:59 -0000
@@ -23,13 +23,15 @@
 gamin_find_server_path()
 {
 	static const char *server_paths[] = {
-/** Disabled right now until we find a safe way to enable this 
-						BUILDDIR "/server/gam_server",
- **/
 						BINDIR "/gam_server", 
 						NULL
 						};
 	int i;
+	const char *gamin_debug_server = getenv("GAMIN_DEBUG_SERVER");
+
+	if (gamin_debug_server) {
+		return gamin_debug_server;
+	}
 
 	for (i = 0; server_paths[i]; i++) {
 		if (access(server_paths[i], X_OK|R_OK) == 0) {
Index: server/Makefile.am
===================================================================
RCS file: /cvs/gnome/gamin/server/Makefile.am,v
retrieving revision 1.3
diff -u -r1.3 Makefile.am
--- server/Makefile.am	10 Aug 2004 08:55:52 -0000	1.3
+++ server/Makefile.am	11 Aug 2004 00:18:59 -0000
@@ -6,8 +6,11 @@
 	-I$(top_srcdir)/lib				\
 	$(LIBGAMIN_CFLAGS)				\
 	-DBINDIR=\""$(bindir)"\"			\
-	-DG_DISABLE_DEPRECATED				\
-	-DGAM_DEBUG_ENABLED
+	-DG_DISABLE_DEPRECATED				
+
+if GAMIN_DEBUG
+INCLUDES += -DGAM_DEBUG_ENABLED
+endif
 
 
 bin_PROGRAMS= gam_server
@@ -27,13 +30,15 @@
 	gam_poll.h					\
 	gam_dnotify.c					\
 	gam_dnotify.h					\
-	gam_inotify.c					\
-	gam_inotify.h					\
 	gam_channel.c					\
 	gam_channel.h					\
 	gam_connection.c				\
 	gam_connection.h
 
+if ENABLE_INOTIFY
+gam_server_SOURCES += gam_inotify.c gam_inotify.h
+endif
+
 gam_server_LDFLAGS =
 gam_server_DEPENDENCIES = $(DEPS)
 gam_server_LDADD= $(top_builddir)/lib/libgamin_shared.a $(LDADDS) $(LIBGAMIN_LIBS)
Index: server/gam_dnotify.c
===================================================================
RCS file: /cvs/gnome/gamin/server/gam_dnotify.c,v
retrieving revision 1.2
diff -u -r1.2 gam_dnotify.c
--- server/gam_dnotify.c	13 Jul 2004 14:24:34 -0000	1.2
+++ server/gam_dnotify.c	11 Aug 2004 00:18:59 -0000
@@ -49,9 +49,6 @@
 /* TODO: GQueue is not signal-safe, need to use something else */
 static GQueue *changes = NULL;
 
-#ifdef WITH_TREADING
-static GMainContext *loop_context;
-#endif
 static GIOChannel *pipe_read_ioc = NULL;
 static GIOChannel *pipe_write_ioc = NULL;
 
@@ -164,15 +161,6 @@
     gam_debug(DEBUG_INFO, "**** signal queue overflow ***\n");
 }
 
-#ifdef WITH_TREADING
-static gpointer
-gam_dnotify_scan_loop(gpointer data)
-{
-    g_main_loop_run(g_main_loop_new(loop_context, TRUE));
-    return (NULL);
-}
-#endif
-
 static gboolean
 gam_dnotify_pipe_handler(gpointer user_data)
 {
@@ -224,11 +212,7 @@
     source = g_idle_source_new();
     g_source_set_callback(source, gam_dnotify_consume_subscriptions_real,
                           NULL, NULL);
-#ifdef WITH_TREADING
-    g_source_attach(source, loop_context);
-#else
     g_source_attach(source, NULL);
-#endif
 }
 
 /**
@@ -273,19 +257,12 @@
     g_io_channel_set_flags(pipe_read_ioc, G_IO_FLAG_NONBLOCK, NULL);
     g_io_channel_set_flags(pipe_write_ioc, G_IO_FLAG_NONBLOCK, NULL);
 
-#ifdef WITH_TREADING
-    loop_context = g_main_context_new();
-#endif
 
     source = g_io_create_watch(pipe_read_ioc,
                                G_IO_IN | G_IO_HUP | G_IO_ERR);
     g_source_set_callback(source, gam_dnotify_pipe_handler, NULL, NULL);
 
-#ifdef WITH_TREADING
-    g_source_attach(source, loop_context);
-#else
     g_source_attach(source, NULL);
-#endif
 
     /* setup some signal stuff */
     act.sa_sigaction = dnotify_signal_handler;
@@ -300,10 +277,6 @@
 
     changes = g_queue_new();
 
-#ifdef WITH_TREADING
-    g_thread_create(gam_dnotify_scan_loop, NULL, TRUE, NULL);
-#endif
-
     path_hash = g_hash_table_new(g_str_hash, g_str_equal);
     fd_hash = g_hash_table_new(g_direct_hash, g_direct_equal);
     gam_poll_set_directory_handler(gam_dnotify_directory_handler);
Index: server/gam_inotify.c
===================================================================
RCS file: /cvs/gnome/gamin/server/gam_inotify.c,v
retrieving revision 1.3
diff -u -r1.3 gam_inotify.c
--- server/gam_inotify.c	10 Aug 2004 08:55:52 -0000	1.3
+++ server/gam_inotify.c	11 Aug 2004 00:18:59 -0000
@@ -20,7 +20,6 @@
 
 
 #include <config.h>
-#ifdef USE_INOTIFY
 #define _GNU_SOURCE
 #include <fcntl.h>
 #include <sys/ioctl.h>
@@ -464,4 +463,3 @@
 }
 
 /** @} */
-#endif /* USE_INOTIFY */
Index: server/gam_node.c
===================================================================
RCS file: /cvs/gnome/gamin/server/gam_node.c,v
retrieving revision 1.2
diff -u -r1.2 gam_node.c
--- server/gam_node.c	13 Jul 2004 14:24:34 -0000	1.2
+++ server/gam_node.c	11 Aug 2004 00:18:59 -0000
@@ -58,9 +58,6 @@
     node->data = NULL;
     node->data_destroy = NULL;
     node->flags = 0;
-#ifdef WITH_TREADING
-    node->lock = g_mutex_new();
-#endif
 
     return node;
 }
@@ -82,9 +79,6 @@
 
     g_free(node->path);
     g_list_free(node->subs);
-#ifdef WITH_TREADING
-    g_mutex_free(node->lock);
-#endif
     g_free(node);
 }
 
@@ -99,13 +93,9 @@
 {
     GamNode *ret = NULL;
 
-    /* gam_node_lock (node); */
-
     if (node->node && node->node->parent)
         ret = (GamNode *) node->node->parent->data;
 
-    /* gam_node_unlock (node); */
-
     return ret;
 }
 
@@ -167,12 +157,10 @@
 gboolean
 gam_node_add_subscription(GamNode * node, GamSubscription * sub)
 {
-    /* gam_node_lock (node); */
 
     if (!g_list_find(node->subs, sub))
         node->subs = g_list_prepend(node->subs, sub);
 
-    /* gam_node_unlock (node); */
 
     return TRUE;
 }
@@ -187,9 +175,7 @@
 gboolean
 gam_node_remove_subscription(GamNode * node, GamSubscription * sub)
 {
-    /* gam_node_lock (node); */
     node->subs = g_list_remove(node->subs, sub);
-    /* gam_node_unlock (node); */
 
     return TRUE;
 }
@@ -212,7 +198,6 @@
     int i = 0;
 
 
-    gam_node_lock(src);
     for (l = gam_node_get_subscriptions(src); l; l = l->next) {
         sub = (GamSubscription *) l->data;
         if (!filter || (filter && (*filter) (sub))) {
@@ -220,7 +205,6 @@
             i++;
         }
     }
-    gam_node_unlock(src);
 
     return i;
 }
@@ -237,7 +221,6 @@
 #ifdef WITH_RECURSIVE
     GList *l;
 
-    /* gam_node_lock (node); */
 
     for (l = gam_node_get_subscriptions(node); l; l = l->next) {
         GamSubscription *sub = (GamSubscription *) l->data;
@@ -246,7 +229,6 @@
             return TRUE;
     }
 
-    /* gam_node_unlock (node); */
 #endif
     return FALSE;
 }
@@ -261,12 +243,10 @@
 void
 gam_node_set_data(GamNode * node, gpointer data, GDestroyNotify destroy)
 {
-    /* gam_node_lock (node); */
 
     node->data = data;
     node->data_destroy = destroy;
 
-    /* gam_node_unlock (node); */
 }
 
 /**
Index: server/gam_node.h
===================================================================
RCS file: /cvs/gnome/gamin/server/gam_node.h,v
retrieving revision 1.2
diff -u -r1.2 gam_node.h
--- server/gam_node.h	13 Jul 2004 14:24:34 -0000	1.2
+++ server/gam_node.h	11 Aug 2004 00:18:59 -0000
@@ -15,9 +15,6 @@
 struct _GamNode {
 	char *path;
 
-#ifdef WITH_TREADING
-	GMutex *lock;
-#endif
 	GList *subs;
 	gboolean is_dir;
 	gpointer data;
@@ -28,13 +25,6 @@
 	GNode *node;
 };
 
-#ifdef WITH_TREADING
-#define gam_node_lock(x) g_mutex_lock (x->lock)
-#define gam_node_unlock(x) g_mutex_unlock (x->lock)
-#else
-#define gam_node_lock(x)
-#define gam_node_unlock(x)
-#endif
 
 GamNode               *gam_node_new                 (const char     *path,
 						   GamSubscription *initial_sub,
Index: server/gam_poll.c
===================================================================
RCS file: /cvs/gnome/gamin/server/gam_poll.c,v
retrieving revision 1.5
diff -u -r1.5 gam_poll.c
--- server/gam_poll.c	4 Aug 2004 12:36:21 -0000	1.5
+++ server/gam_poll.c	11 Aug 2004 00:18:59 -0000
@@ -487,10 +487,6 @@
 {
     tree = gam_tree_new();
 
-#ifdef WITH_TREADING
-    if (start_scan_thread)
-        g_thread_create(gam_poll_scan_loop, NULL, TRUE, NULL);
-#endif
 
     gam_debug(DEBUG_INFO, "Initialized Poll\n");
     return TRUE;
Index: server/gam_server.c
===================================================================
RCS file: /cvs/gnome/gamin/server/gam_server.c,v
retrieving revision 1.5
diff -u -r1.5 gam_server.c
--- server/gam_server.c	5 Aug 2004 14:22:19 -0000	1.5
+++ server/gam_server.c	11 Aug 2004 00:18:59 -0000
@@ -244,15 +244,6 @@
 	}
     }
 
-#ifdef WITH_TREADING
-    g_thread_init(NULL);
-
-    if (!g_thread_supported()) {
-        g_error("The glib thread library does not support your system.\n");
-        exit(1);
-    }
-#endif
-
     if (!gam_init_subscriptions()) {
 	gam_debug(DEBUG_INFO, "Could not initialize the subscription system.\n");
         exit(0);
Index: server/gam_tree.c
===================================================================
RCS file: /cvs/gnome/gamin/server/gam_tree.c,v
retrieving revision 1.2
diff -u -r1.2 gam_tree.c
--- server/gam_tree.c	13 Jul 2004 14:24:34 -0000	1.2
+++ server/gam_tree.c	11 Aug 2004 00:18:59 -0000
@@ -33,9 +33,6 @@
                                  */
     GHashTable *node_hash;      /* a hash table that maps path->node */
 
-#ifdef WITH_TREADING
-    GMutex *lock;
-#endif
 };
 
 typedef struct {
@@ -80,9 +77,6 @@
     tree->root = new_node(gam_node_new("/", NULL, TRUE));
     tree->node_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
                                             g_free, NULL);
-#ifdef WITH_TREADING
-    tree->lock = g_mutex_new();
-#endif
 
     return tree;
 }
@@ -97,9 +91,6 @@
 {
     g_node_destroy(tree->root);
     g_hash_table_destroy(tree->node_hash);
-#ifdef WITH_TREADING
-    g_mutex_free(tree->lock);
-#endif
 
     g_free(tree);
 }
@@ -117,9 +108,6 @@
 {
     GNode *node;
 
-#ifdef WITH_TREADING
-    g_mutex_lock(tree->lock);
-#endif
 
     if (g_hash_table_lookup(tree->node_hash, gam_node_get_path(child)))
         return FALSE; /* lock ??? */
@@ -136,9 +124,6 @@
     g_hash_table_insert(tree->node_hash,
                         g_strdup(gam_node_get_path(child)), node);
 
-#ifdef WITH_TREADING
-    g_mutex_unlock(tree->lock);
-#endif
 
     return TRUE;
 }
@@ -155,9 +140,6 @@
 {
     gboolean ret = FALSE;
 
-#ifdef WITH_TREADING
-    g_mutex_lock(tree->lock);
-#endif
 
     if (g_node_is_ancestor(tree->root, node->node)) {
 
@@ -170,9 +152,6 @@
         ret = TRUE;
     }
 
-#ifdef WITH_TREADING
-    g_mutex_unlock(tree->lock);
-#endif
 
     return ret;
 }


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