Affects Version/s: 14.2.1, GIT
Target Release Version/s: None
Security Level: None
gcc (Debian 4.9.2-10) 4.9.2
Frequency of Occurrence:Constant
ARI http requests take a huge time to be taken into account (and respond with the appropriate SIP messages)
- Setup an extension with a stasis application (withouth the answer app). E.g.,
- Place a call from a phone (sip or pjsip user. It doesn't matter) to the stasis extension (6100 in the example)
- Perform a ARI http request for a answer (or any other request on the channel):
The SIP message "200 OK" should be sent soon after the http POST request (let's say after a few milliseconds).
The SIP message "200 OK" takes an unacceptable time to be sent after the http POST request (>100ms the WCET is 200ms)
(see the wireshark trace attached)
When a channel enter a stasis application, a new thread is spawned and the function stasis_app_exec executed (file res_stasis.c). The function enter in a while loop that performs a ast_waitfor(channel, MAX_WAIT_MS) call that waits for events with a timeout of MAX_WAIT_MS (200ms).
Before a "channel/answer" request, the control flow is blocked on the ast_waitfor for 200ms, then handles the requests inside control_dispatch_all, then waits again on the ast_waitfor and so on... I see that the while loop repeats exactly every 200ms. So, when a "channel/answer" request arrives, ast_waitfor doesn't wake up immediately but waits for the 200ms timeout. When ast_waitfor exits for timeout, finally the channel performs the answer (WCET for the answer: 200ms).
After answering the channel, I see that the while cycle enter every 20ms, because ast_waitfor now exits after only 20ms (and not 200ms as before). So, next requests are more responsive (WCET for following requests: 20ms).
So, it seems to me that the ast_waitfor function doesn't work as expected (it doesn't wake up on http requests, but always wait the timeout expiration)