Commit Graph

59 Commits

Author SHA1 Message Date
Richard Mudgett 0989b63047 autoservice: Don't start channel autoservice if the thread is a user interface.
Executing dialplan functions from either AMI or ARI by getting a variable
could place the channel into autoservice.  However, these user interface
threads do not handle the channel's media so we wind up with two threads
attempting to handle the media.

There can be one and only one thread handling a channel's media at a time.
Otherwise, we don't know which thread is going to handle the media frames.

ASTERISK-27625

Change-Id: If2dc94ce15ddabf923ed1e2a65ea0ef56e013e49
2018-06-19 15:02:52 -05:00
Joshua Colp 9a9589e8e1 core: Reduce video update queueing.
A video update frame is used to indicate that a channel
with video negotiated should provide a full frame so the
decoder decoding the stream is able to do so. In situations
where a queue is used to store frames it makes no sense
for the queue to contain multiple video update frames. One
is sufficient to have a full frame be sent.

ASTERISK-27222

Change-Id: Id3f40a6f51b740ae4704003a1800185c0c658ee7
2017-08-28 11:12:50 -05:00
Joshua Colp 5a7af00e80 asterisk: Audit locking of channel when manipulating flags.
When manipulating flags on a channel the channel has to be
locked to guarantee that nothing else is also manipulating
the flags. This change introduces locking where necessary to
guarantee this. It also adds helper functions that manipulate
channel flags and lock to reduce repeated code.

ASTERISK-26789

Change-Id: I489280662dba0f4c50981bfc5b5a7073fef2db10
2017-05-16 14:25:23 +00:00
Richard Mudgett 72e3fc5845 Frame deferral: Revert API refactoring.
There are several issues with deferring frames that are caused by the
refactoring.

1) The code deferring frames mishandles adding a deferred frame to the
deferred queue.  As a result the deferred queue can only be one frame
long.

2) Deferrable frames can come directly from the channel driver as well as
the read queue.  These frames need to be added to the deferred queue.

3) Whoever is deferring frames is really only doing the __ast_read() to
collect deferred frames and doesn't care about the returned frames except
to detect a hangup event.  When frame deferral is completed we must make
the normal frame processing see the hangup as a frame anyway.  As such,
there is no need to have varying hangup frame deferral methods.  We also
need to be aware of the AST_SOFTHANGUP_ASYNCGOTO hangup that isn't real.
That fake hangup is to cause the PBX thread to break out of loops to go
execute a new dialplan location.

4) To properly deal with deferrable frames from the channel driver as
pointed out by (2) above, means that it is possible to process a dialplan
interception routine while frames are deferred because of the
AST_CONTROL_READ_ACTION control frame.  Deferring frames is not
implemented as a re-entrant operation so you could have the unsupported
case of two sections of code thinking they have control of the media
stream.

A worse problem is because of the bad implementation of the AMI PlayDTMF
action.  It can cause two threads to be deferring frames on the same
channel at the same time.  (ASTERISK_25940)

* Rather than fix all these problems simply revert the API refactoring as
there is going to be only autoservice and safe_sleep deferring frames
anyway.

ASTERISK-26343

ASTERISK-26716 #close

Change-Id: I45069c779aa3a35b6c863f65245a6df2c7865496
2017-02-02 13:02:03 -06:00
George Joseph 7263a17ca0 channel: Fix issues in hangup scenarios caused by frame deferral
ASTERISK-26343

Change-Id: I06dbf7366e26028251964143454a77d017bb61c8
(cherry picked from commit 0be46aaf6b)
2016-11-14 13:18:11 -07:00
George Joseph 6d61f7bfd1 Revert "Revert "autoservice: Use frame deferral API""
This reverts commit edca6911f3.

Change-Id: I76030b87333a2c390cd05392b74b75678d78ddfa
2016-11-14 14:14:50 -06:00
George Joseph edca6911f3 Revert "autoservice: Use frame deferral API"
This reverts commit afef1b8e4a.
Multiple testsuite failures were detected after the fact.

Change-Id: Ib4cb0c0a6475681ce817f71b4050be25640ab67f
2016-11-10 08:32:50 -05:00
Mark Michelson afef1b8e4a autoservice: Use frame deferral API
Rather than use manual frame deferral, just let the channel API do it
for us.

ASTERISK-26343

Change-Id: I688386f36e765dbc07be863943a43f26bd5eac49
(cherry picked from commit 8ba3e2fc27)
2016-11-08 07:06:57 -07:00
Corey Farrell a6e5bae3ef Remove ASTERISK_REGISTER_FILE.
ASTERISK_REGISTER_FILE no longer has any purpose so this commit removes
all traces of it.

