|
From: Eugene P. <pro...@st...> - 2005-12-20 08:12:37
|
> Hope this helps,
> Cristi
Great thanks!
Now I tried to decide this problem in another way. I use existing
iaxc_remove_registration_by_id function and correct it:
static int iaxc_remove_registration_by_id(int id) {
struct iaxc_registration *curr, *prev;
int count=0;
fprintf(stderr, "iaxc_remove_registration_by_id : %d\n", id);
for( prev=NULL, curr=registrations; curr != NULL; prev=curr,
curr=curr->next ) {
fprintf(stderr, "iaxc_remove_registration_by_id : processing %d\n",
curr->id);
if( curr->id == id ) {
count++;
fprintf(stderr, "iaxc_remove_registration_by_id : session %d\n",
curr->session);
if( curr->session != NULL ) {
iax_unregister( curr->session );
iax_destroy( curr->session );
} if( prev != NULL ) {
prev->next = curr->next;
} else {
registrations = curr->next;
}
free( curr );
break;
}
}
return count;
}
This function is used by iaxc_unregister, so all must works. But problem
was in curr->session variable. It's always null. The reason is this code:
static void iaxc_handle_regreply(struct iax_event *e, struct
iaxc_registration *reg) {
iaxc_do_registration_callback(reg->id, e->etype, e->ies.msgcount);
// XXX I think the session is no longer valid.. at least, that's
// what miniphone does, and re-using the session doesn't seem to
// work!
iax_destroy(reg->session);
reg->session = NULL;
if (e->etype == IAX_EVENT_REGREJ) {
// we were rejected, so end the registration
iaxc_remove_registration_by_id(reg->id);
}
}
I comment strings with reg->session, so iaxc_remove_registration_by_id
can call iax_unregister. But there are no any effect. After calling
send_command(session, AST_FRAME_IAX, IAX_COMMAND_REGREL, 0, NULL, 0, -1);
I see no messages on Asterisk console and I see my unregistered client
in iax2 show peers during 1 minute :(
Why can it be?
--
Thanks,
Eugene Prokopiev
|