[Asterisk-cvs] asterisk/pbx pbx_dundi.c,1.15,1.16
markster at lists.digium.com
markster at lists.digium.com
Tue Nov 2 16:53:34 CST 2004
Update of /usr/cvsroot/asterisk/pbx
In directory mongoose.digium.com:/tmp/cvs-serv29853/pbx
Modified Files:
pbx_dundi.c
Log Message:
Fix locking issues
Index: pbx_dundi.c
===================================================================
RCS file: /usr/cvsroot/asterisk/pbx/pbx_dundi.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- pbx_dundi.c 29 Oct 2004 22:31:36 -0000 1.15
+++ pbx_dundi.c 2 Nov 2004 21:56:01 -0000 1.16
@@ -3183,22 +3183,50 @@
static int discover_transactions(struct dundi_request *dr)
{
struct dundi_transaction *trans;
+ ast_mutex_lock(&peerlock);
trans = dr->trans;
while(trans) {
dundi_discover(trans);
trans = trans->next;
}
+ ast_mutex_unlock(&peerlock);
return 0;
}
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;
while(trans) {
- precache_trans(trans, maps, mapcount, expiration, foundanswers);
+ 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);
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;
}
More information about the svn-commits
mailing list