Commit Graph

29 Commits

Author SHA1 Message Date
Mark Michelson 99ea83bbec Merged revisions 122713 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r122713 | mmichelson | 2008-06-13 16:44:53 -0500 (Fri, 13 Jun 2008) | 9 lines

Short circuit the loop in autoservice_run if there are no channels to poll.
If we continued, then the result would be calling poll() with a NULL
pollfd array. While this is fine with POSIX's poll(2) system call, those
who use Asterisk's internal poll mechanism (Darwin systems) would have
a failed assertion occur when poll is called.

(related to issue #10342)


........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@122714 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-06-13 21:45:21 +00:00
Joshua Colp 88a847c4cc Merged revisions 119354 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r119354 | file | 2008-05-30 16:46:37 -0300 (Fri, 30 May 2008) | 2 lines

Fix a bug I found while testing for another issue.

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@119355 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-05-30 19:47:30 +00:00
Russell Bryant f98e98819e Merged revisions 119156 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r119156 | russell | 2008-05-29 17:24:29 -0500 (Thu, 29 May 2008) | 10 lines

Fix a race condition in channel autoservice.  There was still a small window of opportunity
for a DTMF frame, or some other deferred frame type, to come in and get dropped.

(closes issue #12656)
(closes issue #12656)
Reported by: dimas
Patches:
      v3-12656.patch uploaded by dimas (license 88)
	  -- with some modifications by me

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@119157 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-05-29 22:28:50 +00:00
Russell Bryant 8e4c0e85d8 Merged revisions 115990 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r115990 | russell | 2008-05-13 16:05:57 -0500 (Tue, 13 May 2008) | 5 lines

Fix an issue that I noticed in autoservice while mmichelson and I were debugging
a different problem.  I noticed that it was theoretically possible for two threads
to attempt to start the autoservice thread at the same time.  This change makes the
process of starting the autoservice thread, thread-safe.

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@116001 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-05-13 21:07:59 +00:00
Russell Bryant 19f7e8cc93 Merged revisions 114230 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r114230 | russell | 2008-04-17 17:15:43 -0500 (Thu, 17 Apr 2008) | 6 lines

Remove redundant safety net.  The check for the autoservice channel list state
accomplishes the same goal in a better way.

(issue #12470)
Reported By: atis

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@114233 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-17 22:24:00 +00:00
Russell Bryant 6430ec3294 Merged revisions 110395 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r110395 | russell | 2008-03-20 18:13:56 -0500 (Thu, 20 Mar 2008) | 9 lines

Shorten the ast_waitfor() timeout from 500 ms to 50 ms in the autoservice thread.
This really should not make a difference except in very rare cases.  That case would
be that all of the channels in autoservice are not generating any frames.  In that
case, this change reduces the potential amount of time that a thread waits in
ast_autoservice_stop() for the autoservice thread to wrap back around to the beginning
of its loop.

(closes issue #12266, reported by dimas)

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@110396 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-03-20 23:14:13 +00:00
Russell Bryant f7467c83e6 Merged revisions 105565 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r105565 | russell | 2008-03-03 10:01:50 -0600 (Mon, 03 Mar 2008) | 3 lines

Update the copyright information for autoservice.  Most of the code in this file
now is stuff that I have written recently ...

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@105566 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-03-03 16:02:19 +00:00
Russell Bryant 8372a9bf08 3) In addition to merging the changes below, change trunk back to a regular
LIST instead of an RWLIST.  The way this list works makes it such that
   a RWLIST provides no additional benefit.  Also, a mutex is needed for
   use with the thread condition.


Merged revisions 105563 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r105563 | russell | 2008-03-03 09:50:43 -0600 (Mon, 03 Mar 2008) | 24 lines

Merge in some changes from team/russell/autoservice-nochans-1.4

These changes fix up some dubious code that I came across while auditing what
happens in the autoservice thread when there are no channels currently in
autoservice.

1) Change it so that autoservice thread doesn't keep looping around calling
   ast_waitfor_n() on 0 channels twice a second.  Instead, use a thread condition
   so that the thread properly goes to sleep and does not wake up until a
   channel is put into autoservice.

   This actually fixes an interesting bug, as well.  If the autoservice thread
   is already running (almost always is the case), then when the thread goes
   from having 0 channels to have 1 channel to autoservice, that channel would
   have to wait for up to 1/2 of a second to have the first frame read from it.

2) Fix up the code in ast_waitfor_nandfds() for when it gets called with no
   channels and no fds to poll() on, such as was the case with the previous code
   for the autoservice thread.  In this case, the code would call alloca(0), and
   pass the result as the first argument to poll().  In this case, the 2nd
   argument to poll() specified that there were no fds, so this invalid pointer
   shouldn't actually get dereferenced, but, this code makes it explicit and
   ensures the pointers are NULL unless we have valid data to put there.

(related to issue #12116)

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@105564 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-03-03 15:59:50 +00:00
Russell Bryant 796780679e Merged revisions 105409 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r105409 | russell | 2008-02-29 17:34:32 -0600 (Fri, 29 Feb 2008) | 23 lines

Fix a major bug in autoservice.  There was a race condition in the handling of
the list of channels in autoservice.  The problem was that it was possible for
a channel to get removed from autoservice and destroyed, while the autoservice
thread was still messing with the channel.  This led to memory corruption, and
caused crashes.  This explains multiple backtraces I have seen that have
references to autoservice, but do to the nature of the issue (memory corruption),
could cause crashes in a number of areas.

(fixes the crash in BE-386)
(closes issue #11694)
(closes issue #11940)

The following issues could be related.  If you are the reporter of one of these,
please update to include this fix and try again.

(potentially fixes issue #11189)
(potentially fixes issue #12107)
(potentially fixes issue #11573)
(potentially fixes issue #12008)
(potentially fixes issue #11189)
(potentially fixes issue #11993)
(potentially fixes issue #11791)

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@105410 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-02-29 23:36:46 +00:00
Tilghman Lesher f48ed5a943 Merged revisions 97194 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r97194 | tilghman | 2008-01-08 14:47:07 -0600 (Tue, 08 Jan 2008) | 3 lines

Increase constants to where we're less likely to hit them while debugging.
(Closes issue #11694)

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@97198 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-01-08 20:56:38 +00:00
Russell Bryant 74c94cfdeb Merged revisions 94801 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r94801 | russell | 2007-12-26 13:04:31 -0600 (Wed, 26 Dec 2007) | 4 lines

Just in case the AST_FLAG_END_DTMF_ONLY flag was already set before starting
autoservice, remember it and ensure that the channel has the same setting when
autoservice gets stopped.  (pointed out by d1mas, patched up by me)

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@94802 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-12-26 19:09:17 +00:00
Russell Bryant 2295f37761 Merged revisions 94797 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r94797 | russell | 2007-12-26 12:46:39 -0600 (Wed, 26 Dec 2007) | 4 lines

When a channel is in autoservice, mark a flag on the channel that says that
we only care about the END of a digit.  That way, no magic digit emulation stuff
will happen when all we're doing is queueing up END frames.

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@94798 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-12-26 18:47:52 +00:00
Russell Bryant 296e09f9aa Merged revisions 94790 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r94790 | russell | 2007-12-26 11:06:26 -0600 (Wed, 26 Dec 2007) | 5 lines

Don't store DTMF BEGIN frames while a channel is in autoservice.  It's just
going to make ast_read() do a lot of extra work when the channel comes back
out of autoservice.
(closes issue #11628, patched by me)

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@94791 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-12-26 17:07:12 +00:00
Russell Bryant 00297c91e5 Merged revisions 91777 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r91777 | russell | 2007-12-07 10:08:35 -0600 (Fri, 07 Dec 2007) | 6 lines

* Add a bit more of a verbose comment as to why a hangup frame needs to be
  queued up if autoservice gets a NULL return from ast_read().
* Make the process of queueing the hangup frame more efficient by putting the
  frame where it is going to end up and avoiding some locking and extra memory
  allocations and freeing.

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@91778 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-12-07 16:11:00 +00:00
Mark Michelson 05dd9b7ef0 Merged revisions 91737 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r91737 | mmichelson | 2007-12-07 09:39:58 -0600 (Fri, 07 Dec 2007) | 7 lines

Hangups that happen during autoservice were not processed appropriately. This is
because a hangup actually causes a NULL frame to be received, not a hangup frame.
Queueing a hangup if we receive a NULL frame during autoservice corrects this problem

(closes issue #11467, reported  by jmls, patched by me)


........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@91738 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-12-07 15:40:59 +00:00
Tilghman Lesher 87492f6dd6 Merged revisions 90432 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r90432 | tilghman | 2007-12-02 03:34:23 -0600 (Sun, 02 Dec 2007) | 7 lines

Clarify the return value on autoservice.  Specifically, if you started
autoservice and autoservice was already on, it would erroneously return an
error.
Reported by: adiemus
Patch by: dimas
(Closes issue #11433)

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@90433 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-12-02 09:42:48 +00:00
Russell Bryant 8133ad1456 Merged revisions 89886 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r89886 | russell | 2007-11-27 17:47:28 -0600 (Tue, 27 Nov 2007) | 2 lines

Don't do frame processing if ast_read() returned NULL.

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89888 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-27 23:50:58 +00:00
Russell Bryant 21a22fa584 Merged revisions 89790 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r89790 | russell | 2007-11-27 15:45:51 -0600 (Tue, 27 Nov 2007) | 41 lines

Merge changes from team/russell/autoservice_1.4

This set of changes fixes an issue that was reported to me on IRC yesterday.
The user, d1mas, was using chan_zap for incoming calls and was having DTMF
recognition issues in some situations.  Specifically, he noticed that the 
problem occurred when using DISA or WaitExten.  He also noticed that when 
using Read, the problem did not occur.  His system also used DUNDi for 
dialplan lookups.

So, he theorized that if the DUNDi lookups blocked for some period of time,
that audio from the zap channel could get lost.  If the audio got lost, then
it wouldn't be run through the DTMF detector, and digits could get lost.
He was correct, and the following set of changes fixes the problem.  However,
the changes go a little bit further than what was necessary to fix this exact
problem.

1) I updated pbx_extension_helper() to autoservice the associated channel to
   handle cases where extension lookups may take a long time.  This would
   normally be a dialplan switch that does some lookup over the network, such
   as the DUNDi or IAX2 switches.

   This ensures that even while a DUNDi lookup is blocking, the channel will be
   continuously serviced.

2) I made a change to the autoservice code.  This is actually something that
   has bothered me for a long time.  When a channel is in autoservice, _all_
   frames get thrown away.  However, some frames really shouldn't be thrown
   away.  The most notable examples are signalling (CONTROL) frames, and DTMF.

   So, this patch queues up important frames while a channel is in autoservice.
   When autoservice is stopped on the channel, the queued up frames get stuck
   back on the channel so that they can get processed instead of thrown away.

3) I made another change to the autoservice code to handle the case where
   autoservice is started on channels recursively.

   Previously, you could call ast_autoservice_start() multiple times on a
   channel, and it would stop the first time ast_autoservice_stop() gets
   called.  Now, it will ensure that autoservice doesn't actually stop until
   the final call to ast_autoservice_stop().

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89791 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-27 22:05:36 +00:00
Luigi Rizzo e0ff5fef5c remove a bunch of useless #include "options.h"
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89511 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-21 23:09:02 +00:00
Luigi Rizzo 9335ace850 another bunch of include removals (errno.h and asterisk/logger.h)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89425 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-19 19:09:03 +00:00
Luigi Rizzo fdb7f7ba3d Start untangling header inclusion in a way that does not affect
build times - tested, there is no measureable difference before and
after this commit.

In this change:

use asterisk/compat.h to include a small set of system headers:
inttypes.h, unistd.h, stddef.h, stddint.h, sys/types.h, stdarg.h,
stdlib.h, alloca.h, stdio.h

Where available, the inclusion is conditional on HAVE_FOO_H as determined
by autoconf.

Normally, source files should not include any of the above system headers,
and instead use either "asterisk.h" or "asterisk/compat.h" which does it
better. 

For the time being I have left alone second-level directories
(main/db1-ast, etc.).



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89333 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-16 20:04:58 +00:00
Kevin P. Fleming edc78d6023 improve linked-list macros in two ways:
- the *_CURRENT macros no longer need the list head pointer argument
  - add AST_LIST_MOVE_CURRENT to encapsulate the remove/add operation when moving entries between lists


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89106 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-08 05:28:47 +00:00
Russell Bryant 4e0947c5f1 Convert code that checks the _softhangup member of ast_channel directory to use
the ast_check_hangup() funciton.  This function takes scheduled hangups into
account.
(closes issue #10230, patch by Juggie)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@77858 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-08-01 15:39:54 +00:00
Joshua Colp 556ea9f554 Even more minor code cleanup!
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@68920 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-06-12 14:16:37 +00:00
Tilghman Lesher 9d05ff8ed5 Issue 9869 - replace malloc and memset with ast_calloc, and other coding guidelines changes
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@67864 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-06-06 21:20:11 +00:00
Joshua Colp b86d65958f Might as well go crazy here too and make the autoservice list read/write.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@51487 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-01-23 00:16:55 +00:00
Joshua Colp 21b53af31d Cosmetic changes. Make main source files better conform to coding guidelines and standards. (issue #8679 reported by johann8384)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@51486 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-01-23 00:11:32 +00:00
Kevin P. Fleming 3c876af5cf Merged revisions 44378 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r44378 | kpfleming | 2006-10-04 14:47:22 -0500 (Wed, 04 Oct 2006) | 4 lines

update thread creation code a bit
reduce standard thread stack size slightly to allow the pthreads library to allocate the stack+data and not overflow a power-of-2 allocation in the kernel and waste memory/address space
add a new stack size for 'background' threads (those that don't handle PBX calls) when LOW_MEMORY is defined

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@44379 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-04 19:51:38 +00:00
Kevin P. Fleming 0a27d8bfe5 merge new_loader_completion branch, including (at least):
- restructured build tree and makefiles to eliminate recursion problems
  - support for embedded modules
  - support for static builds
  - simpler cross-compilation support
  - simpler module/loader interface (no exported symbols)



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@40722 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-08-21 02:11:39 +00:00