mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 12:36:58 +00:00
Various fixes for OS X
This patch addresses compilation errors on OS X. It's been a while, so there's quite a few things. * Fixed __attribute__ decls in route.h to be portable. * Fixed htonll and ntohll to work when they are defined as macros. * Replaced sem_t usage with our ast_sem wrapper. * Added ast_sem_timedwait to our ast_sem wrapper. * Fixed some GCC 4.9 warnings using sig*set() functions. * Fixed some format strings for portability. * Fixed compilation issues with res_timing_kqueue (although tests still fail on OS X). * Fixed menuconfig /sbin/launchd detection, which disables res_timing_kqueue on OS X). ASTERISK-24539 #close Reported by: George Joseph ASTERISK-24544 #close Reported by: George Joseph Review: https://reviewboard.asterisk.org/r/4327/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@431092 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -98,7 +98,7 @@ void sip_route_dump(const struct sip_route *route);
|
|||||||
* \retval NULL on failure
|
* \retval NULL on failure
|
||||||
*/
|
*/
|
||||||
struct ast_str *sip_route_list(const struct sip_route *route, int formatcli, int skip)
|
struct ast_str *sip_route_list(const struct sip_route *route, int formatcli, int skip)
|
||||||
__attribute_malloc__ __attribute_warn_unused_result__;
|
__attribute__((__malloc__)) __attribute__((__warn_unused_result__));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Check if the route is strict
|
* \brief Check if the route is strict
|
||||||
|
27
configure.ac
27
configure.ac
@@ -660,7 +660,25 @@ AC_FUNC_STRNLEN
|
|||||||
AC_FUNC_STRTOD
|
AC_FUNC_STRTOD
|
||||||
AC_FUNC_UTIME_NULL
|
AC_FUNC_UTIME_NULL
|
||||||
AC_FUNC_VPRINTF
|
AC_FUNC_VPRINTF
|
||||||
AC_CHECK_FUNCS([asprintf atexit closefrom dup2 eaccess endpwent euidaccess ffsll ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday glob htonll ioperm inet_ntoa isascii memchr memmove memset mkdir mkdtemp munmap ntohll newlocale ppoll putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtod strtol strtold strtoq unsetenv utime vasprintf getpeereid sysctl swapctl])
|
AC_CHECK_FUNCS([asprintf atexit closefrom dup2 eaccess endpwent euidaccess ffsll ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday glob ioperm inet_ntoa isascii memchr memmove memset mkdir mkdtemp munmap newlocale ppoll putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtod strtol strtold strtoq unsetenv utime vasprintf getpeereid sysctl swapctl])
|
||||||
|
|
||||||
|
AC_MSG_CHECKING(for htonll)
|
||||||
|
AC_LINK_IFELSE(
|
||||||
|
[AC_LANG_PROGRAM([#include <arpa/inet.h>],
|
||||||
|
[return htonll(0);])],
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
AC_DEFINE(HAVE_HTONLL, 1, [Define to 1 if arpa/inet.h includes a htonll definition.]),
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
)
|
||||||
|
|
||||||
|
AC_MSG_CHECKING(for ntohll)
|
||||||
|
AC_LINK_IFELSE(
|
||||||
|
[AC_LANG_PROGRAM([#include <arpa/inet.h>],
|
||||||
|
[return ntohll(0);])],
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
AC_DEFINE(HAVE_NTOHLL, 1, [Define to 1 if arpa/inet.h includes a ntohll definition.]),
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
)
|
||||||
|
|
||||||
# NOTE: we use AC_CHECK_LIB to get -lm into the arguments for later checks,
|
# NOTE: we use AC_CHECK_LIB to get -lm into the arguments for later checks,
|
||||||
# so that AC_CHECK_FUNCS can detect functions in that library.
|
# so that AC_CHECK_FUNCS can detect functions in that library.
|
||||||
@@ -2432,10 +2450,9 @@ AST_EXT_LIB_CHECK([X11], [X11], [XOpenDisplay], [X11/Xlib.h],, [-I/usr/X11R6/inc
|
|||||||
PBX_LAUNCHD=0
|
PBX_LAUNCHD=0
|
||||||
if test "${cross_compiling}" = "no";
|
if test "${cross_compiling}" = "no";
|
||||||
then
|
then
|
||||||
AC_CHECK_FILE(/sbin/launchd, AC_DEFINE([HAVE_SBIN_LAUNCHD], 1, [Define to 1 if your system has /sbin/launchd.]))
|
AC_CHECK_FILE(/sbin/launchd,
|
||||||
if test "${HAVE_SBIN_LAUNCHD}" = 1; then
|
[PBX_LAUNCHD=1]
|
||||||
PBX_LAUNCHD=1
|
AC_DEFINE([HAVE_SBIN_LAUNCHD], 1, [Define to 1 if your system has /sbin/launchd.]))
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
AC_SUBST(PBX_LAUNCHD)
|
AC_SUBST(PBX_LAUNCHD)
|
||||||
|
|
||||||
|
@@ -41,7 +41,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
#include "asterisk/app.h"
|
#include "asterisk/app.h"
|
||||||
#ifdef TEST_FRAMEWORK
|
#ifdef TEST_FRAMEWORK
|
||||||
#include "asterisk/test.h"
|
#include "asterisk/test.h"
|
||||||
#include <semaphore.h>
|
#include "asterisk/sem.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*** DOCUMENTATION
|
/*** DOCUMENTATION
|
||||||
@@ -664,7 +664,7 @@ AST_TEST_DEFINE(test_invalid_parse_data)
|
|||||||
struct test_cb_data {
|
struct test_cb_data {
|
||||||
struct ast_presence_state_message *presence_state;
|
struct ast_presence_state_message *presence_state;
|
||||||
/* That's right. I'm using a semaphore */
|
/* That's right. I'm using a semaphore */
|
||||||
sem_t sem;
|
struct ast_sem sem;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct test_cb_data *test_cb_data_alloc(void)
|
static struct test_cb_data *test_cb_data_alloc(void)
|
||||||
@@ -675,7 +675,7 @@ static struct test_cb_data *test_cb_data_alloc(void)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sem_init(&cb_data->sem, 0, 0)) {
|
if (ast_sem_init(&cb_data->sem, 0, 0)) {
|
||||||
ast_free(cb_data);
|
ast_free(cb_data);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -686,7 +686,7 @@ static struct test_cb_data *test_cb_data_alloc(void)
|
|||||||
static void test_cb_data_destroy(struct test_cb_data *cb_data)
|
static void test_cb_data_destroy(struct test_cb_data *cb_data)
|
||||||
{
|
{
|
||||||
ao2_cleanup(cb_data->presence_state);
|
ao2_cleanup(cb_data->presence_state);
|
||||||
sem_destroy(&cb_data->sem);
|
ast_sem_destroy(&cb_data->sem);
|
||||||
ast_free(cb_data);
|
ast_free(cb_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -699,7 +699,7 @@ static void test_cb(void *userdata, struct stasis_subscription *sub, struct stas
|
|||||||
cb_data->presence_state = stasis_message_data(msg);
|
cb_data->presence_state = stasis_message_data(msg);
|
||||||
ao2_ref(cb_data->presence_state, +1);
|
ao2_ref(cb_data->presence_state, +1);
|
||||||
|
|
||||||
sem_post(&cb_data->sem);
|
ast_sem_post(&cb_data->sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum ast_test_result_state presence_change_common(struct ast_test *test,
|
static enum ast_test_result_state presence_change_common(struct ast_test *test,
|
||||||
@@ -727,7 +727,7 @@ static enum ast_test_result_state presence_change_common(struct ast_test *test,
|
|||||||
return AST_TEST_FAIL;
|
return AST_TEST_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
sem_wait(&cb_data->sem);
|
ast_sem_wait(&cb_data->sem);
|
||||||
|
|
||||||
ast_copy_string(out_state, ast_presence_state2str(cb_data->presence_state->state), out_state_size);
|
ast_copy_string(out_state, ast_presence_state2str(cb_data->presence_state->state), out_state_size);
|
||||||
ast_copy_string(out_subtype, cb_data->presence_state->subtype, out_subtype_size);
|
ast_copy_string(out_subtype, cb_data->presence_state->subtype, out_subtype_size);
|
||||||
|
@@ -324,7 +324,7 @@
|
|||||||
/* Define to 1 if you have the Hoard Memory Allocator library. */
|
/* Define to 1 if you have the Hoard Memory Allocator library. */
|
||||||
#undef HAVE_HOARD
|
#undef HAVE_HOARD
|
||||||
|
|
||||||
/* Define to 1 if you have the `htonll' function. */
|
/* Define to 1 if arpa/inet.h includes a htonll definition. */
|
||||||
#undef HAVE_HTONLL
|
#undef HAVE_HTONLL
|
||||||
|
|
||||||
/* Define to 1 if you have the iCal library. */
|
/* Define to 1 if you have the iCal library. */
|
||||||
@@ -524,7 +524,7 @@
|
|||||||
/* Define to 1 if you have the newt library. */
|
/* Define to 1 if you have the newt library. */
|
||||||
#undef HAVE_NEWT
|
#undef HAVE_NEWT
|
||||||
|
|
||||||
/* Define to 1 if you have the `ntohll' function. */
|
/* Define to 1 if arpa/inet.h includes a ntohll definition. */
|
||||||
#undef HAVE_NTOHLL
|
#undef HAVE_NTOHLL
|
||||||
|
|
||||||
/* Define to 1 if your C library can safely print NULL to string formats. */
|
/* Define to 1 if your C library can safely print NULL to string formats. */
|
||||||
@@ -1299,6 +1299,11 @@
|
|||||||
/* Define to 1 if running on Darwin. */
|
/* Define to 1 if running on Darwin. */
|
||||||
#undef _DARWIN_UNLIMITED_SELECT
|
#undef _DARWIN_UNLIMITED_SELECT
|
||||||
|
|
||||||
|
/* Enable large inode numbers on Mac OS X 10.5. */
|
||||||
|
#ifndef _DARWIN_USE_64_BIT_INODE
|
||||||
|
# define _DARWIN_USE_64_BIT_INODE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||||
#undef _FILE_OFFSET_BITS
|
#undef _FILE_OFFSET_BITS
|
||||||
|
|
||||||
|
@@ -59,6 +59,11 @@ static force_inline int ast_sem_wait(struct ast_sem *sem)
|
|||||||
return sem_wait(&sem->real_sem);
|
return sem_wait(&sem->real_sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static force_inline int ast_sem_timedwait(struct ast_sem *sem, const struct timespec *abs_timeout)
|
||||||
|
{
|
||||||
|
return sem_timedwait(&sem->real_sem, abs_timeout);
|
||||||
|
}
|
||||||
|
|
||||||
static force_inline int ast_sem_getvalue(struct ast_sem *sem, int *sval)
|
static force_inline int ast_sem_getvalue(struct ast_sem *sem, int *sval)
|
||||||
{
|
{
|
||||||
return sem_getvalue(&sem->real_sem, sval);
|
return sem_getvalue(&sem->real_sem, sval);
|
||||||
@@ -136,6 +141,20 @@ int ast_sem_post(struct ast_sem *sem);
|
|||||||
*/
|
*/
|
||||||
int ast_sem_wait(struct ast_sem *sem);
|
int ast_sem_wait(struct ast_sem *sem);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Decrements the semaphore, waiting until abs_timeout.
|
||||||
|
*
|
||||||
|
* If the semaphore's current value is zero, this function blocks until another
|
||||||
|
* thread posts (ast_sem_post()) to the semaphore (or is interrupted by a signal
|
||||||
|
* handler, which sets errno to EINTR).
|
||||||
|
*
|
||||||
|
* \param sem Semaphore to decrement.
|
||||||
|
*
|
||||||
|
* \return 0 on success.
|
||||||
|
* \return -1 on error, errno set to indicate error.
|
||||||
|
*/
|
||||||
|
int ast_sem_timedwait(struct ast_sem *sem, const struct timespec *abs_timeout);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Gets the current value of the semaphore.
|
* \brief Gets the current value of the semaphore.
|
||||||
*
|
*
|
||||||
|
@@ -2911,7 +2911,9 @@ int ast_safe_fork(int stop_reaper)
|
|||||||
ast_replace_sigchld();
|
ast_replace_sigchld();
|
||||||
}
|
}
|
||||||
|
|
||||||
sigfillset(&signal_set);
|
/* GCC 4.9 gives a bogus "right-hand operand of comma expression has
|
||||||
|
* no effect" warning */
|
||||||
|
(void) sigfillset(&signal_set);
|
||||||
pthread_sigmask(SIG_BLOCK, &signal_set, &old_set);
|
pthread_sigmask(SIG_BLOCK, &signal_set, &old_set);
|
||||||
|
|
||||||
pid = fork();
|
pid = fork();
|
||||||
|
@@ -4366,12 +4366,14 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
ast_makesocket();
|
ast_makesocket();
|
||||||
sigemptyset(&sigs);
|
/* GCC 4.9 gives a bogus "right-hand operand of comma expression has
|
||||||
sigaddset(&sigs, SIGHUP);
|
* no effect" warning */
|
||||||
sigaddset(&sigs, SIGTERM);
|
(void) sigemptyset(&sigs);
|
||||||
sigaddset(&sigs, SIGINT);
|
(void) sigaddset(&sigs, SIGHUP);
|
||||||
sigaddset(&sigs, SIGPIPE);
|
(void) sigaddset(&sigs, SIGTERM);
|
||||||
sigaddset(&sigs, SIGWINCH);
|
(void) sigaddset(&sigs, SIGINT);
|
||||||
|
(void) sigaddset(&sigs, SIGPIPE);
|
||||||
|
(void) sigaddset(&sigs, SIGWINCH);
|
||||||
pthread_sigmask(SIG_BLOCK, &sigs, NULL);
|
pthread_sigmask(SIG_BLOCK, &sigs, NULL);
|
||||||
sigaction(SIGURG, &urg_handler, NULL);
|
sigaction(SIGURG, &urg_handler, NULL);
|
||||||
signal(SIGINT, __quit_handler);
|
signal(SIGINT, __quit_handler);
|
||||||
|
@@ -35,7 +35,6 @@
|
|||||||
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||||
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <semaphore.h>
|
|
||||||
|
|
||||||
#include "asterisk/heap.h"
|
#include "asterisk/heap.h"
|
||||||
#include "asterisk/astobj2.h"
|
#include "asterisk/astobj2.h"
|
||||||
@@ -56,6 +55,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
#include "asterisk/parking.h"
|
#include "asterisk/parking.h"
|
||||||
#include "asterisk/causes.h"
|
#include "asterisk/causes.h"
|
||||||
#include "asterisk/test.h"
|
#include "asterisk/test.h"
|
||||||
|
#include "asterisk/sem.h"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Used to queue an action frame onto a bridge channel and write an action frame into a bridge.
|
* \brief Used to queue an action frame onto a bridge channel and write an action frame into a bridge.
|
||||||
@@ -101,7 +101,7 @@ struct bridge_sync {
|
|||||||
/*! Unique ID of this synchronization object. Corresponds with ID in synchronous frame payload */
|
/*! Unique ID of this synchronization object. Corresponds with ID in synchronous frame payload */
|
||||||
unsigned int id;
|
unsigned int id;
|
||||||
/*! Semaphore used for synchronization */
|
/*! Semaphore used for synchronization */
|
||||||
sem_t sem;
|
struct ast_sem sem;
|
||||||
/*! Pointer to next entry in the list */
|
/*! Pointer to next entry in the list */
|
||||||
AST_LIST_ENTRY(bridge_sync) list;
|
AST_LIST_ENTRY(bridge_sync) list;
|
||||||
};
|
};
|
||||||
@@ -124,7 +124,7 @@ static void bridge_sync_init(struct bridge_sync *sync_struct, unsigned int id)
|
|||||||
{
|
{
|
||||||
memset(sync_struct, 0, sizeof(*sync_struct));
|
memset(sync_struct, 0, sizeof(*sync_struct));
|
||||||
sync_struct->id = id;
|
sync_struct->id = id;
|
||||||
sem_init(&sync_struct->sem, 0, 0);
|
ast_sem_init(&sync_struct->sem, 0, 0);
|
||||||
|
|
||||||
AST_RWLIST_WRLOCK(&sync_structs);
|
AST_RWLIST_WRLOCK(&sync_structs);
|
||||||
AST_RWLIST_INSERT_TAIL(&sync_structs, sync_struct, list);
|
AST_RWLIST_INSERT_TAIL(&sync_structs, sync_struct, list);
|
||||||
@@ -157,7 +157,7 @@ static void bridge_sync_cleanup(struct bridge_sync *sync_struct)
|
|||||||
AST_LIST_TRAVERSE_SAFE_END;
|
AST_LIST_TRAVERSE_SAFE_END;
|
||||||
AST_RWLIST_UNLOCK(&sync_structs);
|
AST_RWLIST_UNLOCK(&sync_structs);
|
||||||
|
|
||||||
sem_destroy(&sync_struct->sem);
|
ast_sem_destroy(&sync_struct->sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -189,7 +189,7 @@ static void bridge_sync_wait(struct bridge_sync *sync_struct)
|
|||||||
.tv_nsec = timeout_val.tv_usec * 1000,
|
.tv_nsec = timeout_val.tv_usec * 1000,
|
||||||
};
|
};
|
||||||
|
|
||||||
sem_timedwait(&sync_struct->sem, &timeout_spec);
|
ast_sem_timedwait(&sync_struct->sem, &timeout_spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -204,7 +204,7 @@ static void bridge_sync_wait(struct bridge_sync *sync_struct)
|
|||||||
*/
|
*/
|
||||||
static void bridge_sync_signal(struct bridge_sync *sync_struct)
|
static void bridge_sync_signal(struct bridge_sync *sync_struct)
|
||||||
{
|
{
|
||||||
sem_post(&sync_struct->sem);
|
ast_sem_post(&sync_struct->sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ast_bridge_channel_lock_bridge(struct ast_bridge_channel *bridge_channel)
|
void ast_bridge_channel_lock_bridge(struct ast_bridge_channel *bridge_channel)
|
||||||
|
@@ -1948,7 +1948,7 @@ static struct ast_json *rtcp_report_to_json(struct stasis_message *msg,
|
|||||||
char sec[32];
|
char sec[32];
|
||||||
char usec[32];
|
char usec[32];
|
||||||
snprintf(sec, sizeof(sec), "%lu", payload->report->sender_information.ntp_timestamp.tv_sec);
|
snprintf(sec, sizeof(sec), "%lu", payload->report->sender_information.ntp_timestamp.tv_sec);
|
||||||
snprintf(usec, sizeof(usec), "%lu", payload->report->sender_information.ntp_timestamp.tv_usec);
|
snprintf(usec, sizeof(usec), "%lu", (unsigned long)payload->report->sender_information.ntp_timestamp.tv_usec);
|
||||||
json_rtcp_sender_info = ast_json_pack("{s: s, s: s, s: i, s: i, s: i}",
|
json_rtcp_sender_info = ast_json_pack("{s: s, s: s, s: i, s: i, s: i}",
|
||||||
"ntp_timestamp_sec", sec,
|
"ntp_timestamp_sec", sec,
|
||||||
"ntp_timestamp_usec", usec,
|
"ntp_timestamp_usec", usec,
|
||||||
|
33
main/sem.c
33
main/sem.c
@@ -85,6 +85,7 @@ int ast_sem_post(struct ast_sem *sem)
|
|||||||
|
|
||||||
int ast_sem_wait(struct ast_sem *sem)
|
int ast_sem_wait(struct ast_sem *sem)
|
||||||
{
|
{
|
||||||
|
int res;
|
||||||
SCOPED_MUTEX(lock, &sem->mutex);
|
SCOPED_MUTEX(lock, &sem->mutex);
|
||||||
|
|
||||||
ast_assert(sem->count >= 0);
|
ast_assert(sem->count >= 0);
|
||||||
@@ -92,7 +93,37 @@ int ast_sem_wait(struct ast_sem *sem)
|
|||||||
/* Wait for a non-zero count */
|
/* Wait for a non-zero count */
|
||||||
++sem->waiters;
|
++sem->waiters;
|
||||||
while (sem->count == 0) {
|
while (sem->count == 0) {
|
||||||
ast_cond_wait(&sem->cond, &sem->mutex);
|
res = ast_cond_wait(&sem->cond, &sem->mutex);
|
||||||
|
/* Give up on error */
|
||||||
|
if (res != 0) {
|
||||||
|
--sem->waiters;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--sem->waiters;
|
||||||
|
|
||||||
|
/* Take it! */
|
||||||
|
--sem->count;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ast_sem_timedwait(struct ast_sem *sem, const struct timespec *abs_timeout)
|
||||||
|
{
|
||||||
|
int res;
|
||||||
|
SCOPED_MUTEX(lock, &sem->mutex);
|
||||||
|
|
||||||
|
ast_assert(sem->count >= 0);
|
||||||
|
|
||||||
|
/* Wait for a non-zero count */
|
||||||
|
++sem->waiters;
|
||||||
|
while (sem->count == 0) {
|
||||||
|
res = ast_cond_timedwait(&sem->cond, &sem->mutex, abs_timeout);
|
||||||
|
/* Give up on error */
|
||||||
|
if (res != 0) {
|
||||||
|
--sem->waiters;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
--sem->waiters;
|
--sem->waiters;
|
||||||
|
|
||||||
|
@@ -91,12 +91,12 @@ static void *kqueue_timer_open(void)
|
|||||||
|
|
||||||
if (!(timer = ao2_alloc(sizeof(*timer), timer_destroy))) {
|
if (!(timer = ao2_alloc(sizeof(*timer), timer_destroy))) {
|
||||||
ast_log(LOG_ERROR, "Could not allocate memory for kqueue_timer structure\n");
|
ast_log(LOG_ERROR, "Could not allocate memory for kqueue_timer structure\n");
|
||||||
return -1;
|
return NULL;
|
||||||
}
|
}
|
||||||
if ((timer->handle = kqueue()) < 0) {
|
if ((timer->handle = kqueue()) < 0) {
|
||||||
ast_log(LOG_ERROR, "Failed to create kqueue timer: %s\n", strerror(errno));
|
ast_log(LOG_ERROR, "Failed to create kqueue timer: %s\n", strerror(errno));
|
||||||
ao2_ref(timer, -1);
|
ao2_ref(timer, -1);
|
||||||
return -1;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return timer;
|
return timer;
|
||||||
@@ -201,6 +201,8 @@ static enum ast_timer_event kqueue_timer_get_event(void *data)
|
|||||||
if (timer->unacked == 0) {
|
if (timer->unacked == 0) {
|
||||||
if (kevent(timer->handle, NULL, 0, &kev, 1, &sixty_seconds) > 0) {
|
if (kevent(timer->handle, NULL, 0, &kev, 1, &sixty_seconds) > 0) {
|
||||||
timer->unacked += kev.data;
|
timer->unacked += kev.data;
|
||||||
|
} else {
|
||||||
|
perror("kevent");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,7 +252,7 @@ AST_TEST_DEFINE(test_kqueue_timing)
|
|||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
pfd.fd = ast_timer_fd(kt);
|
pfd.fd = kqueue_timer_fd(kt);
|
||||||
if (kqueue_timer_set_rate(kt, 1000)) {
|
if (kqueue_timer_set_rate(kt, 1000)) {
|
||||||
ast_test_status_update(test, "Cannot set timer rate to 1000/s\n");
|
ast_test_status_update(test, "Cannot set timer rate to 1000/s\n");
|
||||||
res = AST_TEST_FAIL;
|
res = AST_TEST_FAIL;
|
||||||
@@ -271,13 +273,12 @@ AST_TEST_DEFINE(test_kqueue_timing)
|
|||||||
res = AST_TEST_FAIL;
|
res = AST_TEST_FAIL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
if (kt->unacked == 0) {
|
if (kt->unacked == 0) {
|
||||||
ast_test_status_update(test, "Unacked events is 0, but there should be at least 1.\n");
|
ast_test_status_update(test, "Unacked events is 0, but there should be at least 1.\n");
|
||||||
res = AST_TEST_FAIL;
|
res = AST_TEST_FAIL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
kqueue_timer_enable_continuous(kt);
|
kqueue_timer_enable_continuous(kt);
|
||||||
start = ast_tvnow();
|
start = ast_tvnow();
|
||||||
for (i = 0; i < 100; i++) {
|
for (i = 0; i < 100; i++) {
|
||||||
|
Reference in New Issue
Block a user