--- chan_dahdi.c-rel.invalid 2008-09-04 14:31:54.000000000 +0200 +++ chan_dahdi.c 2008-09-04 14:19:46.000000000 +0200 @@ -9522,9 +9522,17 @@ ast_mutex_lock(&p->lock); if (p->owner) { if (p->ss7call == e->iam.call) { - ast_mutex_unlock(&p->lock); - ast_log(LOG_WARNING, "Duplicate IAM requested on CIC %d\n", e->iam.cic); - break; + ast_log(LOG_WARNING, "Daul seizure on CIC %d!\n", e->iam.cic); + if ((e->iam.opc > ss7_get_pc(ss7)) ? (e->iam.cic & 1) : (~e->iam.cic & 1)) { + ast_log(LOG_NOTICE, "We are the controlling on CIC: %d, the remote party will step back, ignoring IAM\n", e->iam.cic); + ast_mutex_unlock(&p->lock); + break; + } else { + ast_log(LOG_NOTICE, "The remote party is the controlling on CIC: %d, we must step back!\n", e->iam.cic); + p->ss7call = NULL; + dahdi_hangup(p->owner); + p->owner = NULL; + } } else { ast_mutex_unlock(&p->lock); ast_log(LOG_WARNING, "Ring requested on CIC %d already in use!\n", e->iam.cic);