--- chan_dahdi.c.2 2009-08-09 21:20:51.000000000 +1200 +++ chan_dahdi.c 2009-08-10 20:32:48.000000000 +1200 @@ -1602,11 +1602,11 @@ static int my_get_callerid(void *pvt, ch } } - if (analog_p->ringt) { - analog_p->ringt--; - } - if (analog_p->ringt == 1) { - return -1; + if (analog_p->ringt > 0) { + if (!(--analog_p->ringt)) { + /* only return if we timeout from a ring event */ + return -1; + } } if (p->cid_signalling == CID_SIG_V23_JP) { @@ -1706,11 +1706,11 @@ static int my_distinctive_ring(struct as } break; } - if (analog_p->ringt) - analog_p->ringt--; - if (analog_p->ringt == 1) { - res = -1; - break; + if (analog_p->ringt > 0) { + if (!(--analog_p->ringt)) { + res = -1; + break; + } } } } @@ -7445,12 +7445,12 @@ static struct ast_frame *dahdi_read(stru ast_mutex_unlock(&p->lock); return &p->subs[idx].f; } - if (p->ringt == 1) { - ast_mutex_unlock(&p->lock); - return NULL; + if (p->ringt > 0) { + if (!(--p->ringt)) { + ast_mutex_unlock(&p->lock); + return NULL; + } } - else if (p->ringt > 0) - p->ringt--; #ifdef HAVE_OPENR2 if (p->mfcr2) { @@ -8996,11 +8996,11 @@ static void *analog_ss_thread(void *data } break; } - if (p->ringt) - p->ringt--; - if (p->ringt == 1) { - res = -1; - break; + if (p->ringt > 0) { + if (!(--p->ringt)) { + res = -1; + break; + } } } } @@ -9153,12 +9153,11 @@ static void *analog_ss_thread(void *data } break; } - if (p->ringt) { - p->ringt--; - } - if (p->ringt == 1) { - res = -1; - break; + if (p->ringt > 0) { + if (!(--p->ringt)) { + res = -1; + break; + } } samples += res; res = callerid_feed(cs, buf, res, AST_LAW(p)); @@ -9215,11 +9214,11 @@ static void *analog_ss_thread(void *data } break; } - if (p->ringt) - p->ringt--; - if (p->ringt == 1) { - res = -1; - break; + if (p->ringt > 0) { + if (!(--p->ringt)) { + res = -1; + break; + } } } }