p2 = iflist;
while(p2) {
if (!strcmp(p2->callid, tmp5)) {
- /* Go ahead and lock it before returning */
+ /* Go ahead and lock it (and its owner) before returning */
ast_mutex_lock(&p2->lock);
+ if (p2->owner) {
+ while(ast_mutex_trylock(&p2->owner->lock)) {
+ ast_mutex_unlock(&p2->lock);
+ usleep(1);
+ ast_mutex_lock(&p2->lock);
+ if (!p2->owner)
+ break;
+ }
+ }
p->refer_call = p2;
break;
}
if (p->refer_call) {
ast_log(LOG_DEBUG,"202 Accepted (supervised)\n");
attempt_transfer(p, p->refer_call);
+ if (p->refer_call->owner)
+ ast_mutex_unlock(&p->refer_call->owner->lock);
ast_mutex_unlock(&p->refer_call->lock);
p->refer_call = NULL;
p->gotrefer = 1;
return NULL;
}
while(!feof(f)) {
- fgets(buf, sizeof(buf), f);
lineno++;
- if (!feof(f)) {
+ if (fgets(buf, sizeof(buf), f)) {
if (cfg_process(tmp, _tmpc, _last, buf, lineno, configfile, includelevel
#ifdef PRESERVE_COMMENTS
, acs