diff options
author | marcus <marcus@FreeBSD.org> | 2006-02-11 14:58:29 +0800 |
---|---|---|
committer | marcus <marcus@FreeBSD.org> | 2006-02-11 14:58:29 +0800 |
commit | 929f909f0416ed76674be6fe173f48b20bc7bd6b (patch) | |
tree | b6e40f94f28d48dcc0ded854857b92ea40ee9ecd /devel/gamin | |
parent | 86e8d04809ca8f1e62745ac7a6f4b1677d66ef79 (diff) | |
download | freebsd-ports-gnome-929f909f0416ed76674be6fe173f48b20bc7bd6b.tar.gz freebsd-ports-gnome-929f909f0416ed76674be6fe173f48b20bc7bd6b.tar.zst freebsd-ports-gnome-929f909f0416ed76674be6fe173f48b20bc7bd6b.zip |
* Restore the stale socket cleanup code from gamin 0.1.5 to ensure that even
if gamin crashes or is killed with SIGKILL, a leftover socket does not
prevent gam_server from starting.
* Revert to using the home-grown poller in gamin's kqueue backend instead
of gamin's built-in poller. The built-in poller can still be enabled if
desired via OPTIONS.
* If gamin's poller is used, make sure all local file systems are handled
by kqueue where as all remote file systems are handled by polling.
Reviewed by: jylefort
Diffstat (limited to 'devel/gamin')
-rw-r--r-- | devel/gamin/Makefile | 16 | ||||
-rw-r--r-- | devel/gamin/files/patch-server_gam_channel.c | 57 | ||||
-rw-r--r-- | devel/gamin/files/patch-server_gam_fs.c | 86 |
3 files changed, 113 insertions, 46 deletions
diff --git a/devel/gamin/Makefile b/devel/gamin/Makefile index b3bcdf34d15b..0c5398bf49f0 100644 --- a/devel/gamin/Makefile +++ b/devel/gamin/Makefile @@ -7,7 +7,7 @@ PORTNAME= gamin PORTVERSION= 0.1.7 -PORTREVISION?= 0 +PORTREVISION?= 1 CATEGORIES?= devel MASTER_SITES= http://www.gnome.org/~veillard/gamin/sources/ @@ -19,8 +19,9 @@ USE_GNOME?= gnomehack glib20 INSTALLS_SHLIB= yes CONFIGURE_ARGS?=--with-html-dir=${PREFIX}/share/doc \ --without-python -CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include ${PTHREAD_CFLAGS}" \ +CONFIGURE_ENV= CPPFLAGS="${CPPFLAGS}" \ LDFLAGS="-L${LOCALBASE}/lib ${PTHREAD_LIBS}" +CPPFLAGS= -I${LOCALBASE}/include ${PTHREAD_CFLAGS} CONFLICTS= fam-[0-9]* @@ -28,6 +29,15 @@ CONFLICTS= fam-[0-9]* USE_AUTOTOOLS= libtool:15 .else USE_AUTOTOOLS= libtool:15:inc +OPTIONS= GAM_POLLER "Use gamin's poller instead of kqueue's" off +.endif + +.include <bsd.port.pre.mk> + +.if !defined(GAMIN_SLAVE) +.if defined(WITH_GAM_POLLER) +CPPFLAGS+= -DUSE_GAMIN_POLLER=1 +.endif .endif post-patch: @@ -43,4 +53,4 @@ post-install: @${CAT} ${PKGMESSAGE} .endif -.include <bsd.port.mk> +.include <bsd.port.post.mk> diff --git a/devel/gamin/files/patch-server_gam_channel.c b/devel/gamin/files/patch-server_gam_channel.c index b87f2543dbcc..7b5fb8aeee22 100644 --- a/devel/gamin/files/patch-server_gam_channel.c +++ b/devel/gamin/files/patch-server_gam_channel.c @@ -1,5 +1,5 @@ ---- server/gam_channel.c.orig Tue Aug 9 18:17:39 2005 -+++ server/gam_channel.c Wed Feb 8 11:23:26 2006 +--- server/gam_channel.c.orig Tue Aug 9 12:17:39 2005 ++++ server/gam_channel.c Fri Feb 10 01:22:46 2006 @@ -7,6 +7,7 @@ #include <sys/stat.h> #include <sys/un.h> @@ -8,7 +8,7 @@ #include "gam_error.h" #include "gam_connection.h" #include "gam_channel.h" -@@ -30,10 +31,10 @@ +@@ -30,10 +31,10 @@ gam_client_conn_send_cred(int fd) { char data[2] = { 0, 0 }; int written; @@ -22,7 +22,7 @@ } cmsg; struct iovec iov; struct msghdr msg; -@@ -45,16 +46,16 @@ +@@ -45,16 +46,16 @@ gam_client_conn_send_cred(int fd) msg.msg_iov = &iov; msg.msg_iovlen = 1; @@ -43,7 +43,7 @@ written = sendmsg(fd, &msg, 0); #else written = write(fd, &data[0], 1); -@@ -95,15 +96,16 @@ +@@ -95,15 +96,16 @@ gam_client_conn_check_cred(GIOChannel * gid_t c_gid; #ifdef HAVE_CMSGCRED @@ -63,7 +63,7 @@ /* Set the socket to receive credentials on the next message */ { int on = 1; -@@ -124,8 +126,8 @@ +@@ -124,8 +126,8 @@ gam_client_conn_check_cred(GIOChannel * #ifdef HAVE_CMSGCRED memset(&cmsg, 0, sizeof(cmsg)); @@ -74,7 +74,7 @@ #endif retry: -@@ -142,7 +144,7 @@ +@@ -142,7 +144,7 @@ gam_client_conn_check_cred(GIOChannel * goto failed; } #ifdef HAVE_CMSGCRED @@ -83,7 +83,7 @@ GAM_DEBUG(DEBUG_INFO, "Message from recvmsg() was not SCM_CREDS\n"); goto failed; -@@ -168,9 +170,10 @@ +@@ -168,9 +170,10 @@ gam_client_conn_check_cred(GIOChannel * goto failed; } #elif defined(HAVE_CMSGCRED) @@ -97,18 +97,31 @@ #else /* !SO_PEERCRED && !HAVE_CMSGCRED */ GAM_DEBUG(DEBUG_INFO, "Socket credentials not supported on this OS\n"); -@@ -557,11 +560,9 @@ - path); - goto cleanup; +@@ -620,6 +621,7 @@ gam_listen_unix_socket(const char *path) + { + int fd; + struct sockaddr_un addr; ++ struct stat st; + + fd = socket(PF_UNIX, SOCK_STREAM, 0); + if (fd < 0) { +@@ -640,8 +642,18 @@ gam_listen_unix_socket(const char *path) + * some extra protection checks. Also make sure the socket is created + * with restricted mode + */ +- if (!gam_check_secure_path(path)) { ++ if (!gam_check_secure_dir()) { ++ close(fd); + return (-1); ++ } ++ ++ if (stat(path, &st) == 0) { ++ /* bind() will fail if the socket already exists */ ++ if (unlink(path) < 0) { ++ GAM_DEBUG(DEBUG_INFO, "Failed to remove %s\n", path); ++ close(fd); ++ return (-1); ++ } } -- /* -- * Looks good though binding may fail due to an existing server -- */ -- return(TRUE); -- -+ gam_error(DEBUG_INFO, -+ "Maybe there is another server listening on socket %s\n", -+ path); - cleanup: - /* - * the existing file at the socket location seems strange, try to remove it + strncpy(&addr.sun_path[0], path, (sizeof(addr) - 4) - 1); + umask(0077); diff --git a/devel/gamin/files/patch-server_gam_fs.c b/devel/gamin/files/patch-server_gam_fs.c index 5039c65931ad..342eb8f0af0e 100644 --- a/devel/gamin/files/patch-server_gam_fs.c +++ b/devel/gamin/files/patch-server_gam_fs.c @@ -1,5 +1,5 @@ ---- server/gam_fs.c.orig Sat Aug 6 00:31:46 2005 -+++ server/gam_fs.c Wed Feb 8 15:05:24 2006 +--- server/gam_fs.c.orig Fri Aug 5 18:31:46 2005 ++++ server/gam_fs.c Sat Feb 11 01:44:04 2006 @@ -7,6 +7,11 @@ #include <string.h> #include <errno.h> @@ -12,17 +12,21 @@ #include "gam_error.h" #include "gam_fs.h" -@@ -26,7 +31,9 @@ +@@ -21,9 +26,13 @@ typedef struct _gam_fs_properties { + typedef struct _gam_fs { + char *path; + char *fsname; ++ guint64 flags; + } gam_fs; + static gboolean initialized = FALSE; ++#ifdef __FreeBSD__ ++static gboolean initializing = FALSE; ++#endif static GList *filesystems = NULL; static GList *fs_props = NULL; -+#ifdef __linux__ static struct stat mtab_sbuf; -+#endif - - static void - gam_fs_free_filesystems (void) -@@ -110,6 +117,7 @@ +@@ -110,6 +119,7 @@ gam_fs_filesystem_sort_cb (gconstpointer return strlen(fsb->path) - strlen (fsa->path); } @@ -30,7 +34,7 @@ static void gam_fs_scan_mtab (void) { -@@ -165,10 +173,40 @@ +@@ -165,10 +175,41 @@ gam_fs_scan_mtab (void) gam_fs_free_filesystems (); filesystems = g_list_sort (new_filesystems, gam_fs_filesystem_sort_cb); } @@ -54,6 +58,7 @@ + fs = g_new0 (gam_fs, 1); + fs->path = g_strdup (stat[i].f_mntonname); + fs->fsname = g_strdup (stat[i].f_fstypename); ++ fs->flags = stat[i].f_flags; + + new_filesystems = g_list_prepend (new_filesystems, fs); + } @@ -71,7 +76,7 @@ if (initialized == FALSE) { initialized = TRUE; -@@ -181,6 +219,7 @@ +@@ -181,6 +222,7 @@ gam_fs_init (void) if (stat("/etc/mtab", &mtab_sbuf) != 0) { GAM_DEBUG(DEBUG_INFO, "Could not stat /etc/mtab\n"); @@ -79,7 +84,7 @@ } gam_fs_scan_mtab (); } else { -@@ -189,6 +228,7 @@ +@@ -189,6 +231,7 @@ gam_fs_init (void) if (stat("/etc/mtab", &sbuf) != 0) { GAM_DEBUG(DEBUG_INFO, "Could not stat /etc/mtab\n"); @@ -87,25 +92,62 @@ } /* /etc/mtab has changed */ -@@ -199,6 +239,17 @@ +@@ -199,6 +242,54 @@ gam_fs_init (void) mtab_sbuf = sbuf; } +#elif defined(__FreeBSD__) -+ if (initialized == FALSE) ++ if (initialized == FALSE && initializing == FALSE) + { ++ GList *iterator = NULL; ++ GHashTable *fs_hash = NULL; ++ gam_fs *fs = NULL; ++ + initialized = TRUE; -+ gam_fs_set ("ufs", GFS_MT_KERNEL, 0); -+ gam_fs_set ("nfs", GFS_MT_POLL, 5); -+ gam_fs_set ("smbfs", GFS_MT_POLL, 5); -+ } -+ gam_fs_getmntinfo (); ++ initializing = TRUE; ++ ++ gam_fs_getmntinfo (); + ++ iterator = filesystems; ++ fs_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); ++ ++ while (iterator) { ++ fs = iterator->data; ++ ++ if (!g_hash_table_lookup (fs_hash, fs->fsname)) { ++ if (fs->flags & MNT_LOCAL) ++ gam_fs_set (fs->fsname, GFS_MT_KERNEL, 0); ++ else ++ gam_fs_set (fs->fsname, GFS_MT_POLL, 5); ++ ++ g_hash_table_insert (fs_hash, g_strdup (fs->fsname), GINT_TO_POINTER (1)); ++ } ++ ++ iterator = g_list_next (iterator); ++ } ++ ++ g_hash_table_destroy (fs_hash); ++ initializing = FALSE; ++ } else if (initializing == FALSE) { ++ struct stat sbuf; ++ ++ if (stat ("/etc/fstab", &sbuf) != 0) { ++ GAM_DEBUG(DEBUG_INFO, "Could not stat /etc/fstab\n"); ++ return; ++ } ++ ++ if (sbuf.st_mtime != mtab_sbuf.st_mtime) { ++ GAM_DEBUG(DEBUG_INFO, "Updating list of mounted filesystems\n"); ++ gam_fs_getmntinfo (); ++ } ++ ++ mtab_sbuf = sbuf; ++ } +#endif } gam_fs_mon_type -@@ -209,10 +260,11 @@ +@@ -209,10 +300,13 @@ gam_fs_get_mon_type (const char *path) props = gam_fs_find_fs_props (path); @@ -113,9 +155,11 @@ - return GFS_MT_KERNEL; - - return props->mon_type; -+#if defined(ENABLE_INOTIFY) || defined(ENABLE_DNOTIFY) || defined(ENABLE_KQUEUE) || defined(ENABLE_HURD_MACH_NOTIFY) ++#if (defined(ENABLE_INOTIFY) || defined(ENABLE_DNOTIFY) || defined(ENABLE_KQUEUE) || defined(ENABLE_HURD_MACH_NOTIFY)) && defined(USE_GAMIN_POLLER) + if (props) + return props->mon_type; ++#elif !defined(USE_GAMIN_POLLER) ++ return GFS_MT_KERNEL; +#endif + return GFS_MT_POLL; } |