[Home]

Summary:ASTERISK-03964: [patch] Wait failed (random message) in ast_waitfordigit_full()
Reporter:staffanu (staffanu)Labels:
Date Opened:2005-04-21 07:35:13Date Closed:2008-01-15 15:34:07.000-0600
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) patch-channel.c
Description:On one of my machines, the call to ast_waitfor_nandfds() in channel.c sometimes returns with the condition ((!rchan) && (outfd < 0) && (ms)) true, but none of the system calls in the function have failed.

ast_waitfordigit_full() assumes that there's been an error and prints out "Wait failed:", and the message corresponding to whatever error code happens to be in errno at the time.  It also returns an error and the call is hung up.

****** ADDITIONAL INFORMATION ******

This happens on an old slow machine (233 MHz), running FreeBSD 5.4.

Looking at the code in ast_waitfor_nandfds(), what happens seems logically impossible at first glance.  I added some debug prints to the function, and concluded that sometimes the call to poll() returns before the requested timeout, with no error, with no file descriptors ready.  This always happens when the timeout value is very small (under 5 ms).

I made the attached patch to make asterisk work on this machine, with no ill effects detected so far.  Maybe it would be better to change ast_waitfor_nandfds() so that it either sets *ms to 0, or calls poll again?  That would of course help in some other places that the same function is called...

At the very least, the part setting errno to 0 helps debugging, since one is not fooled into believing an error code that is printed actually happened...
Comments:By: Kevin P. Fleming (kpfleming) 2005-04-21 11:47:49

That looks reasonably safe, but I'm curious why your system's poll() function is returning in that case (not reached the timeout, no fds ready, no error indicated)?

Also, it doesn't appear that you have a disclaimer on file, although this patch is small enough we can accept it anyway... but if you wish to contribute anything more in the future, please file a disclaimer with Digium. Thanks!

By: staffanu (staffanu) 2005-04-21 17:54:53

I'm curious about why myself.  Maybe the timeout is rounded down in some circumstances?

I did fax a disclaimer about a month ago when submitting a minor patch (which was not accepted... :) ).

By: Kevin P. Fleming (kpfleming) 2005-04-21 20:49:55

Committed to CVS, thanks!

By: Russell Bryant (russell) 2005-05-11 22:38:05

fixed in 1.0 as well

By: Digium Subversion (svnbot) 2008-01-15 15:32:01.000-0600

Repository: asterisk
Revision: 5492

U   trunk/channel.c

------------------------------------------------------------------------
r5492 | kpfleming | 2008-01-15 15:32:01 -0600 (Tue, 15 Jan 2008) | 2 lines

initialize errno and don't report an error when poll() returns without indicating one (bug ASTERISK-3964)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=5492

By: Digium Subversion (svnbot) 2008-01-15 15:34:07.000-0600

Repository: asterisk
Revision: 5635

U   branches/v1-0/channel.c

------------------------------------------------------------------------
r5635 | russell | 2008-01-15 15:34:07 -0600 (Tue, 15 Jan 2008) | 2 lines

initialize errno and don't report an error when poll() returns without indicating one (bug ASTERISK-3964)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=5635