Index: channels/chan_sip.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v retrieving revision 1.835 diff -u -r1.835 chan_sip.c --- channels/chan_sip.c 1 Sep 2005 23:01:54 -0000 1.835 +++ channels/chan_sip.c 2 Sep 2005 08:31:07 -0000 @@ -9947,7 +9947,7 @@ { int gotdest; int res = 0; - int firststate = 0; + int firststate = -2; if (p->initreq.headers) { /* We already have a dialog */ @@ -10066,13 +10066,6 @@ } if (p->subscribed != NONE) p->stateid = ast_extension_state_add(p->context, p->exten, cb_extensionstate, p); - firststate = ast_extension_state(NULL, p->context, p->exten); - if (firststate < 0) { - ast_log(LOG_ERROR, "Got SUBSCRIBE for extensions without hint. Please add hint to %s in context %s\n", p->exten, p->context); - transmit_response(p, "404 Not found", req); - ast_set_flag(p, SIP_NEEDDESTROY); - return 0; - } } } @@ -10084,8 +10077,7 @@ ast_set_flag(p, SIP_NEEDDESTROY); return 0; } - /* TODO: Do we need this any longer? And what exactly to remove? */ - /* The next line can be removed if the SNOM200 Expires bug is fixed */ + /* The next 4 lines can be removed if the SNOM Expires bug is fixed */ if (p->subscribed == DIALOG_INFO_XML) { if (p->expiry > max_expiry) p->expiry = max_expiry; @@ -10096,8 +10088,16 @@ if (p->autokillid > -1) sip_cancel_destroy(p); /* Remove subscription expiry for renewals */ sip_scheddestroy(p, (p->expiry + 10) * 1000); /* Set timer for destruction of call at expiration */ - transmit_state_notify(p, firststate, 1, 1); /* Send first notification */ - append_history(p, "Subscribestatus", "active"); + + if ((firststate = ast_extension_state(NULL, p->context, p->exten)) < 0) { + ast_log(LOG_ERROR, "Got SUBSCRIBE for extensions without hint. Please add hint to %s in context %s\n", p->exten, p->context); + transmit_response(p, "404 Not found", req); + ast_set_flag(p, SIP_NEEDDESTROY); + return 0; + } else { + transmit_state_notify(p, firststate, 1, 1); /* Send first notification */ + append_history(p, "Subscribestatus", (char (*))ast_extension_state2str(firststate)); + } } return 1; }