Summary:ASTERISK-03965: [patch] Hang during call to Wait - also cause of deadlock messages
Reporter:obelisk (obelisk)Labels:
Date Opened:2005-04-21 11:40:19Date Closed:2005-05-31 00:21:24
Versions:Frequency of
Environment:Attachments:( 0) asterisk-poll-timeout.patch
( 1) 4060.stable.patch.txt
Description:I am using * from a CVS on the 16th, and I have a Fritz card used to receive incoming calls (with patches to make it work with the latest CVS). It works fine in normal circumstances. I added:

  exten => s,1,Wait,2

to the start of the initial context the ISDN call comes into, and it waited too short a time, so I changed it to:

  exten => s,1,Wait,12

Now, the Wait never returns.

This seems to happen for smaller values of the wait parameter, perhaps based on load.


This seems to relate to the code in channel.c not handling a zero return value from the call to poll.

It *looks* like the call to 'poll' times out, but not at the exact millisecond
expected (or system times are slightly out in comparison to timer used by

The attached patch checks for a 0 return from poll which according to the docs
means a timeout. If zero is returned, it explicitly sets *ms to 0.

The problem has now gone away, along with several annoying deadlock messages.

This looks safe to me, but I'd appreciate someone who knows asterisk looking at it!

Comments:By: Kevin P. Fleming (kpfleming) 2005-04-22 08:34:33

Do you have a disclaimer on file? I cannot commit your patch without it being disclaimed.

By: obelisk (obelisk) 2005-04-22 09:16:31

I saw all the Karma comments about disclaimers, but could find no details on how to give you one.

By: Kevin P. Fleming (kpfleming) 2005-04-22 09:20:03

The main page of the bug tracker has a section that describes how to do it... http://bugs.digium.com

By: obelisk (obelisk) 2005-04-22 09:32:21

Just faxed it.

By: Mark Spencer (markster) 2005-04-24 18:04:46

Got the disclaimer...

Added to CVS, however:

1) Please note that chan_capi is *not* part of Asterisk and is *not* covered by this bug tracker.

2) This patch is really just working around a buggy poll implementation in CAPI.  There is no reason that it should return 0 from poll yet not take long enough for the catch for the "ms" counter at the end not to trigger.

By: Michael Jerris (mikej) 2005-05-30 23:32:02

This is commit of asterisk channel.c,1.191,1.192.  No note of bug number in commit log:
--- channel.c 22 Apr 2005 13:11:34 -0000 1.191
+++ channel.c 24 Apr 2005 22:54:50 -0000 1.192
@@ -1126,6 +1126,12 @@
return NULL;
+        } else {
+         /* If no fds signalled, then timeout. So set ms = 0
+   since we may not have an exact timeout.
+ */
+ if (res == 0)
+ *ms = 0;

if (havewhen)

By: Michael Jerris (mikej) 2005-05-30 23:44:41

patch for stable, disclaimer on file.

By: Russell Bryant (russell) 2005-05-31 00:21:24

fixed in 1.0, thanks!