Update to 0.6.21, and add a patch from avahi SVN to fix a segfault when

no domains are configured in /etc/resolv.conf.
This commit is contained in:
Joe Marcus Clarke 2007-08-26 04:56:04 +00:00
parent baa9289b9b
commit b9c3d0bb34
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=198316
6 changed files with 28 additions and 182 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.20
PORTVERSION= 0.6.21
PORTREVISION?= 0
CATEGORIES?= net dns
MASTER_SITES= http://www.avahi.org/download/

View File

@ -1,3 +1,3 @@
MD5 (avahi-0.6.20.tar.gz) = 6acdff79afa2631f765f3bbbc3e25a74
SHA256 (avahi-0.6.20.tar.gz) = 89ae5fd08018679b80cee201e1c1350d86db73bdcf6718aabb4bd3ea86f93ec9
SIZE (avahi-0.6.20.tar.gz) = 974209
MD5 (avahi-0.6.21.tar.gz) = 9cc68f79c50c9dd9e419990c3c9b05b9
SHA256 (avahi-0.6.21.tar.gz) = d817c35f43011861476eab02eea14edd123b2bc58b4408d9d9b69b0c39252561
SIZE (avahi-0.6.21.tar.gz) = 976841

View File

@ -0,0 +1,14 @@
--- avahi-common/dbus-watch-glue.c.orig 2007-08-26 00:46:45.000000000 -0400
+++ avahi-common/dbus-watch-glue.c 2007-08-26 00:47:12.000000000 -0400
@@ -134,7 +134,11 @@ static dbus_bool_t update_watch(const Av
if (!(avahi_watch = poll_api->watch_new(
poll_api,
+#if (DBUS_VERSION_MAJOR == 1 && DBUS_VERSION_MINOR == 1 && DBUS_VERSION_MICRO >= 1) || (DBUS_VERSION_MAJOR == 1 && DBUS_VERSION_MAJOR > 1) || (DBUS_VERSION_MAJOR > 1)
dbus_watch_get_unix_fd(dbus_watch),
+#else
+ dbus_watch_get_fd(dbus_watch),
+#endif
translate_dbus_to_avahi(dbus_watch_get_flags(dbus_watch)),
watch_callback,
dbus_watch)))

View File

@ -1,10 +0,0 @@
--- avahi-core/fdutil.c.orig Sat Jun 23 02:09:02 2007
+++ avahi-core/fdutil.c Sat Jun 23 02:09:37 2007
@@ -23,6 +23,7 @@
#include <config.h>
#endif
+#include <sys/select.h>
#include <unistd.h>
#include <fcntl.h>
#include <assert.h>

View File

@ -1,161 +1,14 @@
--- avahi-daemon/main.c.orig Wed May 9 09:09:19 2007
+++ avahi-daemon/main.c Sat Jun 9 13:56:02 2007
@@ -50,6 +50,12 @@
#endif
#endif
--- avahi-daemon/main.c.orig 2007-08-26 00:48:40.000000000 -0400
+++ avahi-daemon/main.c 2007-08-26 00:49:04.000000000 -0400
@@ -317,6 +317,11 @@ static void update_browse_domains(void)
int n;
char **p;
+#ifdef HAVE_KQUEUE
+#include <sys/types.h>
+#include <sys/event.h>
+#include <unistd.h>
+#endif
+
#include <libdaemon/dfork.h>
#include <libdaemon/dsignal.h>
#include <libdaemon/dlog.h>
@@ -691,6 +697,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_chroot;
+#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
@@ -698,6 +751,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);
@@ -746,6 +803,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;
@@ -801,6 +883,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);
@@ -876,6 +962,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;
+ }
+ if (!resolv_conf_search_domains) {
+ avahi_server_set_browse_domains(avahi_server, NULL);
+ return;
+ }
+#endif
+
load_resolv_conf();
#ifdef ENABLE_CHROOT
static_service_load(config.use_chroot);
@@ -944,6 +1043,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
l = avahi_string_list_copy(config.server_config.browse_domains);
if (simple_poll_api) {
for (p = resolv_conf_search_domains, n = 0; *p && n < BROWSE_DOMAINS_MAX; p++, n++) {

View File

@ -1,11 +0,0 @@
--- 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>