Previously exported symbols removed:
* __ast_register_file
* __ast_unregister_file
* ast_complete_source_filename

This also removes the mtx_prof static variable that was declared when
MTX_PROFILE was enabled.  This variable was only used in lock.c so it
is now initialized in that file only.

ASTERISK-26480 #close

Change-Id: I1074af07d71f9e159c48ef36631aa432c86f9966
2016-10-27 09:53:55 -04:00
Matt Jordan 4a58261694 git migration: Refactor the ASTERISK_FILE_VERSION macro
Git does not support the ability to replace a token with a version
string during check-in. While it does have support for replacing a
token on clone, this is somewhat sub-optimal: the token is replaced
with the object hash, which is not particularly easy for human
consumption. What's more, in practice, the source file version was often
not terribly useful. Generally, when triaging bugs, the overall version
of Asterisk is far more useful than an individual SVN version of a file. As a
result, this patch removes Asterisk's support for showing source file
versions.

Specifically, it does the following:

* Rename ASTERISK_FILE_VERSION macro to ASTERISK_REGISTER_FILE, and
  remove passing the version in with the macro. Other facilities
  than 'core show file version' make use of the file names, such as
  setting a debug level only on a specific file. As such, the act of
  registering source files with the Asterisk core still has use. The
  macro rename now reflects the new macro purpose.

* main/asterisk:
  - Refactor the file_version structure to reflect that it no longer
    tracks a version field.
  - Remove the "core show file version" CLI command. Without the file
    version, it is no longer useful.
  - Remove the ast_file_version_find function. The file version is no
    longer tracked.
  - Rename ast_register_file_version/ast_unregister_file_version to
    ast_register_file/ast_unregister_file, respectively.

* main/manager: Remove value from the Version key of the ModuleCheck
  Action. The actual key itself has not been removed, as doing so would
  absolutely constitute a backwards incompatible change. However, since
  the file version is no longer tracked, there is no need to attempt to
  include it in the Version key.

* UPGRADE: Add notes for:
  - Modification to the ModuleCheck AMI Action
  - Removal of the "core show file version" CLI command

Change-Id: I6cf0ff280e1668bf4957dc21f32a5ff43444a40e
2015-04-13 03:48:57 -04:00
Corey Farrell c08fd275bf Logger: Convert 'struct ast_callid' to unsigned int.
Switch logger callid's from AO2 objects to simple integers.
This helps in two ways.  Copying integers is faster than
referencing AO2 objects, so this will result in a small
reduction in logger overhead.  This also erases the possibility
of an infinate loop caused by an invalid callid in
threadstorage.

ASTERISK-24833 #comment Committed callid conversion to trunk. 
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/4466/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432834 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-13 01:12:35 +00:00
Walter Doekes 37179a2b1f core: Don't allow free to mean ast_free (and malloc, etc..).
This gets rid of most old libc free/malloc/realloc and replaces them
with ast_free and friends. When compiling with MALLOC_DEBUG you'll
notice it when you're mistakenly using one of the libc variants. For
the legacy cases you can define WRAP_LIBC_MALLOC before including
asterisk.h.

Even better would be if the errors were also enabled when compiling
without MALLOC_DEBUG, but that's a slightly more invasive header
file change.

Those compiling addons/format_mp3 will need to rerun
./contrib/scripts/get_mp3_source.sh.

ASTERISK-24348 #related
Review: https://reviewboard.asterisk.org/r/4015/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@423978 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-09-26 14:41:38 +00:00
Corey Farrell 8da7f0248f autoservice: stop thread on graceful shutdown
This change adds thread shutdown to autoservice for graceful shutdowns only.
ast_register_cleanup is backported to 1.8 to allow this.  The logger callid
is also released on shutdown in 11+.

ASTERISK-23827 #close
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/3594/
........

Merged revisions 415463 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 415464 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 415465 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@415466 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-06-09 03:50:45 +00:00
Corey Farrell c87f8a599b autoservice: fix reference leak of logger callid.
autoservice acquires a local reference to the logger callid of each channel
in a loop.  This local reference was not released, causing the callid of
every channel in autoservice to leak.  This change moves the callid unref
inside the loop.

ASTERISK-23616 #close
Reported by: ibercom
........

Merged revisions 412305 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 412306 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@412307 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-04-14 15:54:50 +00:00
Walter Doekes e744fa5f5b Don't leak frames when memory is full in autoservice_run.
Review: https://reviewboard.asterisk.org/r/2566/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396505 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-09 20:29:09 +00:00
Kevin Harwell 71bce17720 Stopped spamming of debug messages during attended transfer.
While autoservice is running and servicing a channel the callid is being stored
and removed in the thread's local storage for each iteration of the thread loop.
If debug was set to a sufficient level the log file would be spammed with callid
thread local storage debug messages.

