Remove portions that weren't meant to be committed for the OS X compat fix

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@251263 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Tilghman Lesher 2010-03-08 05:15:01 +00:00
parent e58fc610ae
commit da6ba8e60e
4 changed files with 7028 additions and 28024 deletions

34909
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -317,7 +317,6 @@ AST_EXT_LIB_SETUP([INOTIFY], [inotify support], [inotify])
AST_EXT_LIB_SETUP([IODBC], [iODBC], [iodbc])
AST_EXT_LIB_SETUP([ISDNNET], [ISDN4Linux Library], [isdnnet])
AST_EXT_LIB_SETUP([JACK], [Jack Audio Connection Kit], [jack])
AST_EXT_LIB_SETUP([KQUEUE], [kqueue support], [kqueue])
AST_EXT_LIB_SETUP([LDAP], [OpenLDAP], [ldap])
AST_EXT_LIB_SETUP([LIBXML2], [LibXML2], [libxml2])
AST_EXT_LIB_SETUP([LTDL], [libtool], [ltdl])
@ -1406,9 +1405,6 @@ AST_EXT_LIB_CHECK([INOTIFY], [c], [inotify_init], [sys/inotify.h])
AST_EXT_LIB_CHECK([JACK], [jack], [jack_activate], [jack/jack.h])
# BSD (and OS X) equivalent of inotify
AST_EXT_LIB_CHECK([KQUEUE], [c], [kqueue], [sys/event.h])
# Needed by unixodbc
AST_EXT_LIB_CHECK([LTDL], [ltdl], [lt_dlinit], [ltdl.h], [])

View File

@ -425,12 +425,6 @@
/* Define to the version of the Jack Audio Connection Kit library. */
#undef HAVE_JACK_VERSION
/* Define to 1 if you have the kqueue support library. */
#undef HAVE_KQUEUE
/* Define to the version of the kqueue support library. */
#undef HAVE_KQUEUE_VERSION
/* Define to 1 if you have the OpenLDAP library. */
#undef HAVE_LDAP

View File

@ -53,13 +53,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include <float.h>
#ifdef HAVE_INOTIFY
#include <sys/inotify.h>
#elif HAVE_KQUEUE
#include <sys/types.h>
#include <sys/time.h>
#include <sys/event.h>
#include <dirent.h>
#include <sys/stat.h>
#include <fcntl.h>
#endif
#include "private.h"
@ -159,9 +152,6 @@ struct state {
struct lsinfo lsis[TZ_MAX_LEAPS];
#ifdef HAVE_INOTIFY
int wd[2];
#elif defined(HAVE_KQUEUE)
int fd;
DIR *dir;
#else
time_t mtime[2];
#endif
@ -328,129 +318,6 @@ static void add_notify(struct state *sp, const char *path)
);
}
}
#elif HAVE_KQUEUE
static int queue_fd = -1;
static void *kqueue_daemon(void *data)
{
struct kevent kev;
struct state *sp;
struct timespec no_wait = { 0, 1 };
if ((queue_fd = kqueue()) < 0) {
ast_log(LOG_ERROR, "Unable to initialize kqueue(): %s\n", strerror(errno));
inotify_thread = AST_PTHREADT_NULL;
ast_cond_signal(&initialization);
return NULL;
}
for (;/*ever*/;) {
if (kevent(queue_fd, NULL, 0, &kev, 1, NULL) < 0) {
continue;
}
sp = kev.udata;
/*!\note
* If the file event fired, then the file was removed, so we'll need
* to reparse the entry. The directory event is a bit more
* interesting. Unfortunately, the queue doesn't contain information
* about the file that changed (only the directory itself), so unless
* we kept a record of the directory state before, it's not really
* possible to know what change occurred. But if we act paranoid and
* just purge the associated file, then it will get reparsed, and
* everything works fine. It may be more work, but it's a vast
* improvement over the alternative implementation, which is to stat
* the file repeatedly in what is essentially a busy loop. */
AST_LIST_REMOVE(&zonelist, sp, list);
#ifndef EV_RECEIPT
#define EV_RECEIPT 0
#endif
/* If the directory event fired, remove the file event */
EV_SET(&kev, sp->fd, EVFILT_VNODE, EV_DELETE | EV_RECEIPT, 0, 0, NULL);
kevent(queue_fd, &kev, 1, NULL, 0, &no_wait);
close(sp->fd);
if (sp->dir) {
/* If the file event fired, remove the directory event */
EV_SET(&kev, dirfd(sp->dir), EVFILT_VNODE, EV_DELETE | EV_RECEIPT, 0, 0, NULL);
kevent(queue_fd, &kev, 1, NULL, 0, &no_wait);
closedir(sp->dir);
}
free(sp);
}
}
static void add_notify(struct state *sp, const char *path)
{
struct kevent kev;
struct timespec no_wait = { 0, 1 };
char watchdir[PATH_MAX + 1];
if (inotify_thread == AST_PTHREADT_NULL) {
ast_cond_init(&initialization, NULL);
ast_mutex_init(&initialization_lock);
ast_mutex_lock(&initialization_lock);
if (!(ast_pthread_create_background(&inotify_thread, NULL, kqueue_daemon, NULL))) {
/* Give the thread a chance to initialize */
ast_cond_wait(&initialization, &initialization_lock);
}
ast_mutex_unlock(&initialization_lock);
}
if (queue_fd < 0) {
/* Error already sent */
return;
}
if (readlink(path, watchdir, sizeof(watchdir) - 1) != -1) {
/* Special -- watch the directory for changes, because we cannot directly watch a symlink */
char *slash;
DIR *dir;
if ((slash = strrchr(watchdir, '/'))) {
*slash = '\0';
}
if (!(sp->dir = opendir(watchdir))) {
ast_log(LOG_ERROR, "Unable to watch directory with symlink '%s': %s\n", path, strerror(errno));
goto watch_file;
}
/*!\note
* You may be wondering about whether there is a potential conflict
* with the kqueue interface, because we might be watching the same
* directory for multiple zones. The answer is no, because kqueue
* looks at the descriptor to know if there's a duplicate. Since we
* (may) have opened the directory multiple times, each represents a
* different event, so no replacement of an existing event will occur.
* Likewise, there's no potential leak of a descriptor.
*/
EV_SET(&kev, dirfd(sp->dir), EVFILT_VNODE, EV_ADD | EV_RECEIPT | EV_ONESHOT,
NOTE_WRITE | NOTE_EXTEND | NOTE_REVOKE, 0, sp);
if (kevent(queue_fd, &kev, 1, NULL, 0, &no_wait) < 0 && errno != 0) {
ast_log(LOG_ERROR, "Unable to watch '%s': %s\n", watchdir, strerror(errno));
closedir(dir);
goto watch_file;
}
}
watch_file:
if ((sp->fd = open(path, O_RDONLY)) < 0) {
ast_log(LOG_ERROR, "Unable to watch '%s' for changes: %s\n", path, strerror(errno));
return;
}
EV_SET(&kev, sp->fd, EVFILT_VNODE, EV_ADD | EV_RECEIPT | EV_ONESHOT, NOTE_DELETE, 0, sp);
if (kevent(queue_fd, &kev, 1, NULL, 0, &no_wait) < 0 && errno != 0) {
/* According to the API docs, we may get -1 return value, due to the
* NULL space for a returned event, but errno should be 0 unless
* there's a real error. Otherwise, kevent will return 0 to indicate
* that the time limit expired. */
ast_log(LOG_ERROR, "Unable to watch '%s': %s\n", path, strerror(errno));
close(sp->fd);
}
}
#else
static void *notify_daemon(void *data)
{