1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-02 06:03:50 +00:00

Update to 0.6.18, and add kqueue support for automatically processing service

changes.
This commit is contained in:
Joe Marcus Clarke 2007-04-21 00:42:31 +00:00
parent 83fb33d581
commit f42c93b7a9
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=190517
7 changed files with 201 additions and 16 deletions

View File

@ -6,7 +6,7 @@
# $MCom: ports/net/avahi/Makefile,v 1.19 2006/10/12 16:44:41 marcus Exp $
PORTNAME= avahi
PORTVERSION= 0.6.17
PORTVERSION= 0.6.18
PORTREVISION?= 0
CATEGORIES?= net dns
MASTER_SITES= http://www.avahi.org/download/
@ -39,7 +39,7 @@ CONFIGURE_ARGS?=--with-distro=freebsd \
--enable-compat-howl \
--disable-autoipd \
--mandir=${PREFIX}/man
CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include" \
CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include -DHAVE_KQUEUE" \
LDFLAGS="-L${LOCALBASE}/lib" \
PTHREAD_CFLAGS="${PTHREAD_CFLAGS}" \
PTHREAD_LIBS="${PTHREAD_LIBS}"
@ -53,7 +53,7 @@ MAN1= avahi-browse-domains.1 avahi-browse.1 avahi-publish-address.1 \
MAN5= avahi-daemon.conf.5 avahi.service.5 avahi.hosts.5
MAN8= avahi-daemon.8 avahi-dnsconfd.8 avahi-dnsconfd.action.8
OPTIONS= GTK2 "Build a GTK+ 2 browser utility" off \
OPTIONS= GTK2 "Build a GTK+ 2 browser utility and other tools" off \
LIBDNS "Enable mDNSResponder compatibility" off
.endif

View File

@ -1,3 +1,3 @@
MD5 (avahi-0.6.17.tar.gz) = 29ebb2181958d5721ee5fc45f035a77c
SHA256 (avahi-0.6.17.tar.gz) = 2cb6a15a9fff56c0d24f3a95b7f67c52436a88716e640c7f7afd48c9a5cbd740
SIZE (avahi-0.6.17.tar.gz) = 927202
MD5 (avahi-0.6.18.tar.gz) = ab3d67cb743d16cf38ad69b4b76ca989
SHA256 (avahi-0.6.18.tar.gz) = 11a0270cdf1220943ce8f3a79b705c6de6e57d94a058ee2efa9592037b4a4274
SIZE (avahi-0.6.18.tar.gz) = 961748

View File

@ -1,10 +0,0 @@
--- avahi-core/dns.c.orig Thu Oct 12 12:43:19 2006
+++ avahi-core/dns.c Thu Oct 12 12:43:31 2006
@@ -28,6 +28,7 @@
#include <stdio.h>
#include <assert.h>
+#include <sys/types.h>
#include <netinet/in.h>
#include <avahi-common/defs.h>

View File

