mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
BSD portability enhancements (bug #234)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1486 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
@@ -82,7 +83,7 @@ static ast_mutex_t monlock = AST_MUTEX_INITIALIZER;
|
||||
|
||||
/* This is the thread for the monitor which checks for input on the channels
|
||||
which are not currently in use. */
|
||||
static pthread_t monitor_thread = -1;
|
||||
static pthread_t monitor_thread = (pthread_t) -1;
|
||||
|
||||
static int restart_monitor(void);
|
||||
|
||||
@@ -644,7 +645,7 @@ static void *do_monitor(void *data)
|
||||
static int restart_monitor()
|
||||
{
|
||||
/* If we're supposed to be stopped -- stay stopped */
|
||||
if (monitor_thread == -2)
|
||||
if (monitor_thread == (pthread_t) -2)
|
||||
return 0;
|
||||
if (ast_mutex_lock(&monlock)) {
|
||||
ast_log(LOG_WARNING, "Unable to lock monitor\n");
|
||||
@@ -655,7 +656,7 @@ static int restart_monitor()
|
||||
ast_log(LOG_WARNING, "Cannot kill myself\n");
|
||||
return -1;
|
||||
}
|
||||
if (monitor_thread != -1) {
|
||||
if (monitor_thread != (pthread_t) -1) {
|
||||
pthread_cancel(monitor_thread);
|
||||
/* Nudge it a little, as it's probably stuck in select */
|
||||
pthread_kill(monitor_thread, SIGURG);
|
||||
@@ -949,11 +950,11 @@ int unload_module()
|
||||
return -1;
|
||||
}
|
||||
if (!ast_mutex_lock(&monlock)) {
|
||||
if (monitor_thread > -1) {
|
||||
if (monitor_thread != (pthread_t) -1 && monitor_thread != (pthread_t) -2) {
|
||||
pthread_cancel(monitor_thread);
|
||||
pthread_join(monitor_thread, NULL);
|
||||
}
|
||||
monitor_thread = -2;
|
||||
monitor_thread = (pthread_t) -2;
|
||||
ast_mutex_unlock(&monlock);
|
||||
} else {
|
||||
ast_log(LOG_WARNING, "Unable to lock the monitor\n");
|
||||
|
Reference in New Issue
Block a user