summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Drake <dsd@gentoo.org>2005-06-19 15:35:29 +0000
committerDaniel Drake <dsd@gentoo.org>2005-06-19 15:35:29 +0000
commit91860b636545e8bbe9612649a78767b132acaa32 (patch)
tree5de92b5879114f8ec4712be386660b8962d57288 /app-admin/gamin/files
parentInitial import (diff)
downloadhistorical-91860b636545e8bbe9612649a78767b132acaa32.tar.gz
historical-91860b636545e8bbe9612649a78767b132acaa32.tar.bz2
historical-91860b636545e8bbe9612649a78767b132acaa32.zip
Version bump to 0.1.1, should solve bug 74285. Requires a new inotify kernel such as gentoo-sources-2.6.12 for best performance.
Package-Manager: portage-1.589-cvs
Diffstat (limited to 'app-admin/gamin/files')
-rw-r--r--app-admin/gamin/files/digest-gamin-0.1.11
-rw-r--r--app-admin/gamin/files/gamin-0.1.1-inotify-fix.patch482
2 files changed, 483 insertions, 0 deletions
diff --git a/app-admin/gamin/files/digest-gamin-0.1.1 b/app-admin/gamin/files/digest-gamin-0.1.1
new file mode 100644
index 000000000000..f33e19ddded8
--- /dev/null
+++ b/app-admin/gamin/files/digest-gamin-0.1.1
@@ -0,0 +1 @@
+MD5 5c5330c3df26ece7d71b69a0b8f4a126 gamin-0.1.1.tar.gz 512316
diff --git a/app-admin/gamin/files/gamin-0.1.1-inotify-fix.patch b/app-admin/gamin/files/gamin-0.1.1-inotify-fix.patch
new file mode 100644
index 000000000000..5dbb9e415516
--- /dev/null
+++ b/app-admin/gamin/files/gamin-0.1.1-inotify-fix.patch
@@ -0,0 +1,482 @@
+===================================================================
+RCS file: /cvs/gnome/gamin/server gam_dnotify.c,v
+retrieving revision 1.19
+retrieving revision 1.20
+diff -u -r1.19 -r1.20
+--- server/gam_dnotify.c 2005/06/08 13:57:28 1.19
++++ server/gam_dnotify.c 2005/06/13 09:13:45 1.20
+@@ -58,6 +58,29 @@
+
+ static gboolean have_consume_idler = FALSE;
+
++void
++gam_dnotify_data_debug (gpointer key, gpointer value, gpointer user_data)
++{
++ DNotifyData *data = (DNotifyData *)value;
++
++ if (!data)
++ return;
++
++ int deactivated = data->fd == -1 ? 1 : 0;
++
++ GAM_DEBUG(DEBUG_INFO, "dsub fd %d refs %d busy %d deactivated %d: %s\n", data->fd, data->refcount, data->busy, deactivated, data->path);
++}
++
++void
++gam_dnotify_debug (void)
++{
++ if (path_hash == NULL)
++ return;
++
++ GAM_DEBUG(DEBUG_INFO, "Dumping dnotify subscriptions\n");
++ g_hash_table_foreach (path_hash, gam_dnotify_data_debug, NULL);
++}
++
+ static DNotifyData *
+ gam_dnotify_data_new(const char *path, int fd)
+ {
+===================================================================
+RCS file: /cvs/gnome/gamin/server gam_dnotify.h,v
+retrieving revision 1.1
+retrieving revision 1.2
+diff -u -r1.1 -r1.2
+--- server/gam_dnotify.h 2004/06/15 19:30:49 1.1
++++ server/gam_dnotify.h 2005/06/13 09:13:45 1.2
+@@ -12,6 +12,7 @@
+ gboolean gam_dnotify_add_subscription (GamSubscription *sub);
+ gboolean gam_dnotify_remove_subscription (GamSubscription *sub);
+ gboolean gam_dnotify_remove_all_for (GamListener *listener);
++void gam_dnotify_debug (void);
+
+ G_END_DECLS
+
+===================================================================
+RCS file: /cvs/gnome/gamin/server gam_inotify.c,v
+retrieving revision 1.23
+retrieving revision 1.24
+diff -u -r1.23 -r1.24
+--- server/gam_inotify.c 2005/06/08 09:35:56 1.23
++++ server/gam_inotify.c 2005/06/13 09:13:45 1.24
+@@ -44,15 +44,15 @@
+ #include "gam_debugging.h"
+ #endif
+
+-#define MIN_POLL_TIME 1.0
+-
+ typedef struct {
+ char *path;
+ int wd;
+ int refcount;
+ GList *subs;
+ int busy;
+- gboolean deactivated;
++ gboolean deactivated;
++ int events;
++ int deactivated_events;
+ } inotify_data_t;
+
+ static GHashTable *path_hash = NULL;
+@@ -68,6 +68,36 @@
+
+ static guint should_poll_mask = IN_MODIFY|IN_ATTRIB|IN_CLOSE_WRITE|IN_MOVED_FROM|IN_MOVED_TO|IN_DELETE|IN_CREATE|IN_DELETE_SELF|IN_UNMOUNT;
+
++static void
++gam_inotify_data_debug (gpointer key, gpointer value, gpointer user_data)
++{
++ inotify_data_t *data = (inotify_data_t *)value;
++
++ if (!data)
++ return;
++
++ int deactivated = data->deactivated;
++
++ GAM_DEBUG(DEBUG_INFO, "isub wd %d refs %d busy %d deactivated %d events (%d:%d): %s\n", data->wd, data->refcount, data->busy, deactivated, data->events, data->deactivated_events, data->path);
++}
++
++void
++gam_inotify_debug(void)
++{
++ if (inotify_device_fd == -1)
++ {
++ GAM_DEBUG(DEBUG_INFO, "Inotify device not opened\n");
++ return;
++ }
++
++ if (path_hash == NULL)
++ return;
++
++ GAM_DEBUG(DEBUG_INFO, "Inotify device fd = %d\n", inotify_device_fd);
++ GAM_DEBUG(DEBUG_INFO, "Dumping inotify subscriptions\n");
++ g_hash_table_foreach (path_hash, gam_inotify_data_debug, NULL);
++}
++
+ static void print_mask(int mask)
+ {
+ if (mask & IN_ACCESS)
+@@ -138,6 +168,8 @@
+ data->wd = wd;
+ data->busy = 0;
+ data->refcount = 1;
++ data->deactivated_events = 0;
++ data->events = 0;
+
+ return data;
+ }
+@@ -145,7 +177,7 @@
+ static void
+ gam_inotify_data_free(inotify_data_t * data)
+ {
+- if (data->refcount != 0)
++ if (data->refcount != 0)
+ GAM_DEBUG(DEBUG_INFO, "gam_inotify_data_free called with reffed data.\n");
+ g_free(data->path);
+ g_free(data);
+@@ -155,11 +187,8 @@
+ gam_inotify_directory_handler_internal(const char *path, pollHandlerMode mode)
+ {
+ inotify_data_t *data;
+- int path_fd;
+- int path_wd;
++ int path_fd, path_wd;
+ struct inotify_watch_request iwr;
+-
+-
+ switch (mode) {
+ case GAMIN_ACTIVATE:
+ GAM_DEBUG(DEBUG_INFO, "Adding %s to inotify\n", path);
+@@ -178,9 +207,11 @@
+ mode, path);
+ return;
+ }
++
+ G_LOCK(inotify);
+
+ if (mode == GAMIN_ACTIVATE) {
++
+ if ((data = g_hash_table_lookup(path_hash, path)) != NULL) {
+ data->refcount++;
+ GAM_DEBUG(DEBUG_INFO, " found incremented refcount: %d\n",
+@@ -214,24 +245,13 @@
+ gam_debug_report(GAMinotifyCreate, path, 0);
+ #endif
+ } else if (mode == GAMIN_DESACTIVATE) {
+- char *dir = (char *) path;
+-
+ data = g_hash_table_lookup(path_hash, path);
+
+ if (!data) {
+- dir = g_path_get_dirname(path);
+- data = g_hash_table_lookup(path_hash, dir);
+-
+- if (!data) {
+- GAM_DEBUG(DEBUG_INFO, " not found !!!\n");
++ GAM_DEBUG(DEBUG_INFO, " not found !!!\n");
+
+- if (dir != NULL)
+- g_free(dir);
+-
+- G_UNLOCK(inotify);
+- return;
+- }
+- GAM_DEBUG(DEBUG_INFO, " not found using parent\n");
++ G_UNLOCK(inotify);
++ return;
+ }
+
+ data->refcount--;
+@@ -240,46 +260,32 @@
+
+ if (data->refcount == 0) {
+ int wd = data->wd;
+-
+- GAM_DEBUG(DEBUG_INFO, "removed inotify watch for %s\n", data->path);
+-
++ GAM_DEBUG(DEBUG_INFO, "removed inotify watch for %s\n",
++ data->path);
+ g_hash_table_remove(path_hash, data->path);
+ g_hash_table_remove(wd_hash, GINT_TO_POINTER(data->wd));
+ gam_inotify_data_free(data);
+-
+ if (ioctl (inotify_device_fd, INOTIFY_IGNORE, &wd) < 0) {
+ GAM_DEBUG (DEBUG_INFO, "INOTIFY_IGNORE failed for %s (wd = %d)\n", data->path, data->wd);
+ }
+ #ifdef GAMIN_DEBUG_API
+- gam_debug_report(GAMinotifyDelete, dir, 0);
++ gam_debug_report(GAMinotifyDelete, data->path, 0);
+ #endif
+ } else {
+ GAM_DEBUG(DEBUG_INFO, " found decremented refcount: %d\n",
+ data->refcount);
+ #ifdef GAMIN_DEBUG_API
+- gam_debug_report(GAMinotifyChange, dir, data->refcount);
++ gam_debug_report(GAMinotifyChange, data->path, data->refcount);
+ #endif
+ }
+- if ((dir != path) && (dir != NULL))
+- g_free(dir);
+ } else if ((mode == GAMIN_FLOWCONTROLSTART) ||
+ (mode == GAMIN_FLOWCONTROLSTOP)) {
+- char *dir = (char *) path;
+-
+ data = g_hash_table_lookup(path_hash, path);
+ if (!data) {
+- dir = g_path_get_dirname(path);
+- data = g_hash_table_lookup(path_hash, dir);
+-
+- if (!data) {
+- GAM_DEBUG(DEBUG_INFO, " not found !!!\n");
++ GAM_DEBUG(DEBUG_INFO, " not found !!!\n");
+
+- if (dir != NULL)
+- g_free(dir);
+- G_UNLOCK(inotify);
+- return;
+- }
+- GAM_DEBUG(DEBUG_INFO, " not found using parent\n");
++ G_UNLOCK(inotify);
++ return;
+ }
+ if (data != NULL) {
+ if (mode == GAMIN_FLOWCONTROLSTART) {
+@@ -292,7 +298,7 @@
+ GAM_DEBUG(DEBUG_INFO, "deactivated inotify for %s\n",
+ data->path);
+ #ifdef GAMIN_DEBUG_API
+- gam_debug_report(GAMinotifyFlowOn, dir, 0);
++ gam_debug_report(GAMinotifyFlowOn, data->path, 0);
+ #endif
+ }
+ data->busy++;
+@@ -310,13 +316,11 @@
+ "failed to reactivate inotify for %s\n",
+ data->path);
+
+- if ((dir != path) && (dir != NULL))
+- g_free(dir);
+ return;
+ }
+
+ iwr.fd = path_fd;
+- iwr.mask = 0xffffffff;
++ iwr.mask = should_poll_mask;
+ path_wd = ioctl (inotify_device_fd, INOTIFY_WATCH, &iwr);
+ close (path_fd);
+
+@@ -338,8 +342,6 @@
+ }
+ }
+ }
+- if ((dir != path) && (dir != NULL))
+- g_free(dir);
+ } else {
+ GAM_DEBUG(DEBUG_INFO, "Unimplemented operation\n");
+ }
+@@ -353,17 +355,7 @@
+ GAM_DEBUG(DEBUG_INFO, "gam_inotify_directory_handler %s : %d\n",
+ path, mode);
+
+- if ((mode == GAMIN_DESACTIVATE) ||
+- (g_file_test(path, G_FILE_TEST_IS_DIR))) {
+- gam_inotify_directory_handler_internal(path, mode);
+- } else {
+- char *dir;
+-
+- dir = g_path_get_dirname(path);
+- GAM_DEBUG(DEBUG_INFO, " not a dir using parent %s\n", dir);
+- gam_inotify_directory_handler_internal(dir, mode);
+- g_free(dir);
+- }
++ gam_inotify_directory_handler_internal(path, mode);
+ }
+
+ static void
+@@ -374,15 +366,18 @@
+ if (g_file_test(path, G_FILE_TEST_IS_DIR)) {
+ gam_inotify_directory_handler_internal(path, mode);
+ } else {
+- char *dir;
+-
+- dir = g_path_get_dirname(path);
+- GAM_DEBUG(DEBUG_INFO, " not a dir using parent %s\n", dir);
+- gam_inotify_directory_handler_internal(dir, mode);
+- g_free(dir);
++ GAM_DEBUG(DEBUG_INFO, " not a dir %s, FAILED!!!\n", path);
+ }
+ }
+
++static void
++gam_inotify_q_overflow (gpointer key, gpointer value, gpointer user_data)
++{
++ inotify_data_t *data = (inotify_data_t *)value;
++
++ gam_poll_scan_directory (data->path);
++}
++
+ static gboolean
+ gam_inotify_read_handler(gpointer user_data)
+ {
+@@ -393,10 +388,6 @@
+
+ G_LOCK(inotify);
+
+-#if 0
+- gam_inotify_dirty_list_cleaner ();
+-#endif
+-
+ if (ioctl(inotify_device_fd, FIONREAD, &buffer_size) < 0) {
+ G_UNLOCK(inotify);
+ GAM_DEBUG(DEBUG_INFO, "inotify FIONREAD < 0. kaboom!\n");
+@@ -427,6 +418,7 @@
+ GAM_DEBUG(DEBUG_INFO, "processing event: inotify can't find wd %d\n", event->wd);
+ } else if (data->deactivated) {
+ GAM_DEBUG(DEBUG_INFO, "inotify: ignoring event on temporarily deactivated watch %s\n", data->path);
++ data->deactivated_events++;
+ } else {
+ if (event->mask == IN_IGNORED) {
+ GList *l;
+@@ -434,6 +426,8 @@
+ GAM_DEBUG(DEBUG_INFO, "inotify: IN_IGNORE on wd=%d\n", event->wd);
+ GAM_DEBUG(DEBUG_INFO, "inotify: removing all subscriptions for %s\n", data->path);
+
++ data->events++;
++
+ l = data->subs;
+ data->subs = NULL;
+ for (l = l; l; l = l->next) {
+@@ -445,11 +439,12 @@
+ GAM_DEBUG(DEBUG_INFO, "inotify requesting poll for %s\n", data->path);
+ GAM_DEBUG(DEBUG_INFO, "poll was requested for event = ");
+ print_mask (event->mask);
++ data->events++;
+ gam_poll_scan_directory (data->path);
+ }
+ } else if (event->mask == IN_Q_OVERFLOW) {
+- GAM_DEBUG(DEBUG_INFO, "inotify queue over flowed\n");
+- GAM_DEBUG(DEBUG_INFO, "FIXME, should request poll for all paths here\n");
++ GAM_DEBUG(DEBUG_INFO, "inotify queue over flowed, requesting poll on all watched paths\n");
++ g_hash_table_foreach (path_hash, gam_inotify_q_overflow, NULL);
+ }
+ }
+
+@@ -516,16 +511,16 @@
+ {
+ GSource *source;
+
++ g_return_val_if_fail(gam_poll_init_full(FALSE), FALSE);
++
+ inotify_device_fd = open("/dev/inotify", O_RDONLY);
+
+ if (inotify_device_fd < 0) {
+- GAM_DEBUG(DEBUG_INFO, "Could not open /dev/inotify\n");
+- return FALSE;
++ GAM_DEBUG(DEBUG_INFO, "Could not open /dev/inotify\n");
++ return FALSE;
+ }
+
+- g_return_val_if_fail(gam_poll_init_full(FALSE), FALSE);
+-
+- inotify_read_ioc = g_io_channel_unix_new(inotify_device_fd);
++ inotify_read_ioc = g_io_channel_unix_new(inotify_device_fd);
+
+ /* For binary data */
+ g_io_channel_set_encoding(inotify_read_ioc, NULL, NULL);
+@@ -563,6 +558,7 @@
+ gam_inotify_add_subscription(GamSubscription * sub)
+ {
+ GAM_DEBUG(DEBUG_INFO, "gam_inotify_add_subscription\n");
++
+ if (!gam_poll_add_subscription(sub)) {
+ return FALSE;
+ }
+===================================================================
+RCS file: /cvs/gnome/gamin/server gam_inotify.h,v
+retrieving revision 1.2
+retrieving revision 1.3
+diff -u -r1.2 -r1.3
+--- server/gam_inotify.h 2005/04/15 11:17:38 1.2
++++ server/gam_inotify.h 2005/06/13 09:13:45 1.3
+@@ -11,6 +11,7 @@
+ gboolean gam_inotify_add_subscription (GamSubscription *sub);
+ gboolean gam_inotify_remove_subscription (GamSubscription *sub);
+ gboolean gam_inotify_remove_all_for (GamListener *listener);
++void gam_inotify_debug (void);
+
+ G_END_DECLS
+
+===================================================================
+RCS file: /cvs/gnome/gamin/server gam_poll.c,v
+retrieving revision 1.56
+retrieving revision 1.57
+diff -u -r1.56 -r1.57
+--- server/gam_poll.c 2005/06/10 14:31:33 1.56
++++ server/gam_poll.c 2005/06/13 09:13:45 1.57
+@@ -149,7 +149,7 @@
+ static void
+ trigger_dir_handler(const char *path, pollHandlerMode mode, GamNode * node)
+ {
+- if (type_khandler == GAMIN_K_DNOTIFY) {
++ if (type_khandler == GAMIN_K_DNOTIFY || type_khandler == GAMIN_K_INOTIFY) {
+ if (gam_node_is_dir(node)) {
+ if (dir_handler != NULL)
+ (*dir_handler) (path, mode);
+@@ -172,7 +172,7 @@
+ static void
+ trigger_file_handler(const char *path, pollHandlerMode mode, GamNode * node)
+ {
+- if (type_khandler == GAMIN_K_DNOTIFY) {
++ if (type_khandler == GAMIN_K_DNOTIFY || type_khandler == GAMIN_K_INOTIFY) {
+ if (gam_node_is_dir(node)) {
+ (*file_handler) (path, mode);
+ } else {
+@@ -947,8 +947,14 @@
+ gboolean
+ gam_poll_init_full(gboolean start_scan_thread)
+ {
++ /* already started */
++ if ((poll_mode == 2) && (start_scan_thread))
++ return (TRUE);
++ if ((poll_mode == 1) && (!start_scan_thread))
++ return (TRUE);
++ /* not started as expected */
+ if (poll_mode != 0)
+- return (FALSE);
++ return(FALSE);
+
+ if (!start_scan_thread) {
+ g_timeout_add(1000, gam_poll_scan_callback, NULL);
+===================================================================
+RCS file: /cvs/gnome/gamin/server gam_server.c,v
+retrieving revision 1.24
+retrieving revision 1.25
+diff -u -r1.24 -r1.25
+--- server/gam_server.c 2005/06/08 22:07:51 1.24
++++ server/gam_server.c 2005/06/13 09:13:45 1.25
+@@ -82,6 +82,12 @@
+ void
+ gam_show_debug(void) {
+ gam_connections_debug();
++#ifdef ENABLE_INOTIFY
++ gam_inotify_debug ();
++#endif
++#ifdef ENABLE_DNOTIFY
++ gam_dnotify_debug ();
++#endif
+ }
+
+ /**
+===================================================================
+RCS file: /cvs/gnome/gamin/tests testing.c,v
+retrieving revision 1.10
+retrieving revision 1.11
+diff -u -r1.10 -r1.11
+--- tests/testing.c 2005/04/04 11:51:38 1.10
++++ tests/testing.c 2005/06/13 09:13:45 1.11
+@@ -313,7 +313,7 @@
+ testState.nb_requests++;
+ } else if (!strcmp(command, "monfile")) {
+ if (args != 2) {
+- fprintf(stderr, "mkdir line %d: lacks name\n", no);
++ fprintf(stderr, "monfile line %d: lacks name\n", no);
+ return (-1);
+ }
+ if (arg[0] != '/')