summaryrefslogtreecommitdiff
path: root/main/autoservice.c
AgeCommit message (Collapse)Author
2008-05-13Merged revisions 115990 via svnmerge from Russell Bryant
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-04-17Merged revisions 114230 via svnmerge from Russell Bryant
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-03-20Merged revisions 110395 via svnmerge from Russell Bryant
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-03Merged revisions 105565 via svnmerge from Russell Bryant
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-033) In addition to merging the changes below, change trunk back to a regularRussell Bryant
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-02-29Merged revisions 105409 via svnmerge from Russell Bryant
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-01-08Merged revisions 97194 via svnmerge from Tilghman Lesher
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
2007-12-26Merged revisions 94801 via svnmerge from Russell Bryant
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-26Merged revisions 94797 via svnmerge from Russell Bryant
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-26Merged revisions 94790 via svnmerge from Russell Bryant
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-07Merged revisions 91777 via svnmerge from Russell Bryant
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-07Merged revisions 91737 via svnmerge from Mark Michelson
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-02Merged revisions 90432 via svnmerge from Tilghman Lesher
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-11-27Merged revisions 89886 via svnmerge from Russell Bryant
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-27Merged revisions 89790 via svnmerge from Russell Bryant
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-21remove a bunch of useless #include "options.h"Luigi Rizzo
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89511 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-19another bunch of include removals (errno.h and asterisk/logger.h)Luigi Rizzo
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89425 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-16Start untangling header inclusion in a way that does not affectLuigi Rizzo
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-08improve linked-list macros in two ways:Kevin P. Fleming
- 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-08-01Convert code that checks the _softhangup member of ast_channel directory to useRussell Bryant
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-06-12Even more minor code cleanup!Joshua Colp
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@68920 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-06-06Issue 9869 - replace malloc and memset with ast_calloc, and other coding ↵Tilghman Lesher
guidelines changes git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@67864 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-01-23Might as well go crazy here too and make the autoservice list read/write.Joshua Colp
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@51487 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-01-23Cosmetic changes. Make main source files better conform to coding guidelines ↵Joshua Colp
and standards. (issue #8679 reported by johann8384) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@51486 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-04Merged revisions 44378 via svnmerge from Kevin P. Fleming
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-08-21merge new_loader_completion branch, including (at least):Kevin P. Fleming
- 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