[gamin] updated patch



Here is an updated patch to apply to HEAD. Same stuff
as last one + inotify change. 

I tried using getlogin() but that doesn't work because
we don't have a controlling TTY. 

getlogin's man page says to use getpwuid(geteuid()) instead of
cuserid(). We could use $USER? I don't know what the best solution is..
but getlogin() won't work.

John
Index: Makefile.am
===================================================================
RCS file: /cvs/gnome/gamin/Makefile.am,v
retrieving revision 1.3
diff -u -r1.3 Makefile.am
--- Makefile.am	4 Aug 2004 11:14:28 -0000	1.3
+++ Makefile.am	8 Aug 2004 20:33:40 -0000
@@ -1,6 +1,6 @@
 ## Process this file with automake to produce Makefile.in
 
-SUBDIRS = libgamin server tests # docs
+SUBDIRS = lib libgamin server tests # docs
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = gamin.pc
Index: TODO
===================================================================
RCS file: /cvs/gnome/gamin/TODO,v
retrieving revision 1.7
diff -u -r1.7 TODO
--- TODO	4 Aug 2004 12:36:21 -0000	1.7
+++ TODO	8 Aug 2004 20:33:40 -0000
@@ -1,18 +1,18 @@
  - merge GAMIN_EVENT_ with FAMEvents ?
- - path flexibility for the remote server in gam_fork.c (needed for
-   make tests)
  - try to use getlogin and $USER to get the user name
- - test for availability of setsid(), usleep()
  - doc extraction and reformatting of comments in gtk-doc style
  - handling of missing monitored resources where dnotify() won't work
- - code merge between client and server, e.g. libgamin/gam_error.[ch]
-   and server/gam_error.[ch] ?
                                                                                 
 Regression tests:
  - try all the file length on the client till error.
  - try the fragmented/multirequests tests on the client side
 
 Done:
+ - path flexibility for the remote server in gam_fork.c (needed for
+   make tests)
+ - code merge between client and server, e.g. libgamin/gam_error.[ch]
+   and server/gam_error.[ch] ?
+ - test for availability of setsid(), usleep()
  - code and file cleanup, indenting
  - removed old common dependancy
  - autostart/stop of the server side
Index: configure.in
===================================================================
RCS file: /cvs/gnome/gamin/configure.in,v
retrieving revision 1.9
diff -u -r1.9 configure.in
--- configure.in	6 Aug 2004 15:09:14 -0000	1.9
+++ configure.in	8 Aug 2004 20:33:40 -0000
@@ -75,6 +75,8 @@
 
 AM_CONDITIONAL(ENABLE_GTK_DOC, test x$enable_gtk_doc = xyes)
 
+AC_CHECK_FUNCS(usleep setsid getlogin_r)
+
 dnl
 dnl Start of pkg-config checks
 dnl
