aboutsummaryrefslogtreecommitdiffstats
path: root/main/stdtime
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2010-03-16 19:34:01 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2010-03-16 19:34:01 +0000
commite4085f9c75afdfdb9084816798ea5d19ad679eed (patch)
tree999ff06c1d84d02b22accde1ebfbb2a7138836ba /main/stdtime
parent62efab186b2aa279e84ea45213bba0e099713f9b (diff)
Fix test_time on Mac OS X (and other platforms without inotify)
Reviewboard: https://reviewboard.asterisk.org/r/554/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@252846 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/stdtime')
-rw-r--r--main/stdtime/localtime.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/main/stdtime/localtime.c b/main/stdtime/localtime.c
index 925ef029b..eb9a2b1c7 100644
--- a/main/stdtime/localtime.c
+++ b/main/stdtime/localtime.c
@@ -239,12 +239,11 @@ static void *inotify_daemon(void *data)
} buf;
ssize_t res;
struct state *cur;
- struct timespec ten_seconds = { 10, 0 };
inotify_fd = inotify_init();
ast_mutex_lock(&initialization_lock);
- ast_cond_signal(&initialization);
+ ast_cond_broadcast(&initialization);
ast_mutex_unlock(&initialization_lock);
if (inotify_fd < 0) {
@@ -261,8 +260,7 @@ static void *inotify_daemon(void *data)
break;
} else if (res < 0) {
if (errno == EINTR || errno == EAGAIN) {
- /* If read fails, then wait a bit, then continue */
- nanosleep(&ten_seconds, NULL);
+ /* If read fails, try again */
continue;
}
/* Sanity check -- this should never happen, either */
@@ -278,6 +276,7 @@ static void *inotify_daemon(void *data)
}
}
AST_LIST_TRAVERSE_SAFE_END
+ ast_cond_broadcast(&initialization);
AST_LIST_UNLOCK(&zonelist);
}
close(inotify_fd);
@@ -326,7 +325,7 @@ static void *notify_daemon(void *data)
struct timespec sixty_seconds = { 60, 0 };
ast_mutex_lock(&initialization_lock);
- ast_cond_signal(&initialization);
+ ast_cond_broadcast(&initialization);
ast_mutex_unlock(&initialization_lock);
for (;/*ever*/;) {
@@ -347,12 +346,14 @@ static void *notify_daemon(void *data)
stat(name, &st);
lstat(name, &lst);
if (st.st_mtime > cur->mtime[0] || lst.st_mtime > cur->mtime[1]) {
+ ast_log(LOG_NOTICE, "Removing cached TZ entry '%s' because underlying file changed.\n", name);
AST_LIST_REMOVE_CURRENT(list);
ast_free(cur);
continue;
}
}
AST_LIST_TRAVERSE_SAFE_END
+ ast_cond_broadcast(&initialization);
AST_LIST_UNLOCK(&zonelist);
}
inotify_thread = AST_PTHREADT_NULL;
@@ -381,6 +382,16 @@ static void add_notify(struct state *sp, const char *path)
}
#endif
+void ast_localtime_wakeup_monitor(void)
+{
+ if (inotify_thread != AST_PTHREADT_NULL) {
+ AST_LIST_LOCK(&zonelist);
+ pthread_kill(inotify_thread, SIGURG);
+ ast_cond_wait(&initialization, &(&zonelist)->lock);
+ AST_LIST_UNLOCK(&zonelist);
+ }
+}
+
/*! \note
** Section 4.12.3 of X3.159-1989 requires that
** Except for the strftime function, these functions [asctime,