Added a new function that checks to see if the callid to be stored is different
than what is already contained (if anything).  If it is different then
store/replace and log, otherwise just leave as is.  Also made it so all logging
of debug messages pertaining to the callid thread storage outputs only when
TEST_FRAMEWORK is defined.

(issue ASTERISK-21014)
(closes issue ASTERISK-21014)
Report by: Rusty Newton
Review: https://reviewboard.asterisk.org/r/2324/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@381557 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-02-15 17:38:22 +00:00
Richard Mudgett ac35b92b62 Hangup handlers - Dialplan subroutines that run when the channel hangs up.
Hangup handlers are an alternative to the h extension.  They can be used
in addition to the h extension.  The idea is to attach a Gosub routine to
a channel that will execute when the call hangs up.  Whereas which h
extension gets executed depends on the location of dialplan execution when
the call hangs up, hangup handlers are attached to the call channel.  You
can attach multiple handlers that will execute in the order of most
recently added first.

(closes issue ASTERISK-19549)
Reported by: Mark Murawski
Tested by: rmudgett

Review: https://reviewboard.asterisk.org/r/2002/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@369493 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-06-29 17:02:32 +00:00
Jonathan Rose 5eb94d7ebb Unique Call ID logging Phases III and IV
Adds call ID logging changes to specific channel drivers that weren't handled
handled in phase II of Call ID Logging. Also covers logging for threads for
threads created by systems that may be involved with many different calls.
Extra special thanks to Richard for rigorous review of chan_dahdi and its
various signalling modules.

review: https://reviewboard.asterisk.org/r/1927/
review: https://reviewboard.asterisk.org/r/1950/



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@369414 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-06-26 21:45:22 +00:00
Kevin P. Fleming 166b4e2b30 Multiple revisions 369001-369002
........
  r369001 | kpfleming | 2012-06-15 10:56:08 -0500 (Fri, 15 Jun 2012) | 11 lines
  
  Add support-level indications to many more source files.
  
  Since we now have tools that scan through the source tree looking for files
  with specific support levels, we need to ensure that every file that is
  a component of a 'core' or 'extended' module (or the main Asterisk binary)
  is explicitly marked with its support level. This patch adds support-level
  indications to many more source files in tree, but avoids adding them to
  third-party libraries that are included in the tree and to source files
  that don't end up involved in Asterisk itself.
........
  r369002 | kpfleming | 2012-06-15 10:57:14 -0500 (Fri, 15 Jun 2012) | 3 lines
  
  Add a script to enable finding source files without support-levels defined.
........

