Fix problems with zero message numbers, and make sure that the interface message number gets set to zero when it is not in use.

This commit is contained in:
MelwareDE 2006-01-13 02:38:26 +00:00
parent 2ecb9846cb
commit 3f5395c6d9
1 changed files with 13 additions and 2 deletions

View File

@ -59,7 +59,7 @@
*/
static unsigned capi_ApplID = 0;
static _cword capi_MessageNumber = 1;
static _cword capi_MessageNumber;
static char *desc = "Common ISDN API for Asterisk";
#ifdef CC_AST_HAVE_TECH_PVT
static const char tdesc[] = "Common ISDN API Driver (" CC_VERSION ") " ASTERISKVERSION;
@ -214,8 +214,15 @@ static _cword get_capi_MessageNumber(void)
_cword mn;
cc_mutex_lock(&messagenumber_lock);
mn = capi_MessageNumber;
capi_MessageNumber++;
if (capi_MessageNumber == 0) {
/* avoid zero */
capi_MessageNumber = 1;
}
mn = capi_MessageNumber;
cc_mutex_unlock(&messagenumber_lock);
return(mn);
@ -706,6 +713,7 @@ static void interface_cleanup(struct capi_pvt *i)
i->faxhandled = 0;
i->PLCI = 0;
i->MessageNumber = 0;
i->NCCI = 0;
i->onholdPLCI = 0;
@ -1956,6 +1964,9 @@ static struct capi_pvt *find_interface_by_msgnum(unsigned short msgnum)
{
struct capi_pvt *i;
if (msgnum == 0x0000)
return NULL;
cc_mutex_lock(&iflock);
for (i = iflist; i; i = i->next) {
if ((i->PLCI == 0) && (i->MessageNumber == msgnum))