--- chan_dahdi.c.167791 2009-01-09 20:14:18.000000000 +1300 +++ chan_dahdi.c 2009-01-10 14:30:34.000000000 +1300 @@ -8105,6 +8105,8 @@ static void *do_monitor(void *data) char buf[1024]; struct pollfd *pfds=NULL; int lastalloc = -1; + struct dahdi_params par; + /* This thread monitors all the frame relay interfaces which are not yet in use (and thus do not have a separate thread) indefinitely */ /* From here on out, we die whenever asked */ @@ -8183,22 +8185,26 @@ static void *do_monitor(void *data) last = i; if (last) { if (!last->mwisendactive && last->sig & __DAHDI_SIG_FXO) { - res = has_voicemail(last); - if (last->msgstate != res) { - /* Set driver resources for signalling VMWI */ - res2 = ioctl(last->subs[SUB_REAL].dfd, DAHDI_VMWI, &res); - if (res2) { - /* TODO: This message will ALWAYS be generated on some cards; any way to restrict it to those cards where it is interesting? */ - ast_debug(3, "Unable to control message waiting led on channel %d: %s\n", last->channel, strerror(errno)); - } - /* This channel has a new voicemail state, - * initiate a mechanism to send an MWI message - */ - if (mwi_send_init(last)) { - ast_log(LOG_WARNING, "Unable to initiate mwi send sequence on channel %d\n", last->channel); + /* make sure port is OnHook before sending MWI spill */ + res = ioctl(last->subs[SUB_REAL].dfd, DAHDI_GET_PARAMS, &par); + if (!res && !par.rxisoffhook) { + res = has_voicemail(last); + if (last->msgstate != res) { + /* Set driver resources for signalling VMWI */ + res2 = ioctl(last->subs[SUB_REAL].dfd, DAHDI_VMWI, &res); + if (res2) { + /* TODO: This message will ALWAYS be generated on some cards; any way to restrict it to those cards where it is interesting? */ + ast_debug(3, "Unable to control message waiting led on channel %d: %s\n", last->channel, strerror(errno)); + } + /* This channel has a new voicemail state, + * initiate a mechanism to send an MWI message + */ + if (mwi_send_init(last)) { + ast_log(LOG_WARNING, "Unable to initiate mwi send sequence on channel %d\n", last->channel); + } + last->msgstate = res; + found ++; } - last->msgstate = res; - found ++; } } last = last->next;