@@ -282,6 +284,7 @@
 
 AC_OUTPUT([
 Makefile
+lib/Makefile
 libgamin/Makefile
 server/Makefile
 tests/Makefile
Index: libgamin/Makefile.am
===================================================================
RCS file: /cvs/gnome/gamin/libgamin/Makefile.am,v
retrieving revision 1.5
diff -u -r1.5 Makefile.am
--- libgamin/Makefile.am	30 Jul 2004 13:00:46 -0000	1.5
+++ libgamin/Makefile.am	8 Aug 2004 20:33:40 -0000
@@ -1,7 +1,9 @@
 INCLUDES =						\
 	$(default_includes)				\
 	-I$(top_builddir) 				\
+	-I$(top_srcdir)/lib				\
 	-DBINDIR=\""$(bindir)"\"			\
+	-DBUILDDIR=\""$(top_builddir)"\"		\
 	-DGAM_DEBUG_ENABLED
 
 EXTRA_DIST = 						\
@@ -17,13 +19,11 @@
 	gam_api.c					\
 	gam_data.c					\
 	gam_data.h					\
-	gam_error.c					\
-	gam_error.h					\
 	gam_fork.c					\
 	gam_fork.h					\
 	gam_protocol.h
 
-libgamin_1_la_LIBADD = 
+libgamin_1_la_LIBADD = $(top_builddir)/lib/libgamin_shared.a 
 
 libgamin_1_la_LDFLAGS = -Wl,--version-script=gamin_sym.version \
                         -version-info @GAMIN_VERSION_INFO@
Index: libgamin/TODO
===================================================================
RCS file: /cvs/gnome/gamin/libgamin/TODO,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 TODO
--- libgamin/TODO	15 Jun 2004 19:30:48 -0000	1.1.1.1
+++ libgamin/TODO	8 Aug 2004 20:33:40 -0000
@@ -1,10 +1,8 @@
  - on the client handle numbers provided by the caller.
  - merge GAMIN_EVENT_ with FAMEvents ?
  - check both ways of identification, not just server checking client.
- - path flexibility for the remote server in gam_fork.c
  - cleanup deps w.r.t. libmarmot
  - try to use getlogin and $USER to get the user name
- - test for availability of setsid(), usleep()
  - remove threading, gam_poll_init_full(), use timers instead
    of running a loop with usleep in a thread.
  - code 'cb' processing cleanup
@@ -16,6 +14,8 @@
   - try the fragmented/multirequests tests on the client side
 
 Done:
+  - path flexibility for the remote server in gam_fork.c
+  - test for availability of setsid(), usleep()
   - code and file cleanup, indenting
   - removed old common dependancy
   - autostart/stop of the server side
Index: libgamin/gam_api.c
===================================================================
RCS file: /cvs/gnome/gamin/libgamin/gam_api.c,v
retrieving revision 1.13
diff -u -r1.13 gam_api.c
--- libgamin/gam_api.c	6 Aug 2004 15:09:14 -0000	1.13
+++ libgamin/gam_api.c	8 Aug 2004 20:33:40 -0000
@@ -64,12 +64,14 @@
 static char *
 gamin_get_user_name(void)
 {
-    struct passwd *pw;
+	struct passwd *pw;
 
-    pw = getpwuid(getuid());
-    if (pw != NULL)
-        return (strdup(pw->pw_name));
-    return (NULL);
+	pw = getpwuid(getuid());
+
+	if (pw != NULL)
+		return (strdup(pw->pw_name));
+
+	return (NULL);
 }
 
 /**
@@ -344,9 +346,9 @@
             goto retry_start;
         }
         if (retries < MAX_RETRIES) {
+            close(fd);
             usleep(50000);
             retries++;
-            close(fd);
             goto retry_start;
         }
 
Index: libgamin/gam_fork.c
===================================================================
RCS file: /cvs/gnome/gamin/libgamin/gam_fork.c,v
retrieving revision 1.4
diff -u -r1.4 gam_fork.c
--- libgamin/gam_fork.c	6 Aug 2004 12:27:27 -0000	1.4
+++ libgamin/gam_fork.c	8 Aug 2004 20:33:40 -0000
@@ -13,10 +13,29 @@
 #include "gam_error.h"
 
 /**
- * TODO: the patch is computed statically at build time, maybe more
- *       flexibility might be needed.
+ * gamin_find_server_path:
+ *
+ * Tries to find the path to the gam_server binary.
+ * 
+ * Returns path on success or NULL in case of error.
  */
-static const char *server_path = BINDIR "/gam_server";
+static const char *
+gamin_find_server_path()
+{
+	static const char *server_paths[] = {
+						BUILDDIR "/server/gam_server",
+						BINDIR "/gam_server", 
+						NULL
+						};
+	int i;
+
+	for (i = 0; server_paths[i]; i++) {
+		if (access(server_paths[i], X_OK|R_OK) == 0) {
+			return server_paths[i];
+		}
+	}
+	return NULL;
+}
 
 /**
  * gamin_fork_server:
@@ -30,7 +49,12 @@
 int
 gamin_fork_server(const char *fam_client_id)
 {
+    const char *server_path = gamin_find_server_path();
     int ret, pid, status;
+    if (!server_path) {
+	    gam_error(DEBUG_INFO, "failed to find gam_server\n");
+    }
+
 
     gam_debug(DEBUG_INFO, "Asking to launch %s with client id %s\n",
               server_path, fam_client_id);
Index: server/Makefile.am
===================================================================
RCS file: /cvs/gnome/gamin/server/Makefile.am,v
retrieving revision 1.2
diff -u -r1.2 Makefile.am
--- server/Makefile.am	27 Jul 2004 10:24:43 -0000	1.2
+++ server/Makefile.am	8 Aug 2004 20:33:40 -0000
@@ -3,6 +3,7 @@
 	-I$(top_builddir) 				\
 	-I$(top_builddir)/libgamin			\
 	-I$(top_builddir)/protocol			\
+	-I$(top_srcdir)/lib				\
 	$(LIBGAMIN_CFLAGS)				\
 	-DBINDIR=\""$(bindir)"\"			\
 	-DG_DISABLE_DEPRECATED				\
@@ -18,16 +19,12 @@
 	gam_listener.h					\
 	gam_server.c					\
 	gam_server.h					\
-	gam_event.c					\
-	gam_event.h					\
 	gam_node.c					\
 	gam_node.h					\
 	gam_tree.c					\
 	gam_tree.h					\
 	gam_poll.c					\
 	gam_poll.h					\
-	gam_error.c					\
-	gam_error.h					\
 	gam_dnotify.c					\
 	gam_dnotify.h					\
 	gam_inotify.c					\
@@ -39,4 +36,4 @@
 
 gam_server_LDFLAGS =
 gam_server_DEPENDENCIES = $(DEPS)
-gam_server_LDADD= $(LDADDS) $(LIBGAMIN_LIBS)
+gam_server_LDADD= $(top_builddir)/lib/libgamin_shared.a $(LDADDS) $(LIBGAMIN_LIBS)
Index: server/gam_inotify.c
===================================================================
RCS file: /cvs/gnome/gamin/server/gam_inotify.c,v
retrieving revision 1.2
diff -u -r1.2 gam_inotify.c
--- server/gam_inotify.c	5 Aug 2004 14:22:19 -0000	1.2
+++ server/gam_inotify.c	8 Aug 2004 20:33:41 -0000
@@ -14,6 +14,8 @@
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free
  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * TODO:
+ * 	Handle removal of subscriptions when we get IGNORE event
  */
 
 
@@ -91,12 +93,15 @@
 	GList *subs;
 
 	subs = NULL;
+	subs = g_list_append(subs, sub);
 
         if ((data = g_hash_table_lookup(path_hash, path)) != NULL) {
             data->refcount++;
 	    data->subs = g_list_prepend(data->subs, sub);
             G_UNLOCK(inotify);
 	    gam_debug(DEBUG_INFO, "inotify updated refcount\n");
+	    gam_server_emit_event (path, GAMIN_EVENT_EXISTS, subs);
+            gam_server_emit_event (path, GAMIN_EVENT_ENDEXISTS, subs);
             return;
         }
 
@@ -111,7 +116,6 @@
             return;
         }
 
-
         data = gam_inotify_data_new(path, wd);
     	data->subs = g_list_prepend(data->subs, sub);
         g_hash_table_insert(wd_hash, GINT_TO_POINTER(data->wd), data);
@@ -119,8 +123,6 @@
 
         gam_debug(DEBUG_INFO, "activated INotify for %s\n", path);
 
-	subs = g_list_append(subs, sub);
-
 	gam_server_emit_event (path, GAMIN_EVENT_EXISTS, subs);
 	gam_server_emit_event (path, GAMIN_EVENT_ENDEXISTS, subs);
     } else {
@@ -224,9 +226,11 @@
 	return FALSE;
     }
 
-
-    /* Need to walk data->subs list and remove this from each subscription
-    if (event.mask == IN_IGNORE) {
+    /* When we get an ignore event, we 
+     * remove all the subscriptions for this wd
+     */
+    if (event.mask == IN_IGNORED) {
+	    GList *l;
 	    data = g_hash_table_lookup (wd_hash, GINT_TO_POINTER(event.wd));
 
 	    if (!data) {
@@ -234,13 +238,15 @@
 		    return TRUE;
 		}
 
-	    g_hash_table_remove(path_hash, data->path);
-	    g_hash_table_remove(wd_hash, GINT_TO_POINTER(data->wd));
-	    gam_inotify_data_free (data);
+	    l = data->subs;
+	    data->subs = NULL;
+	    for (l = l; l; l = l->next) {
+		    GamSubscription *sub = l->data;
+		    gam_inotify_remove_subscription (sub);
+	    }
 	    G_UNLOCK(inotify);
 	    return TRUE;
     }
-    */
 
     data = g_hash_table_lookup (wd_hash, GINT_TO_POINTER(event.wd));
 


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