aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xasterisk.c8
-rwxr-xr-xautoservice.c8
-rwxr-xr-xchannels/chan_h323.c10
-rwxr-xr-xchannels/chan_iax.c8
-rwxr-xr-xchannels/chan_iax2.c8
-rwxr-xr-xchannels/chan_mgcp.c8
-rwxr-xr-xchannels/chan_modem.c10
-rwxr-xr-xchannels/chan_phone.c10
-rwxr-xr-xchannels/chan_sip.c8
-rwxr-xr-xchannels/chan_skinny.c8
-rwxr-xr-xchannels/chan_vofr.c6
-rwxr-xr-xchannels/chan_zap.c8
12 files changed, 52 insertions, 48 deletions
diff --git a/asterisk.c b/asterisk.c
index a267df996..7adb02790 100755
--- a/asterisk.c
+++ b/asterisk.c
@@ -34,7 +34,7 @@
#include <signal.h>
#include <sched.h>
#include <asterisk/io.h>
-#include <pthread.h>
+#include <asterisk/lock.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/select.h>
@@ -109,7 +109,7 @@ char ast_config_AST_RUN_DIR[AST_CONFIG_MAX_PATH];
static char *_argv[256];
static int shuttingdown = 0;
static int restartnow = 0;
-static pthread_t consolethread = (pthread_t) -1;
+static pthread_t consolethread = AST_PTHREADT_NULL;
int ast_register_atexit(void (*func)(void))
{
@@ -544,7 +544,7 @@ static void quit_handler(int num, int nice, int safeshutdown, int restart)
restartnow = 1;
/* If there is a consolethread running send it a SIGHUP
so it can execvp, otherwise we can do it ourselves */
- if (consolethread != (pthread_t) -1) {
+ if (consolethread != AST_PTHREADT_NULL) {
pthread_kill(consolethread, SIGHUP);
/* Give the signal handler some time to complete */
sleep(2);
@@ -591,7 +591,7 @@ static void console_verboser(const char *s, int pos, int replace, int complete)
fflush(stdout);
if (complete)
/* Wake up a select()ing console */
- if (option_console && consolethread != (pthread_t) -1)
+ if (option_console && consolethread != AST_PTHREADT_NULL)
pthread_kill(consolethread, SIGURG);
}
diff --git a/autoservice.c b/autoservice.c
index 7e5699b97..3f24db8c1 100755
--- a/autoservice.c
+++ b/autoservice.c
@@ -44,7 +44,7 @@ struct asent {
};
static struct asent *aslist = NULL;
-static pthread_t asthread = (pthread_t) -1;
+static pthread_t asthread = AST_PTHREADT_NULL;
static void *autoservice_run(void *ign)
{
@@ -80,7 +80,7 @@ static void *autoservice_run(void *ign)
ast_frfree(f);
}
}
- asthread = (pthread_t) -1;
+ asthread = AST_PTHREADT_NULL;
return NULL;
}
@@ -90,7 +90,7 @@ int ast_autoservice_start(struct ast_channel *chan)
struct asent *as;
int needstart;
ast_mutex_lock(&autolock);
- needstart = (asthread == (pthread_t) -1) ? 1 : 0 /* aslist ? 0 : 1 */;
+ needstart = (asthread == AST_PTHREADT_NULL) ? 1 : 0 /* aslist ? 0 : 1 */;
as = aslist;
while(as) {
if (as->chan == chan)
@@ -142,7 +142,7 @@ int ast_autoservice_stop(struct ast_channel *chan)
if (!chan->_softhangup)
res = 0;
}
- if (asthread != (pthread_t) -1)
+ if (asthread != AST_PTHREADT_NULL)
pthread_kill(asthread, SIGURG);
ast_mutex_unlock(&autolock);
/* Wait for it to un-block */
diff --git a/channels/chan_h323.c b/channels/chan_h323.c
index 5b99ed80e..70761d883 100755
--- a/channels/chan_h323.c
+++ b/channels/chan_h323.c
@@ -147,7 +147,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 = 0;
+static pthread_t monitor_thread = AST_PTHREADT_NULL;
static int restart_monitor(void);
@@ -1260,7 +1260,7 @@ restartsearch:
static int restart_monitor(void)
{
/* If we're supposed to be stopped -- stay stopped */
- if (monitor_thread == -2)
+ if (monitor_thread == AST_PTHREADT_STOP)
return 0;
if (ast_mutex_lock(&monlock)) {
ast_log(LOG_WARNING, "Unable to lock monitor\n");
@@ -1271,7 +1271,7 @@ static int restart_monitor(void)
ast_log(LOG_WARNING, "Cannot kill myself\n");
return -1;
}
- if (monitor_thread && (monitor_thread != -2)) {
+ if (monitor_thread && (monitor_thread != AST_PTHREADT_STOP)) {
/* Wake up the thread */
pthread_kill(monitor_thread, SIGURG);
} else {
@@ -1840,12 +1840,12 @@ int unload_module()
}
if (!ast_mutex_lock(&monlock)) {
- if (monitor_thread && (monitor_thread != -2)) {
+ if (monitor_thread && (monitor_thread != AST_PTHREADT_STOP)) {
pthread_cancel(monitor_thread);
pthread_kill(monitor_thread, SIGURG);
pthread_join(monitor_thread, NULL);
}
- monitor_thread = (pthread_t) -2;
+ monitor_thread = AST_PTHREADT_STOP;
ast_mutex_unlock(&monlock);
} else {
ast_log(LOG_WARNING, "Unable to lock the monitor\n");
diff --git a/channels/chan_iax.c b/channels/chan_iax.c
index ce0897066..a88e855f6 100755
--- a/channels/chan_iax.c
+++ b/channels/chan_iax.c
@@ -149,7 +149,7 @@ static int iaxdebug = 0;
static char accountcode[20];
static int amaflags = 0;
-static pthread_t netthreadid;
+static pthread_t netthreadid = AST_PTHREADT_NULL;
#define IAX_STATE_STARTED (1 << 0)
#define IAX_STATE_AUTHENTICATED (1 << 1)
@@ -5345,8 +5345,10 @@ static int __unload_module(void)
{
int x;
/* Cancel the network thread, close the net socket */
- pthread_cancel(netthreadid);
- pthread_join(netthreadid, NULL);
+ if (netthreadid != AST_PTHREADT_NULL) {
+ pthread_cancel(netthreadid);
+ pthread_join(netthreadid, NULL);
+ }
close(netsocket);
for (x=0;x<AST_IAX_MAX_CALLS;x++)
if (iaxs[x])
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 04f80738f..c9da32ea9 100755
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -172,7 +172,7 @@ static char accountcode[20];
static int amaflags = 0;
static int notransfer = 0;
-static pthread_t netthreadid;
+static pthread_t netthreadid = AST_PTHREADT_NULL;
#define IAX_STATE_STARTED (1 << 0)
#define IAX_STATE_AUTHENTICATED (1 << 1)
@@ -6521,8 +6521,10 @@ static int __unload_module(void)
{
int x;
/* Cancel the network thread, close the net socket */
- pthread_cancel(netthreadid);
- pthread_join(netthreadid, NULL);
+ if (netthreadid != AST_PTHREADT_NULL) {
+ pthread_cancel(netthreadid);
+ pthread_join(netthreadid, NULL);
+ }
close(netsocket);
for (x=0;x<IAX_MAX_CALLS;x++)
if (iaxs[x])
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index 6774ac743..1554b3365 100755
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -167,7 +167,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 = 0;
+static pthread_t monitor_thread = AST_PTHREADT_NULL;
static int restart_monitor(void);
@@ -2558,7 +2558,7 @@ static int restart_monitor(void)
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
/* If we're supposed to be stopped -- stay stopped */
- if (monitor_thread == (pthread_t) -2)
+ if (monitor_thread == AST_PTHREADT_STOP)
return 0;
if (ast_mutex_lock(&monlock)) {
ast_log(LOG_WARNING, "Unable to lock monitor\n");
@@ -3052,12 +3052,12 @@ int unload_module()
return -1;
}
if (!ast_mutex_lock(&monlock)) {
- if (monitor_thread && (monitor_thread != -2)) {
+ if (monitor_thread && (monitor_thread != AST_PTHREADT_STOP)) {
pthread_cancel(monitor_thread);
pthread_kill(monitor_thread, SIGURG);
pthread_join(monitor_thread, NULL);
}
- monitor_thread = -2;
+ monitor_thread = AST_PTHREADT_STOP;
ast_mutex_unlock(&monlock);
} else {
ast_log(LOG_WARNING, "Unable to lock the monitor\n");
diff --git a/channels/chan_modem.c b/channels/chan_modem.c
index 09451decd..728aa361a 100755
--- a/channels/chan_modem.c
+++ b/channels/chan_modem.c
@@ -83,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 = (pthread_t) -1;
+static pthread_t monitor_thread = AST_PTHREADT_NULL;
static int restart_monitor(void);
@@ -646,7 +646,7 @@ static void *do_monitor(void *data)
static int restart_monitor()
{
/* If we're supposed to be stopped -- stay stopped */
- if (monitor_thread == (pthread_t) -2)
+ if (monitor_thread == AST_PTHREADT_STOP)
return 0;
if (ast_mutex_lock(&monlock)) {
ast_log(LOG_WARNING, "Unable to lock monitor\n");
@@ -657,7 +657,7 @@ static int restart_monitor()
ast_log(LOG_WARNING, "Cannot kill myself\n");
return -1;
}
- if (monitor_thread != (pthread_t) -1) {
+ if (monitor_thread != AST_PTHREADT_NULL) {
pthread_cancel(monitor_thread);
/* Nudge it a little, as it's probably stuck in select */
pthread_kill(monitor_thread, SIGURG);
@@ -861,11 +861,11 @@ static int __unload_module(void)
return -1;
}
if (!ast_mutex_lock(&monlock)) {
- if (monitor_thread != (pthread_t) -1 && monitor_thread != (pthread_t) -2) {
+ if (monitor_thread != AST_PTHREADT_NULL && monitor_thread != AST_PTHREADT_STOP) {
pthread_cancel(monitor_thread);
pthread_join(monitor_thread, NULL);
}
- monitor_thread = (pthread_t) -2;
+ monitor_thread = AST_PTHREADT_STOP;
ast_mutex_unlock(&monlock);
} else {
ast_log(LOG_WARNING, "Unable to lock the monitor\n");
diff --git a/channels/chan_phone.c b/channels/chan_phone.c
index 775734842..5ebe02192 100755
--- a/channels/chan_phone.c
+++ b/channels/chan_phone.c
@@ -67,7 +67,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 = AST_PTHREADT_NULL;
static int restart_monitor(void);
@@ -910,7 +910,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 == AST_PTHREADT_STOP)
return 0;
if (ast_mutex_lock(&monlock)) {
ast_log(LOG_WARNING, "Unable to lock monitor\n");
@@ -921,7 +921,7 @@ static int restart_monitor()
ast_log(LOG_WARNING, "Cannot kill myself\n");
return -1;
}
- if (monitor_thread != -1) {
+ if (monitor_thread != AST_PTHREADT_NULL) {
pthread_cancel(monitor_thread);
#if 0
pthread_join(monitor_thread, NULL);
@@ -1071,11 +1071,11 @@ static int __unload_module(void)
return -1;
}
if (!ast_mutex_lock(&monlock)) {
- if (monitor_thread > -1) {
+ if (monitor_thread > AST_PTHREADT_NULL) {
pthread_cancel(monitor_thread);
pthread_join(monitor_thread, NULL);
}
- monitor_thread = -2;
+ monitor_thread = AST_PTHREADT_STOP;
ast_mutex_unlock(&monlock);
} else {
ast_log(LOG_WARNING, "Unable to lock the monitor\n");
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 2784277e1..bcf9ff9a2 100755
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -134,7 +134,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 = 0;
+static pthread_t monitor_thread = AST_PTHREADT_NULL;
static int restart_monitor(void);
@@ -5818,7 +5818,7 @@ restartsearch:
static int restart_monitor(void)
{
/* If we're supposed to be stopped -- stay stopped */
- if (monitor_thread == (pthread_t) -2)
+ if (monitor_thread == AST_PTHREADT_STOP)
return 0;
if (ast_mutex_lock(&monlock)) {
ast_log(LOG_WARNING, "Unable to lock monitor\n");
@@ -6865,12 +6865,12 @@ int unload_module()
return -1;
}
if (!ast_mutex_lock(&monlock)) {
- if (monitor_thread && ((int)monitor_thread != -2)) {
+ if (monitor_thread && (monitor_thread != AST_PTHREADT_STOP)) {
pthread_cancel(monitor_thread);
pthread_kill(monitor_thread, SIGURG);
pthread_join(monitor_thread, NULL);
}
- monitor_thread = (pthread_t) -2;
+ monitor_thread = AST_PTHREADT_STOP;
ast_mutex_unlock(&monlock);
} else {
ast_log(LOG_WARNING, "Unable to lock the monitor\n");
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index b44c49423..0a01bdc57 100755
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -599,7 +599,7 @@ static ast_mutex_t devicelock = 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 = 0;
+static pthread_t monitor_thread = AST_PTHREADT_NULL;
/* Wait up to 16 seconds for first digit */
static int firstdigittimeout = 16000;
@@ -2415,7 +2415,7 @@ static int restart_monitor(void)
{
/* If we're supposed to be stopped -- stay stopped */
- if (monitor_thread == (pthread_t)-2)
+ if (monitor_thread == AST_PTHREADT_STOP)
return 0;
if (ast_mutex_lock(&monlock)) {
ast_log(LOG_WARNING, "Unable to lock monitor\n");
@@ -2718,12 +2718,12 @@ int unload_module()
return -1;
}
if (!ast_mutex_lock(&monlock)) {
- if (monitor_thread && (monitor_thread != -2)) {
+ if (monitor_thread && (monitor_thread != AST_PTHREADT_STOP)) {
pthread_cancel(monitor_thread);
pthread_kill(monitor_thread, SIGURG);
pthread_join(monitor_thread, NULL);
}
- monitor_thread = -2;
+ monitor_thread = AST_PTHREADT_STOP;
ast_mutex_unlock(&monlock);
} else {
ast_log(LOG_WARNING, "Unable to lock the monitor\n");
diff --git a/channels/chan_vofr.c b/channels/chan_vofr.c
index 289e101a9..3d677bd3d 100755
--- a/channels/chan_vofr.c
+++ b/channels/chan_vofr.c
@@ -64,7 +64,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 = 0;
+static pthread_t monitor_thread = AST_PTHREADT_NULL;
static int restart_monitor(void);
@@ -997,7 +997,7 @@ static void *do_monitor(void *data)
static int restart_monitor(void)
{
/* If we're supposed to be stopped -- stay stopped */
- if (monitor_thread == -2)
+ if (monitor_thread == AST_PTHREADT_STOP)
return 0;
if (ast_mutex_lock(&monlock)) {
ast_log(LOG_WARNING, "Unable to lock monitor\n");
@@ -1161,7 +1161,7 @@ static int __unload_module(void)
pthread_kill(monitor_thread, SIGURG);
pthread_join(monitor_thread, NULL);
}
- monitor_thread = -2;
+ monitor_thread = AST_PTHREADT_STOP;
ast_mutex_unlock(&monlock);
} else {
ast_log(LOG_WARNING, "Unable to lock the monitor\n");
diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index dd089f5fb..930a870fc 100755
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -228,7 +228,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 = 0;
+static pthread_t monitor_thread = AST_PTHREADT_NULL;
static int restart_monitor(void);
@@ -5171,7 +5171,7 @@ static int restart_monitor(void)
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
/* If we're supposed to be stopped -- stay stopped */
- if (monitor_thread == -2)
+ if (monitor_thread == AST_PTHREADT_STOP)
return 0;
if (ast_mutex_lock(&monlock)) {
ast_log(LOG_WARNING, "Unable to lock monitor\n");
@@ -7313,12 +7313,12 @@ static int __unload_module(void)
return -1;
}
if (!ast_mutex_lock(&monlock)) {
- if (monitor_thread && (monitor_thread != -2)) {
+ if (monitor_thread && (monitor_thread != AST_PTHREADT_STOP)) {
pthread_cancel(monitor_thread);
pthread_kill(monitor_thread, SIGURG);
pthread_join(monitor_thread, NULL);
}
- monitor_thread = -2;
+ monitor_thread = AST_PTHREADT_STOP;
ast_mutex_unlock(&monlock);
} else {
ast_log(LOG_WARNING, "Unable to lock the monitor\n");