diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-05-20 22:38:58 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-05-20 22:38:58 +0000 |
commit | d94b0a420fec3599db18c2dc495243e62620e22d (patch) | |
tree | be859f88f90a4a479d1f1256bc8a1eb2476ce835 /main | |
parent | 0a6414d92e59371794a4358a755c78dee18185ec (diff) | |
parent | 33e9e9f4b753fbf5518afcc967190b875fefb568 (diff) |
create 1.4.20 from 1.4.20-rc3
git-svn-id: http://svn.digium.com/svn/asterisk/tags/1.4.20@117333 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r-- | main/asterisk.c | 2 | ||||
-rw-r--r-- | main/autoservice.c | 14 | ||||
-rw-r--r-- | main/channel.c | 20 | ||||
-rw-r--r-- | main/utils.c | 78 |
4 files changed, 65 insertions, 49 deletions
diff --git a/main/asterisk.c b/main/asterisk.c index 37823e989..934a61731 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -2307,7 +2307,7 @@ static void ast_remotecontrol(char * data) char buf[512] = "", *curline = buf, *nextline; int not_written = 1; - if (read(ast_consock, buf, sizeof(buf) - 1) < 0) { + if (read(ast_consock, buf, sizeof(buf) - 1) <= 0) { break; } diff --git a/main/autoservice.c b/main/autoservice.c index 88ab0d4e6..fb0840f92 100644 --- a/main/autoservice.c +++ b/main/autoservice.c @@ -201,25 +201,29 @@ int ast_autoservice_start(struct ast_channel *chan) ast_channel_unlock(chan); AST_LIST_LOCK(&aslist); - if (AST_LIST_EMPTY(&aslist)) + + if (AST_LIST_EMPTY(&aslist) && asthread != AST_PTHREADT_NULL) { ast_cond_signal(&as_cond); + } + AST_LIST_INSERT_HEAD(&aslist, as, list); - AST_LIST_UNLOCK(&aslist); if (asthread == AST_PTHREADT_NULL) { /* need start the thread */ if (ast_pthread_create_background(&asthread, NULL, autoservice_run, NULL)) { ast_log(LOG_WARNING, "Unable to create autoservice thread :(\n"); /* There will only be a single member in the list at this point, the one we just added. */ - AST_LIST_LOCK(&aslist); AST_LIST_REMOVE(&aslist, as, list); - AST_LIST_UNLOCK(&aslist); free(as); + asthread = AST_PTHREADT_NULL; res = -1; - } else + } else { pthread_kill(asthread, SIGURG); + } } + AST_LIST_UNLOCK(&aslist); + return res; } diff --git a/main/channel.c b/main/channel.c index f61d365b7..d9ab77c38 100644 --- a/main/channel.c +++ b/main/channel.c @@ -4534,7 +4534,7 @@ const char *channelreloadreason2txt(enum channelreloadreason reason) /*! \brief Unlock AST channel (and print debugging output) \note You need to enable DEBUG_CHANNEL_LOCKS for this function */ -int ast_channel_unlock(struct ast_channel *chan) +int __ast_channel_unlock(struct ast_channel *chan, const char *filename, int lineno, const char *func) { int res = 0; if (option_debug > 2) @@ -4545,8 +4545,11 @@ int ast_channel_unlock(struct ast_channel *chan) ast_log(LOG_DEBUG, "::::==== Unlocking non-existing channel \n"); return 0; } - +#ifdef DEBUG_THREADS + res = __ast_pthread_mutex_unlock(filename, lineno, func, "(channel lock)", &chan->lock); +#else res = ast_mutex_unlock(&chan->lock); +#endif if (option_debug > 2) { #ifdef DEBUG_THREADS @@ -4573,14 +4576,18 @@ int ast_channel_unlock(struct ast_channel *chan) /*! \brief Lock AST channel (and print debugging output) \note You need to enable DEBUG_CHANNEL_LOCKS for this function */ -int ast_channel_lock(struct ast_channel *chan) +int __ast_channel_lock(struct ast_channel *chan, const char *filename, int lineno, const char *func) { int res; if (option_debug > 3) ast_log(LOG_DEBUG, "====:::: Locking AST channel %s\n", chan->name); +#ifdef DEBUG_THREADS + res = __ast_pthread_mutex_lock(filename, lineno, func, "(channel lock)", &chan->lock); +#else res = ast_mutex_lock(&chan->lock); +#endif if (option_debug > 3) { #ifdef DEBUG_THREADS @@ -4605,14 +4612,17 @@ int ast_channel_lock(struct ast_channel *chan) /*! \brief Lock AST channel (and print debugging output) \note You need to enable DEBUG_CHANNEL_LOCKS for this function */ -int ast_channel_trylock(struct ast_channel *chan) +int __ast_channel_trylock(struct ast_channel *chan, const char *filename, int lineno, const char *func) { int res; if (option_debug > 2) ast_log(LOG_DEBUG, "====:::: Trying to lock AST channel %s\n", chan->name); - +#ifdef DEBUG_THREADS + res = __ast_pthread_mutex_trylock(filename, lineno, func, "(channel lock)", &chan->lock); +#else res = ast_mutex_trylock(&chan->lock); +#endif if (option_debug > 2) { #ifdef DEBUG_THREADS diff --git a/main/utils.c b/main/utils.c index 2bb4fb2bb..e03cbbfae 100644 --- a/main/utils.c +++ b/main/utils.c @@ -736,46 +736,48 @@ static int handle_show_locks(int fd, int argc, char *argv[]) pthread_mutex_lock(&lock_infos_lock.mutex); AST_LIST_TRAVERSE(&lock_infos, lock_info, entry) { int i; - ast_dynamic_str_append(&str, 0, "=== Thread ID: %u (%s)\n", (int) lock_info->thread_id, - lock_info->thread_name); - pthread_mutex_lock(&lock_info->lock); - for (i = 0; str && i < lock_info->num_locks; i++) { - int j; - ast_mutex_t *lock; - - ast_dynamic_str_append(&str, 0, "=== ---> %sLock #%d (%s): %s %d %s %s %p (%d)\n", - lock_info->locks[i].pending > 0 ? "Waiting for " : - lock_info->locks[i].pending < 0 ? "Tried and failed to get " : "", i, - lock_info->locks[i].file, - locktype2str(lock_info->locks[i].type), - lock_info->locks[i].line_num, - lock_info->locks[i].func, lock_info->locks[i].lock_name, - lock_info->locks[i].lock_addr, - lock_info->locks[i].times_locked); - - if (!lock_info->locks[i].pending || lock_info->locks[i].pending == -1) - continue; - - /* We only have further details for mutexes right now */ - if (lock_info->locks[i].type != AST_MUTEX) - continue; - - lock = lock_info->locks[i].lock_addr; - - ast_reentrancy_lock(lock); - for (j = 0; str && j < lock->reentrancy; j++) { - ast_dynamic_str_append(&str, 0, "=== --- ---> Locked Here: %s line %d (%s)\n", - lock->file[j], lock->lineno[j], lock->func[j]); + if (lock_info->num_locks) { + ast_dynamic_str_append(&str, 0, "=== Thread ID: %u (%s)\n", (int) lock_info->thread_id, + lock_info->thread_name); + pthread_mutex_lock(&lock_info->lock); + for (i = 0; str && i < lock_info->num_locks; i++) { + int j; + ast_mutex_t *lock; + + ast_dynamic_str_append(&str, 0, "=== ---> %sLock #%d (%s): %s %d %s %s %p (%d)\n", + lock_info->locks[i].pending > 0 ? "Waiting for " : + lock_info->locks[i].pending < 0 ? "Tried and failed to get " : "", i, + lock_info->locks[i].file, + locktype2str(lock_info->locks[i].type), + lock_info->locks[i].line_num, + lock_info->locks[i].func, lock_info->locks[i].lock_name, + lock_info->locks[i].lock_addr, + lock_info->locks[i].times_locked); + + if (!lock_info->locks[i].pending || lock_info->locks[i].pending == -1) + continue; + + /* We only have further details for mutexes right now */ + if (lock_info->locks[i].type != AST_MUTEX) + continue; + + lock = lock_info->locks[i].lock_addr; + + ast_reentrancy_lock(lock); + for (j = 0; str && j < lock->reentrancy; j++) { + ast_dynamic_str_append(&str, 0, "=== --- ---> Locked Here: %s line %d (%s)\n", + lock->file[j], lock->lineno[j], lock->func[j]); + } + ast_reentrancy_unlock(lock); } - ast_reentrancy_unlock(lock); + pthread_mutex_unlock(&lock_info->lock); + if (!str) + break; + ast_dynamic_str_append(&str, 0, "=== -------------------------------------------------------------------\n" + "===\n"); + if (!str) + break; } - pthread_mutex_unlock(&lock_info->lock); - if (!str) - break; - ast_dynamic_str_append(&str, 0, "=== -------------------------------------------------------------------\n" - "===\n"); - if (!str) - break; } pthread_mutex_unlock(&lock_infos_lock.mutex); |