aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
Diffstat (limited to 'channels')
-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
10 files changed, 44 insertions, 40 deletions
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");