mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-30 10:33:13 +00:00
Fix locking issues
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4148 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -3183,22 +3183,50 @@ static int dundi_query(struct dundi_transaction *trans)
|
|||||||
static int discover_transactions(struct dundi_request *dr)
|
static int discover_transactions(struct dundi_request *dr)
|
||||||
{
|
{
|
||||||
struct dundi_transaction *trans;
|
struct dundi_transaction *trans;
|
||||||
|
ast_mutex_lock(&peerlock);
|
||||||
trans = dr->trans;
|
trans = dr->trans;
|
||||||
while(trans) {
|
while(trans) {
|
||||||
dundi_discover(trans);
|
dundi_discover(trans);
|
||||||
trans = trans->next;
|
trans = trans->next;
|
||||||
}
|
}
|
||||||
|
ast_mutex_unlock(&peerlock);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int precache_transactions(struct dundi_request *dr, struct dundi_mapping *maps, int mapcount, int *expiration, int *foundanswers)
|
static int precache_transactions(struct dundi_request *dr, struct dundi_mapping *maps, int mapcount, int *expiration, int *foundanswers)
|
||||||
{
|
{
|
||||||
struct dundi_transaction *trans;
|
struct dundi_transaction *trans, *transn;
|
||||||
|
/* Mark all as "in thread" so they don't disappear */
|
||||||
|
ast_mutex_lock(&peerlock);
|
||||||
trans = dr->trans;
|
trans = dr->trans;
|
||||||
while(trans) {
|
while(trans) {
|
||||||
|
if (trans->thread)
|
||||||
|
ast_log(LOG_WARNING, "This shouldn't happen, really...\n");
|
||||||
|
trans->thread = 1;
|
||||||
|
trans = trans->next;
|
||||||
|
}
|
||||||
|
ast_mutex_unlock(&peerlock);
|
||||||
|
|
||||||
|
trans = dr->trans;
|
||||||
|
while(trans) {
|
||||||
|
if (!(trans->flags & FLAG_DEAD))
|
||||||
precache_trans(trans, maps, mapcount, expiration, foundanswers);
|
precache_trans(trans, maps, mapcount, expiration, foundanswers);
|
||||||
trans = trans->next;
|
trans = trans->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Cleanup any that got destroyed in the mean time */
|
||||||
|
ast_mutex_lock(&peerlock);
|
||||||
|
trans = dr->trans;
|
||||||
|
while(trans) {
|
||||||
|
transn = trans->next;
|
||||||
|
trans->thread = 0;
|
||||||
|
if (trans->flags & FLAG_DEAD) {
|
||||||
|
ast_log(LOG_DEBUG, "Our transaction went away!\n");
|
||||||
|
destroy_trans(trans, 0);
|
||||||
|
}
|
||||||
|
trans = transn;
|
||||||
|
}
|
||||||
|
ast_mutex_unlock(&peerlock);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user