Merged revisions 369001-369002 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 369005 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@369013 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-06-15 16:20:16 +00:00
Kinsey Moore c5b3db1956 Kill off red blobs in most of main/*
Everything still compiled after making these changes, so I assume these
whitespace-only changes didn't break anything (and shouldn't have).


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@360190 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-03-22 19:51:16 +00:00
Terry Wilson 786f5898d1 Finalize ast_channel opaquification
Review: https://reviewboard.asterisk.org/r/1786/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@358907 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-03-13 18:20:34 +00:00
Terry Wilson 0e5c761c28 Opaquify ast_channel typedefs, fd arrays, and softhangup flag
Review: https://reviewboard.asterisk.org/r/1784/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@357721 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-03-01 22:09:18 +00:00
Tilghman Lesher ef95349d1c Merged revisions 278167 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r278167 | tilghman | 2010-07-20 15:59:06 -0500 (Tue, 20 Jul 2010) | 4 lines
  
  Do not queue up DTMF frames while a call is on hold.
  
  (Fixes ABE-2110)
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@278272 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-07-20 22:26:23 +00:00
Tilghman Lesher d31612410d Merged revisions 273717 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r273717 | tilghman | 2010-07-02 12:09:47 -0500 (Fri, 02 Jul 2010) | 8 lines
  
  Autoservice loop optimization causes a busy loop, when channels are serviced while in hangup.
  
  (closes issue #17564)
   Reported by: ramonpeek
   Patches: 
         20100630__issue17564.diff.txt uploaded by tilghman (license 14)
   Tested by: ramonpeek
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@273718 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-07-02 17:10:59 +00:00
Mark Michelson 73e8c7572e Merged revisions 264996 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r264996 | mmichelson | 2010-05-21 11:28:34 -0500 (Fri, 21 May 2010) | 32 lines
  
  Allow ast_safe_sleep to defer specific frames until after the sleep has concluded.
  
  From reviewboard
  
  Background:
  A Digium customer discovered a somewhat odd bug. The setup is that parties A
  and B are bridged, and party A places party B on hold. While party B is 
  listening to hold music, he mashes a bunch of DTMF. Party A takes party
  B off hold while this is happening, but party B continues to hear hold
  music. I could reproduce this about 1 in 5 times.
  
  The issue:
  When DTMF features are enabled and a user presses keys, the channel that
  the DTMF is streamed to is placed in an ast_safe_sleep for 100 ms, the
  duration of the emulated tone. If an AST_CONTROL_UNHOLD frame is read
  from the channel during the sleep, the frame is dropped. Thus the
  unhold indication is never made to the channel that was originally placed
  on hold.
  
  The fix:
  Originally, I discussed with Kevin possible ways of fixing the specific
  problem reported. However, we determined that the same type of problem
  could happen in other situations where ast_safe_sleep() is used. Using
  autoservice as a model, I modified ast_safe_sleep_conditional() to
  defer specific frame types so they can be re-queued once the sleep has
  finished. I made a common function for determining if a frame should
  be deferred so that there are not two identical switch blocks to
  maintain.
  
  Review: https://reviewboard.asterisk.org/r/674/
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@264997 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-05-21 16:44:27 +00:00
Tilghman Lesher d8e0c58437 Expand codec bitfield from 32 bits to 64 bits.
Reviewboard: https://reviewboard.asterisk.org/r/416/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@227580 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-11-04 14:05:12 +00:00
Russell Bryant 72934ead4b Merged revisions 223485-223486 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r223485 | russell | 2009-10-11 12:22:52 -0500 (Sun, 11 Oct 2009) | 6 lines
  
  Don't use data outside of its scope.
  
  The purpose of this code was to have a hangup frame put on the list of deferred
  frames.  However, the code that read the hangup frame was outside of the scope
  of where the hangup frame was declared.
........
  r223486 | russell | 2009-10-11 12:25:06 -0500 (Sun, 11 Oct 2009) | 2 lines
  
  Remove some unnecessary code.
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@223487 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-10-11 17:25:42 +00:00
Kevin P. Fleming 4c0265664e Merged revisions 200991 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r200991 | kpfleming | 2009-06-16 12:05:38 -0500 (Tue, 16 Jun 2009) | 11 lines
  
  Improve support for media paths that can generate multiple frames at once.
  
  There are various media paths in Asterisk (codec translators and UDPTL, primarily)
  that can generate more than one frame to be generated when the application calling
  them expects only a single frame. This patch addresses a number of those cases,
  at least the primary ones to solve the known problems. In addition it removes the
  broken TRACE_FRAMES support, fixes a number of bugs in various frame-related API
  functions, and cleans up various code paths affected by these changes.
  
  https://reviewboard.asterisk.org/r/175/
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@201056 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-06-16 18:54:30 +00:00
Russell Bryant 7fcac067b2 Merged revisions 163448 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r163448 | russell | 2008-12-12 07:44:08 -0600 (Fri, 12 Dec 2008) | 26 lines

Resolve issues that could cause DTMF to be processed out of order.

These changes come from team/russell/issue_12658

1) Change autoservice to put digits on the head of the channel's frame readq 
   instead of the tail.  If there were frames on the readq that autoservice 
   had not yet read, the previous code would have resulted in out of order 
   processing.  This required a new API call to queue a frame to the head 
   of the queue instead of the tail.

2) Change up the processing of DTMF in ast_read().  Some of the problems 
   were the result of having two sources of pending DTMF frames.  There 
   was the dtmfq and the more generic readq.  Both were used for pending 
   DTMF in various scenarios.  Simplifying things to only use the frame 
   readq avoids some of the problems.

3) Fix a bug where a DTMF END frame could get passed through when it 
   shouldn't have.  If code set END_DTMF_ONLY in the middle of digit emulation,
   and a digit arrived before emulation was complete, digits would get 
   processed out of order.

(closes issue #12658)
Reported by: dimas
Tested by: russell, file
Review: http://reviewboard.digium.com/r/85/

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@163449 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-12-12 13:55:30 +00:00
Russell Bryant 1f1dc4a0dc Merged revisions 138027 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r138027 | russell | 2008-08-15 10:07:16 -0500 (Fri, 15 Aug 2008) | 9 lines

Ensure that when a hangup occurs in autoservice, that a hangup frame gets
properly deferred to be read from the channel owner when it gets taken out
of autoservice.

(closes issue #12874)
Reported by: dimas
Patches: 
      v1-12874.patch uploaded by dimas (license 88)

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@138028 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-08-15 15:09:46 +00:00
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