[gamin] another gamin patch



adds lib/libgamin_shared.a
merges gam_error.[ch] from server/ and libgamin/
checks for setsid(), usleep() functions in configure.in
gam_fork() will try and execute the gam_server in the builddir
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	7 Aug 2004 20:06:33 -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	7 Aug 2004 20:06:33 -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.8
diff -u -r1.8 configure.in
--- configure.in	5 Aug 2004 14:53:05 -0000	1.8
+++ configure.in	7 Aug 2004 20:06:34 -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	7 Aug 2004 20:06:34 -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	7 Aug 2004 20:06:34 -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.12
diff -u -r1.12 gam_api.c
--- libgamin/gam_api.c	3 Aug 2004 12:55:03 -0000	1.12
+++ libgamin/gam_api.c	7 Aug 2004 20:06:34 -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) {
-            usleep(100);
-            retries++;
             close(fd);
+            usleep(1000);
+            retries++;
             goto retry_start;
         }
 
Index: libgamin/gam_fork.c
===================================================================
RCS file: /cvs/gnome/gamin/libgamin/gam_fork.c,v
retrieving revision 1.3
diff -u -r1.3 gam_fork.c
--- libgamin/gam_fork.c	5 Aug 2004 10:01:41 -0000	1.3
+++ libgamin/gam_fork.c	7 Aug 2004 20:06:34 -0000
@@ -11,10 +11,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:
@@ -28,6 +47,11 @@
 int
 gamin_fork_server(const char *fam_client_id)
 {
+    const char *server_path = gamin_find_server_path();
+    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);
     /* Become a daemon */
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	7 Aug 2004 20:06:34 -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	7 Aug 2004 20:06:34 -0000
@@ -14,6 +14,10 @@
  * 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
+ * 	Change the Exists/EndExists code to output for every
+ * 		subscription not just the first
  */
 
 
@@ -91,12 +95,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,15 +118,12 @@
             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);
         g_hash_table_insert(path_hash, data->path, data);
 
         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);


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