remove some chekc sof the result of ast_mutex_lock (issue #7119, Mithraen)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@26531 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.4
Russell Bryant 20 years ago
parent 698cead822
commit 19ca8dc7c1

@ -12153,10 +12153,7 @@ static int restart_monitor(void)
/* If we're supposed to be stopped -- stay stopped */ /* If we're supposed to be stopped -- stay stopped */
if (monitor_thread == AST_PTHREADT_STOP) if (monitor_thread == AST_PTHREADT_STOP)
return 0; return 0;
if (ast_mutex_lock(&monlock)) { ast_mutex_lock(&monlock);
ast_log(LOG_WARNING, "Unable to lock monitor\n");
return -1;
}
if (monitor_thread == pthread_self()) { if (monitor_thread == pthread_self()) {
ast_mutex_unlock(&monlock); ast_mutex_unlock(&monlock);
ast_log(LOG_WARNING, "Cannot kill myself\n"); ast_log(LOG_WARNING, "Cannot kill myself\n");
@ -13994,51 +13991,39 @@ static int unload_module(void *mod)
ast_manager_unregister("SIPpeers"); ast_manager_unregister("SIPpeers");
ast_manager_unregister("SIPshowpeer"); ast_manager_unregister("SIPshowpeer");
if (!ast_mutex_lock(&iflock)) { ast_mutex_lock(&iflock);
/* Hangup all interfaces if they have an owner */ /* Hangup all interfaces if they have an owner */
for (p = iflist; p ; p = p->next) { for (p = iflist; p ; p = p->next) {
if (p->owner) if (p->owner)
ast_softhangup(p->owner, AST_SOFTHANGUP_APPUNLOAD); ast_softhangup(p->owner, AST_SOFTHANGUP_APPUNLOAD);
}
ast_mutex_unlock(&iflock);
} else {
ast_log(LOG_WARNING, "Unable to lock the interface list\n");
return -1;
} }
ast_mutex_unlock(&iflock);
if (!ast_mutex_lock(&monlock)) { ast_mutex_lock(&monlock);
if (monitor_thread && (monitor_thread != AST_PTHREADT_STOP)) { if (monitor_thread && (monitor_thread != AST_PTHREADT_STOP)) {
pthread_cancel(monitor_thread); pthread_cancel(monitor_thread);
pthread_kill(monitor_thread, SIGURG); pthread_kill(monitor_thread, SIGURG);
pthread_join(monitor_thread, NULL); pthread_join(monitor_thread, NULL);
}
monitor_thread = AST_PTHREADT_STOP;
ast_mutex_unlock(&monlock);
} else {
ast_log(LOG_WARNING, "Unable to lock the monitor\n");
return -1;
} }
monitor_thread = AST_PTHREADT_STOP;
ast_mutex_unlock(&monlock);
if (!ast_mutex_lock(&iflock)) { ast_mutex_lock(&iflock);
/* Destroy all the interfaces and free their memory */ /* Destroy all the interfaces and free their memory */
p = iflist; p = iflist;
while (p) { while (p) {
pl = p; pl = p;
p = p->next; p = p->next;
/* Free associated memory */ /* Free associated memory */
ast_mutex_destroy(&pl->lock); ast_mutex_destroy(&pl->lock);
if (pl->chanvars) { if (pl->chanvars) {
ast_variables_destroy(pl->chanvars); ast_variables_destroy(pl->chanvars);
pl->chanvars = NULL; pl->chanvars = NULL;
} }
free(pl); free(pl);
} }
iflist = NULL; iflist = NULL;
ast_mutex_unlock(&iflock); ast_mutex_unlock(&iflock);
} else {
ast_log(LOG_WARNING, "Unable to lock the interface list\n");
return -1;
}
/* Free memory for local network address mask */ /* Free memory for local network address mask */
ast_free_ha(localaddr); ast_free_ha(localaddr);

@ -6539,10 +6539,7 @@ static void *do_monitor(void *data)
#endif #endif
for(;;) { for(;;) {
/* Lock the interface list */ /* Lock the interface list */
if (ast_mutex_lock(&iflock)) { ast_mutex_lock(&iflock);
ast_log(LOG_ERROR, "Unable to grab interface lock\n");
return NULL;
}
if (!pfds || (lastalloc != ifcount)) { if (!pfds || (lastalloc != ifcount)) {
if (pfds) if (pfds)
free(pfds); free(pfds);
@ -6588,10 +6585,7 @@ static void *do_monitor(void *data)
} }
/* Alright, lock the interface list again, and let's look and see what has /* Alright, lock the interface list again, and let's look and see what has
happened */ happened */
if (ast_mutex_lock(&iflock)) { ast_mutex_lock(&iflock);
ast_log(LOG_WARNING, "Unable to lock the interface list\n");
continue;
}
found = 0; found = 0;
spoint = 0; spoint = 0;
lastpass = thispass; lastpass = thispass;
@ -6731,10 +6725,7 @@ static int restart_monitor(void)
/* If we're supposed to be stopped -- stay stopped */ /* If we're supposed to be stopped -- stay stopped */
if (monitor_thread == AST_PTHREADT_STOP) if (monitor_thread == AST_PTHREADT_STOP)
return 0; return 0;
if (ast_mutex_lock(&monlock)) { ast_mutex_lock(&monlock);
ast_log(LOG_WARNING, "Unable to lock monitor\n");
return -1;
}
if (monitor_thread == pthread_self()) { if (monitor_thread == pthread_self()) {
ast_mutex_unlock(&monlock); ast_mutex_unlock(&monlock);
ast_log(LOG_WARNING, "Cannot kill myself\n"); ast_log(LOG_WARNING, "Cannot kill myself\n");
@ -7609,10 +7600,7 @@ static struct ast_channel *zt_request(const char *type, int format, void *data,
} }
} }
/* Search for an unowned channel */ /* Search for an unowned channel */
if (ast_mutex_lock(lock)) { ast_mutex_lock(lock);
ast_log(LOG_ERROR, "Unable to lock interface list???\n");
return NULL;
}
exit = p; exit = p;
while(p && !tmp) { while(p && !tmp) {
if (roundrobin) if (roundrobin)
@ -10103,57 +10091,45 @@ static int __unload_module(void)
ast_manager_unregister( "ZapDNDon" ); ast_manager_unregister( "ZapDNDon" );
ast_manager_unregister("ZapShowChannels"); ast_manager_unregister("ZapShowChannels");
ast_channel_unregister(&zap_tech); ast_channel_unregister(&zap_tech);
if (!ast_mutex_lock(&iflock)) { ast_mutex_lock(&iflock);
/* Hangup all interfaces if they have an owner */ /* Hangup all interfaces if they have an owner */
p = iflist; p = iflist;
while(p) { while(p) {
if (p->owner) if (p->owner)
ast_softhangup(p->owner, AST_SOFTHANGUP_APPUNLOAD); ast_softhangup(p->owner, AST_SOFTHANGUP_APPUNLOAD);
p = p->next; p = p->next;
}
ast_mutex_unlock(&iflock);
} else {
ast_log(LOG_WARNING, "Unable to lock the monitor\n");
return -1;
} }
if (!ast_mutex_lock(&monlock)) { ast_mutex_unlock(&iflock);
if (monitor_thread && (monitor_thread != AST_PTHREADT_STOP) && (monitor_thread != AST_PTHREADT_NULL)) { ast_mutex_lock(&monlock);
pthread_cancel(monitor_thread); if (monitor_thread && (monitor_thread != AST_PTHREADT_STOP) && (monitor_thread != AST_PTHREADT_NULL)) {
pthread_kill(monitor_thread, SIGURG); pthread_cancel(monitor_thread);
pthread_join(monitor_thread, NULL); pthread_kill(monitor_thread, SIGURG);
} pthread_join(monitor_thread, NULL);
monitor_thread = AST_PTHREADT_STOP;
ast_mutex_unlock(&monlock);
} else {
ast_log(LOG_WARNING, "Unable to lock the monitor\n");
return -1;
} }
monitor_thread = AST_PTHREADT_STOP;
ast_mutex_unlock(&monlock);
if (!ast_mutex_lock(&iflock)) { ast_mutex_lock(&iflock);
/* Destroy all the interfaces and free their memory */ /* Destroy all the interfaces and free their memory */
p = iflist; p = iflist;
while(p) { while(p) {
/* Free any callerid */ /* Free any callerid */
if (p->cidspill) if (p->cidspill)
free(p->cidspill); free(p->cidspill);
/* Close the zapata thingy */ /* Close the zapata thingy */
if (p->subs[SUB_REAL].zfd > -1) if (p->subs[SUB_REAL].zfd > -1)
zt_close(p->subs[SUB_REAL].zfd); zt_close(p->subs[SUB_REAL].zfd);
pl = p; pl = p;
p = p->next; p = p->next;
x++; x++;
/* Free associated memory */ /* Free associated memory */
if(pl) if(pl)
destroy_zt_pvt(&pl); destroy_zt_pvt(&pl);
ast_verbose(VERBOSE_PREFIX_3 "Unregistered channel %d\n", x); ast_verbose(VERBOSE_PREFIX_3 "Unregistered channel %d\n", x);
} }
iflist = NULL; iflist = NULL;
ifcount = 0; ifcount = 0;
ast_mutex_unlock(&iflock); ast_mutex_unlock(&iflock);
} else {
ast_log(LOG_WARNING, "Unable to lock the monitor\n");
return -1;
}
#ifdef HAVE_LIBPRI #ifdef HAVE_LIBPRI
for(i=0;i<NUM_SPANS;i++) { for(i=0;i<NUM_SPANS;i++) {
if (pris[i].master && (pris[i].master != AST_PTHREADT_NULL)) if (pris[i].master && (pris[i].master != AST_PTHREADT_NULL))
@ -10204,11 +10180,8 @@ static int setup_zap(int reload)
} }
if (ast_mutex_lock(&iflock)) { /* It's a little silly to lock it, but we mind as well just to be sure */
/* It's a little silly to lock it, but we mind as well just to be sure */ ast_mutex_lock(&iflock);
ast_log(LOG_ERROR, "Unable to lock interface list???\n");
return -1;
}
#ifdef HAVE_LIBPRI #ifdef HAVE_LIBPRI
if (!reload) { if (!reload) {
/* Process trunkgroups first */ /* Process trunkgroups first */

Loading…
Cancel
Save