From: Steven S. <ss...@so...> - 2004-01-07 23:34:00
|
Here's a real surprise I found: the failure in the iaxClient library seems to be failing when it calls iax_get_event in the iax2 library. Here's my understanding of how this is happening: 1. My Client Starts. 2. It initializes IAX2 passing in all the necessary goodies. 3. It calls iaxc_start_processing_thread() to begin processing. 4. iaxc_processor calls the function iaxc_process_calls 5. iaxc_process_calls call iaxc_service_network 6. iaxc_service_network checks for a waiting event using select/FD_ISSET 7. If an event is waiting (bit is set on net FD), do_iax_event gets called. 8. do_iax_event continues to get called until FD bit is not set (no more events?) 9. do_iax_event gets called one more time to handle anything that may have been missed? 10. iaxc_service_network returns. 11. iaxc_process_calls handles other functions (pings, audio, registrations). 12. iaxc_process_calls returns. 13. iaxc_processor sleeps for 5ms. 14. iaxc_processor starts over -> Goto Step 5. In steps 7, 8 and 9, the code calls do_iax_event() which in turn gets an event structure by calling the iax_get_event(0) function in iax.c. The iax_get_event function appears to process pending messages then gets events from the network by calling iax_net_read. Iax_net_read in turn grabs a buffer from the network file descriptor and processes it into an event structure by calling iax_net_process. Iax_net_process converts the buffer into either a full sized or mini header. Based on the type of header it uses one of two methods to transform the data into an event (either an "event" or a voice frame). In theory every time the netfd is set (meaning there is an event waiting) there should be an event structure to read from the network (from Asterisk). This is where things (under Win32, at least) seem to break down. I added some code to alert me when the netfd is signaled but there is no event returned by the iax_get_event(0) call in iax_do_event (i.e. the event pointer [e] is null). This seems to happen from time to time. And for whatever reason, it seems to happen fairly consistently after a few minutes, causing it to miss call notifications. Oddly it does not seem to have any problem with re-registration acknowledgments. And apparently it does not happen on the connection to/from IAXtel. Would this mean that my local Asterisk is munging the messages? I see some debugging code in the libiax code, but I don't know how to activate a debugger that will respond (nor what if anything needs to be changed in my build to activate the debugging code). Any suggestions would be greatly helpful. I know Michael is looking forward to a fix for this. I don't know if Dante is still plagued by this one or not, but it would be great to have the Win32 side of the library clean and running smooth! Thanks, Steve Sokol Sokol & Associates, LLC [Where I Think Thins Are Going South] static void do_iax_event() { struct iax_event *e = 0; int callNo; while ( (e = iax_get_event(0))) { // first, see if this is an event for one of our calls. callNo = iaxc_find_call_by_session(e->session); if(callNo >= 0) { iaxc_handle_network_event(e, callNo); } else if #ifndef IAXC_IAX2 ( e->etype == IAX_EVENT_REGREP ) #else ((e->etype == IAX_EVENT_REGACK ) || (e->etype == IAX_EVENT_REGREJ )) #endif { iaxc_handle_regreply(e); } else if(e->etype == IAX_EVENT_REGREQ ) { iaxc_usermsg(IAXC_ERROR, "Registration requested by someone, but we don't understand!"); } else if(e->etype == IAX_EVENT_CONNECT) { callNo = iaxc_first_free_call(); .... |