Improved state disconnect a little bit.

This commit is contained in:
MelwareDE 2005-08-07 13:33:48 +00:00
parent 450dd31d58
commit 458e209ac7
1 changed files with 9 additions and 7 deletions

View File

@ -2356,6 +2356,7 @@ static void capi_handle_disconnect_indication(_cmsg *CMSG, unsigned int PLCI, un
{ {
_cmsg CMSG2; _cmsg CMSG2;
struct ast_frame fr; struct ast_frame fr;
int state;
DISCONNECT_RESP_HEADER(&CMSG2, ast_capi_ApplID, CMSG->Messagenumber , 0); DISCONNECT_RESP_HEADER(&CMSG2, ast_capi_ApplID, CMSG->Messagenumber , 0);
DISCONNECT_RESP_PLCI(&CMSG2) = PLCI; DISCONNECT_RESP_PLCI(&CMSG2) = PLCI;
@ -2363,6 +2364,9 @@ static void capi_handle_disconnect_indication(_cmsg *CMSG, unsigned int PLCI, un
return_on_no_interface("DISCONNECT_IND"); return_on_no_interface("DISCONNECT_IND");
state = i->state;
i->state = CAPI_STATE_DISCONNECTED;
i->reason = DISCONNECT_IND_REASON(CMSG); i->reason = DISCONNECT_IND_REASON(CMSG);
if (PLCI == i->onholdPLCI) { if (PLCI == i->onholdPLCI) {
@ -2371,9 +2375,8 @@ static void capi_handle_disconnect_indication(_cmsg *CMSG, unsigned int PLCI, un
return; return;
} }
if ((i->owner) && (i->state == CAPI_STATE_DID) && (i->owner->pbx == NULL)) { if ((i->owner) && (state == CAPI_STATE_DID) && (i->owner->pbx == NULL)) {
/* the pbx was not started yet */ /* the pbx was not started yet */
i->state = CAPI_STATE_DISCONNECTED;
ast_hangup(i->owner); ast_hangup(i->owner);
return; return;
} }
@ -2391,8 +2394,8 @@ static void capi_handle_disconnect_indication(_cmsg *CMSG, unsigned int PLCI, un
* in this case * did not read our hangup control frame * in this case * did not read our hangup control frame
* so we must hangup the channel! * so we must hangup the channel!
*/ */
if ( (i->owner) && (i->state != CAPI_STATE_DISCONNECTED) && (i->state != CAPI_STATE_INCALL) && if ( (i->owner) && (state != CAPI_STATE_DISCONNECTED) && (state != CAPI_STATE_INCALL) &&
(i->state != CAPI_STATE_DISCONNECTING) && (ast_check_hangup(i->owner) == 0)) { (state != CAPI_STATE_DISCONNECTING) && (ast_check_hangup(i->owner) == 0)) {
cc_ast_verbose(1, 0, VERBOSE_PREFIX_3 "%s: soft hangup by capi\n", cc_ast_verbose(1, 0, VERBOSE_PREFIX_3 "%s: soft hangup by capi\n",
i->name); i->name);
ast_softhangup(i->owner, AST_SOFTHANGUP_DEV); ast_softhangup(i->owner, AST_SOFTHANGUP_DEV);
@ -2402,10 +2405,9 @@ static void capi_handle_disconnect_indication(_cmsg *CMSG, unsigned int PLCI, un
} }
} }
if (i->state == CAPI_STATE_DISCONNECTING) { if (state == CAPI_STATE_DISCONNECTING) {
interface_cleanup(i); interface_cleanup(i);
} }
i->state = CAPI_STATE_DISCONNECTED;
} }
/* /*
@ -2716,7 +2718,7 @@ static void capi_handle_confirmation(_cmsg *CMSG, unsigned int PLCI, unsigned in
case CAPI_LISTEN: case CAPI_LISTEN:
case CAPI_INFO: case CAPI_INFO:
if (CMSG->Info) { if (CMSG->Info) {
ast_log(LOG_ERROR, "CAPI: conf_error 0x%x PLCI=0x%x Command.Subcommand = %#x.%#x\n", cc_ast_verbose(1, 1, VERBOSE_PREFIX_2 "CAPI: conf_error 0x%x PLCI=0x%x Command.Subcommand = %#x.%#x\n",
CMSG->Info, PLCI, CMSG->Command, CMSG->Subcommand); CMSG->Info, PLCI, CMSG->Command, CMSG->Subcommand);
} }
break; break;