@ -0,0 +1,168 @@
--- avahi-daemon/main.c.orig Sat Apr 14 20:34:33 2007
+++ avahi-daemon/main.c Fri Apr 20 20:06:05 2007
@@ -42,11 +42,19 @@
#include <sys/resource.h>
#include <sys/socket.h>
+#ifdef HAVE_INOTIFY
#ifdef HAVE_SYS_INOTIFY_H
#include <sys/inotify.h>
#else
#include "inotify-nosys.h"
#endif
+#endif
+
+#ifdef HAVE_KQUEUE
+#include <sys/types.h>
+#include <sys/event.h>
+#include <unistd.h>
+#endif
#include <libdaemon/dfork.h>
#include <libdaemon/dsignal.h>
@@ -681,6 +689,53 @@ static void add_inotify_watches(void) {
#endif
+#ifdef HAVE_KQUEUE
+
+#define NUM_WATCHES 2
+
+static int kq = -1;
+static int kfds[NUM_WATCHES];
+static int num_kfds = 0;
+
+static void add_kqueue_watch(const char *dir);
+
+static void add_kqueue_watches(void) {
+ int c = 0;
+
+#ifdef ENABLE_CHROOT
+ c = config.use_chrott;
+#endif
+
+ add_kqueue_watch(c ? "/" : AVAHI_CONFIG_DIR);
+ add_kqueue_watch(c ? "/services" : AVAHI_SERVICE_DIR);
+}
+
+static void add_kqueue_watch(const char *dir) {
+ int fd;
+ struct kevent ev;
+
+ if (kq < 0)
+ return;
+
+ if (num_kfds >= NUM_WATCHES)
+ return;
+
+ fd = open(dir, O_RDONLY);
+ if (fd < 0)
+ return;
+ EV_SET(&ev, fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR,
+ NOTE_DELETE | NOTE_EXTEND | NOTE_WRITE | NOTE_RENAME,
+ 0, 0);
+ if (kevent(kq, &ev, 1, NULL, 0, NULL) == -1) {
+ close(fd);
+ return;
+ }
+
+ kfds[num_kfds++] = fd;
+}
+
+#endif
+
static void reload_config(void) {
#ifdef HAVE_INOTIFY
@@ -688,6 +743,10 @@ static void reload_config(void) {
add_inotify_watches();
#endif
+#ifdef HAVE_KQUEUE
+ add_kqueue_watches();
+#endif
+
#ifdef ENABLE_CHROOT
static_service_load(config.use_chroot);
static_hosts_load(config.use_chroot);
@@ -736,6 +795,31 @@ static void inotify_callback(AvahiWatch
#endif
+#ifdef HAVE_KQUEUE
+
+static void kqueue_callback(AvahiWatch *watch, int fd, AVAHI_GCC_UNUSED AvahiWatchEvent event, AVAHI_GCC_UNUSED void *userdata) {
+ struct kevent ev;
+ struct timespec nullts = { 0, 0 };
+ int res;
+
+ assert(fd == kq);
+ assert(watch);
+
+ res = kevent(kq, NULL, 0, &ev, 1, &nullts);
+
+ if (res > 0) {
+ /* Sleep for a half-second to avoid potential races
+ * during install/uninstall. */
+ usleep(500000);
+ avahi_log_info("Files changed, reloading.");
+ reload_config();
+ } else {
+ avahi_log_error("Failed to read kqueue event: %s", avahi_strerror(errno));
+ }
+}
+
+#endif
+
static void signal_callback(AvahiWatch *watch, AVAHI_GCC_UNUSED int fd, AVAHI_GCC_UNUSED AvahiWatchEvent event, AVAHI_GCC_UNUSED void *userdata) {
int sig;
const AvahiPoll *poll_api;
@@ -791,6 +875,10 @@ static int run_server(DaemonConfig *c) {
#ifdef HAVE_INOTIFY
AvahiWatch *inotify_watch = NULL;
#endif
+#ifdef HAVE_KQUEUE
+ int i;
+ AvahiWatch *kqueue_watch = NULL;
+#endif
assert(c);
@@ -866,6 +954,19 @@ static int run_server(DaemonConfig *c) {
}
#endif
+#ifdef HAVE_KQUEUE
+ if ((kq = kqueue()) < 0)
+ avahi_log_warn( "Failed to initialize kqueue: %s", strerror(errno));
+ else {
+ add_kqueue_watches();
+
+ if (!(kqueue_watch = poll_api->watch_new(poll_api, kq, AVAHI_WATCH_IN, kqueue_callback, NULL))) {
+ avahi_log_error( "Failed to create kqueue watcher");
+ goto finish;
+ }
+ }
+#endif
+
load_resolv_conf();
#ifdef ENABLE_CHROOT
static_service_load(config.use_chroot);
@@ -934,6 +1035,17 @@ finish:
poll_api->watch_free(inotify_watch);
if (inotify_fd >= 0)
close(inotify_fd);
+#endif
+
+#ifdef HAVE_KQUEUE
+ if (kqueue_watch)
+ poll_api->watch_free(kqueue_watch);
+ if (kq >= 0)
+ close(kq);
+ for (i = 0; i < num_kfds; i++) {
+ if (kfds[i] >= 0)
+ close(kfds[i]);
+ }
#endif
if (simple_poll_api) {

View File

@ -0,0 +1,11 @@
--- avahi-ui/avahi-ui.c.orig Fri Apr 20 20:07:43 2007
+++ avahi-ui/avahi-ui.c Fri Apr 20 20:09:03 2007
@@ -23,6 +23,8 @@
#include <config.h>
#endif
+#include <sys/types.h>
+#include <sys/socket.h>
#include <string.h>
#include <stdarg.h>
#include <net/if.h>

View File

@ -8,6 +8,8 @@ bin/avahi-resolve
bin/avahi-resolve-address
bin/avahi-resolve-host-name
bin/avahi-set-host-name
%%GTK%%bin/zssh
%%GTK%%bin/zvnc
etc/avahi/avahi-daemon.conf
etc/avahi/avahi-dnsconfd.action
etc/avahi/hosts
@ -61,6 +63,7 @@ include/avahi-core/publish.h
include/avahi-core/rr.h
include/avahi-glib/glib-malloc.h
include/avahi-glib/glib-watch.h
%%GTK%%include/avahi-ui/avahi-ui.h
lib/libavahi-client.a
lib/libavahi-client.la
lib/libavahi-client.so
@ -77,6 +80,10 @@ lib/libavahi-glib.a
lib/libavahi-glib.la
lib/libavahi-glib.so
lib/libavahi-glib.so.1
%%GTK%%lib/libavahi-ui.a
%%GTK%%lib/libavahi-ui.la
%%GTK%%lib/libavahi-ui.so
%%GTK%%lib/libavahi-ui.so.0
%%LIBDNS%%lib/libdns_sd.a
%%LIBDNS%%lib/libdns_sd.la
%%LIBDNS%%lib/libdns_sd.so
@ -90,8 +97,11 @@ libdata/pkgconfig/avahi-compat-howl.pc
%%LIBDNS%%libdata/pkgconfig/avahi-compat-libdns_sd.pc
libdata/pkgconfig/avahi-core.pc
libdata/pkgconfig/avahi-glib.pc
%%GTK%%libdata/pkgconfig/avahi-ui.pc
sbin/avahi-daemon
sbin/avahi-dnsconfd
%%GTK%%share/applications/zssh.desktop
%%GTK%%share/applications/zvnc.desktop
%%DATADIR%%/avahi-service.dtd
%%GTK%%%%DATADIR%%/interfaces/avahi-discover.glade
%%DATADIR%%/introspection/AddressResolver.introspect
@ -107,6 +117,8 @@ sbin/avahi-dnsconfd
@dirrm %%DATADIR%%/introspection
%%GTK%%@dirrm %%DATADIR%%/interfaces
@dirrm %%DATADIR%%
@dirrmtry share/applications
%%GTK%%@dirrm include/avahi-ui
@dirrm include/avahi-glib
@dirrm include/avahi-core
%%LIBDNS%%@dirrm include/avahi-compat-libdns_sd

View File

@ -44,6 +44,10 @@ CONFIGURE_ARGS= --enable-python \
MAN1= avahi-bookmarks.1 avahi-discover.1
pre-build:
@cd ${BUILD_WRKSRC} && ${SETENV} ${MAKE_ENV} ${GMAKE} ${MAKE_FLAGS} \
Makefile ${MAKE_ARGS} clean
post-build:
@cd ${WRKSRC}/service-type-database && ${SETENV} ${MAKE_ENV} ${GMAKE} \
${MAKE_FLAGS} Makefile ${MAKE_ARGS} ${ALL_TARGET}