Mark Michelson [Mon, 27 Aug 2007 22:40:19 +0000 (22:40 +0000)]
Resolve a potential deadlock. In this case, a single queue is locked, then the queue list. In changethread(), the queue list is
locked, and then each individual queue is locked. Under the right circumstances, this could deadlock. As such, I have unlocked
the individual queue before locking the queue list, and then locked the queue back after the queue list is unlocked.
Mark Michelson [Mon, 27 Aug 2007 21:08:48 +0000 (21:08 +0000)]
DTMF begin frames should be ignored so that when an agent acks a call with the '#' key,
he doesn't cause a queue's announce file to be interrupted. Also went ahead and did the
same for the '*' key and for ending a call.
(closes issue #10528, reported by deskhack, patched by me)
Russell Bryant [Mon, 27 Aug 2007 17:27:48 +0000 (17:27 +0000)]
Add a \todo to note that this module leaks most of the memory it allocates on
unload and should be fixed (when I'm not in the middle of something else ...).
This patch fixes a few problems with music on hold.
* Fix issues with starting at the beginning of a file when it shouldn't.
* Fix the inuse counter to be decremented even if the class had not been
set to be deleted when not in use anymore
* Don't arbitrarily limit the number of MOH files to 255
Joshua Colp [Mon, 27 Aug 2007 15:01:59 +0000 (15:01 +0000)]
(closes issue #10561)
Reported by: jesselang
Patches:
chan_sip-ChannelReload-20080825.patch uploaded by jesselang (license 202)
Remove an extra \r\n to make the ChannelReload event conform with every other event.
Russell Bryant [Sat, 25 Aug 2007 17:37:39 +0000 (17:37 +0000)]
Fix some issues with the handling of the scheduler in chan_iax2. Most of the
places that scheduled items to be executed by the scheduler thread did not
signal the scheduler thread to wake up so that it could recalculate the time
until the next action. These changes will make the scheduler thread more
responsive and ensure that actions get executed as close to when intended as
possible instead of it being possible for very long delays.
An empty string is an empty callerid ... so zap it. This closes issue #10502, which was pointed out by dswartz. Thank you, and may the swartz be with you
Russell Bryant [Fri, 24 Aug 2007 21:22:50 +0000 (21:22 +0000)]
If dnsmgr is in use, and no DNS servers are available when Asterisk first
starts, then don't give up on poking peers. Allow the poke to get rescheduled
so that it will work once the dnsmgr is able to resolve the host.
(closes issue #10521, patch by jamesgolovich)
Russell Bryant [Fri, 24 Aug 2007 20:24:05 +0000 (20:24 +0000)]
Improve the debouncing logic in the DTMF detector to fix some reliability
issues. Previously, this code used a shift register of hits and non-hits.
However, if the start of the digit isn't clean, it is possible for the
leading edge detector to miss the digit. These changes replace the flawed
shift register logic and also does the debouncing on the trailing edge as well.
(closes issue #10535, many thanks to softins for the patch)
BJ Weschke [Fri, 24 Aug 2007 19:52:06 +0000 (19:52 +0000)]
A minor correction to the available logic of autofill. If a queue member is paused, they're not really "available" so don't count them as such. Somewhat related to issue #10155
Steve Murphy [Fri, 24 Aug 2007 18:52:15 +0000 (18:52 +0000)]
From a complaint by jmls, I realize that the message in cdr_disposition is unnecessary. To get failure disposition, just return -1; no use having more than one case do that.
Philippe Sultan [Fri, 24 Aug 2007 11:42:46 +0000 (11:42 +0000)]
Closes issue #10509
Googletalk calls are answered too early, which results in CDRs wrongly
stating that a call was ANSWERED when the calling party cancelled a
call before before being established.
We must not answer the call upon reception of a 'transport-accept' iq
packet, but this packet still needs to be acknowledged, otherwise the
remote peer would close the call (like in #8970).
Russell Bryant [Thu, 23 Aug 2007 20:16:41 +0000 (20:16 +0000)]
When executing a dynamic feature, don't look it up a second time by digit pattern
after we already looked it up by name. This causes broken behavior if there is
more than one feature defined with the same digit pattern.
(closes issue #10539, reported by bungalow, patch by me)
Russell Bryant [Thu, 23 Aug 2007 19:21:53 +0000 (19:21 +0000)]
Fix func_timeout to take values in floating point so 1.5 actually means
1.5 seconds instead of being rounded.
(closes issue #10540, reported by spendergrass, patch by me)
Kevin P. Fleming [Thu, 23 Aug 2007 17:08:25 +0000 (17:08 +0000)]
report the actual channel number that was unregistered, instead of assuming that the interface list consists of channels 1 through <x> with no gaps in the sequence
Russell Bryant [Thu, 23 Aug 2007 16:53:52 +0000 (16:53 +0000)]
This is a hack to maintain old behavior of chan_iax2. This ensures that if
the peers and users are being stored in a linked list, that they go in the
list in the same order that the older code used. This is necessary to maintain
the behavior of which peers and users get matched when traversing the container.
Russell Bryant [Wed, 22 Aug 2007 22:54:03 +0000 (22:54 +0000)]
Add some more documentation on iterating ao2 containers. The documentation
implies that is possible to miss an object or see an object twice while
iterating. After looking through the code and talking with mmichelson, I have
documented the exact conditions under which this can happen (which are rare and
harmless in most cases).
Russell Bryant [Wed, 22 Aug 2007 22:40:27 +0000 (22:40 +0000)]
When converting this code to use the list macros, I changed it so objects are
added to the head of a bucket instead of the tail. However, while looking over
code with mmichelson, we noticed that the algorithm used in ao2_iterator_next
requires that items are added to the tail. This wouldn't have caused any huge
problem, but it wasn't correct. It meant that if an object was added to a
container while you were iterating it, and it was added to the same bucket that
the current element is in, then the new object would be returned by
ao2_iterator_next, and any other objects in the bucket would be bypassed in
the traversal.
Russell Bryant [Wed, 22 Aug 2007 20:21:36 +0000 (20:21 +0000)]
Merge changes from team/russell/iax_refcount.
This set of changes fixes problems with the handling of iax2_user and iax2_peer
objects. It was very possible for a thread to still hold a reference to one of
these objects while a reload operation tries to delete them. The fix here is to
ensure that all references to these objects are tracked so that they can't go away
while still in use.
To accomplish this, I used the astobj2 reference counted object model. This
code has been in one of Luigi Rizzo's branches for a long time and was primarily
developed by one of his students, Marta Carbone. I wanted to go ahead and bring
this in to 1.4 because there are other problems similar to the ones fixed by these
changes, so we might as well go ahead and use the new astobj if we're going to go
through all of the work necessary to fix the problems.
As a nice side benefit of these changes, peer and user handling got more efficient.
Using astobj2 lets us not hold the container lock for peers or users nearly as long
while iterating. Also, by changing a define at the top of chan_iax2.c, the objects
will be distributed in a hash table, drastically increasing lookup speed in these
containers, which will have a very big impact on systems that have a large number of
users or peers.
The use of the hash table will be made the default in trunk. It is not the default
in 1.4 because it changes the behavior slightly. Previously, since peers and users
were stored in memory in the same order they were specified in the configuration file,
you could influence peer and user matching order based on the order they are specified
in the configuration. The hash table does not guarantee any order in the container,
so this behavior will be going away. It just means that you have to be a little
more careful ensuring that peers and users are matched explicitly and not forcing
chan_iax2 to have to guess which user is the right one based on secret, host, and
access list settings, instead of simply using the username.
If you have any questions, feel free to ask on the asterisk-dev list.
Russell Bryant [Wed, 22 Aug 2007 19:53:30 +0000 (19:53 +0000)]
Juggie in #asterisk-dev was reporting problems where fgets would return
without reading the whole line when using fastagi. When this happens,
errno was set to EINTR or EAGAIN. This patch accounts for the possibility
and lets fgets continue in that case.
Russell Bryant [Wed, 22 Aug 2007 16:21:58 +0000 (16:21 +0000)]
Honor the contents of the COPTS variable as custom target CFLAGS. Apparently
this is what openwrt does.
(reported by Brian Capouch on the asterisk-dev list, patch by me)
Russell Bryant [Tue, 21 Aug 2007 18:42:15 +0000 (18:42 +0000)]
Don't record SIP dialog history if it's not turned on. Also, put an upper
limit on how many history entires will be stored for each SIP dialog. It is
currently set to 50, but can be increased if deemed necessary.
(closes issue #10421, closes issue #10418, patches suggested by jmoldenhauer,
patches updated by me)
(Security implications documented in AST-2007-020)
Steve Murphy [Tue, 21 Aug 2007 16:36:34 +0000 (16:36 +0000)]
This patch solves problem 1 in 8126; it should not slow down the alaw codec, but should prevent signal degradation via multiple trips thru the codec. Fossil estimates the twice thru this codec will prevent fax from working. 4-6 times thru would result hearable, noticeable, voice degradation.
Mark Michelson [Mon, 20 Aug 2007 16:17:43 +0000 (16:17 +0000)]
Found a pointless ternary if. member->dynamic was set to 1 and has no opportunity to change
between then and this line, so "dynamic" will ALWAYS be output.
Tilghman Lesher [Sat, 18 Aug 2007 14:30:44 +0000 (14:30 +0000)]
Don't allocate vmu for messagecount when we could just use the stack instead (closes issue #10490)
Also, remove a useless (and leaky) SQLAllocHandle (closes issue #10480)
Russell Bryant [Fri, 17 Aug 2007 21:01:43 +0000 (21:01 +0000)]
Avoid a crash in the handling of DTMF based Caller ID. It is valid for
ast_read to return NULL in the case that the channel has been hung up.
(crash reported by anonymouz666 on IRC in #asterisk-dev)
Mark Michelson [Fri, 17 Aug 2007 19:14:05 +0000 (19:14 +0000)]
Patch allows for more seamless transition from file storage voicemail to ODBC storage voicemail.
If a retrieval of a greeting from the database fails, but the file is found on the file system, then
we go ahead an insert the greeting into the database. The result of this is that people who
switch from file storage to ODBC storage do not need to rerecord their voicemail greetings.
Russell Bryant [Fri, 17 Aug 2007 13:37:08 +0000 (13:37 +0000)]
Fix some crashes in chan_sip. This patch changes various places that add items
to the scheduler to ensure that they don't overwrite the ID of a previously
scheduled item. If there is one, it should be removed.
(closes issue #10391, closes issue #10256, probably others, patch by me)
sometimes we don't need to signal dtmf tones to asterisk, we just want them to go through as inband. Otherwise they might be generated by the other channel partner and then there is a double tone.
Russell Bryant [Thu, 16 Aug 2007 22:32:33 +0000 (22:32 +0000)]
Fix a little race condition that could cause a crash if two channels had MOH
stopped at the same time that were using a class that had been marked for
deletion when its use count hits zero.
Russell Bryant [Thu, 16 Aug 2007 22:24:25 +0000 (22:24 +0000)]
This patch fixes a bug where reloading the module with "module reload" did not
delete classes from memory that were no longer in the config. This patch fixes
that problem as well as another one. Previously, if you reloaded MOH using the
"moh reload" CLI command, which behaved differently than "module reload ...",
MOH had to be stopped on every channel and started again immediately. However,
there was no way to tell what class was being used, so they would all fall back
to the default class.
Russell Bryant [Thu, 16 Aug 2007 21:29:24 +0000 (21:29 +0000)]
Fix more deadlocks in chan_iax2 that were introduced by making frame handling
and scheduling multi-threaded. Unfortunately, we have to do some expensive
deadlock avoidance when queueing frames on to the ast_channel owner of the IAX2
pvt struct. This was already handled for regular frames, but ast_queue_hangup
and ast_queue_control were still used directly. Making these changes introduced
even more places where the IAX2 pvt struct can disappear in the context of a
function holding its lock due to calling a function that has to unlock/lock it
to avoid deadlocks. I went through and fixed all of these places to account for
this possibility.
(issue #10362, patch by me)
Philippe Sultan [Thu, 16 Aug 2007 09:37:10 +0000 (09:37 +0000)]
A fix for two critical problems detected while working with Daniel
McKeehan in issue #10184.
Upon priority change, the resource list is not NULL terminated when
moving an item to the end of the list. This makes Asterisk endlessy
loop whenever it needs to read the list. Jids with different resource and
priority values, like in Gmail's and GoogleTalk's jabber clients put
that problem in evidence.
Upon reception of a 'from' attribute with an empty resource string,
Asterisk crashes when trying to access the found->cap pointer if the
resource list for the given buddy is not empty. This situation is
perfectly valid and must be handled. The Gizmoproject's jabber client
put that problem in evidence.
Also added a few comments in the code as well as a handle for the
capabilities from Gmail's jabber client, which are stored in a caps:c tag
rather than the usual c tag.
Joshua Colp [Wed, 15 Aug 2007 14:40:23 +0000 (14:40 +0000)]
(closes issue #10440)
Reported by: irroot
(closes issue #10454)
Reported by: flo_turc
Increase maximum timestamp skew to 120. 20 was apparently far too low.
Joshua Colp [Wed, 15 Aug 2007 14:18:44 +0000 (14:18 +0000)]
(closes issue #10456)
Reported by: irroot
Patches:
sip_timeout.patch uploaded by irroot (license 52)
Change hardcoded timer value to defined value. I'm doing this in 1.4 as well so if it needs to be changed in the future this place would not have been forgotten.
Russell Bryant [Mon, 13 Aug 2007 20:18:30 +0000 (20:18 +0000)]
Release the pvt lock before calling find_peer in register_verify to avoid a
deadlock. Also, remove some unnecessary locking in auth_fail that was only done
recursively.
Russell Bryant [Mon, 13 Aug 2007 19:27:39 +0000 (19:27 +0000)]
I am fighting deadlocks in chan_iax2. I have tracked them down to a single
core issue. You can not call find_callno() while holding a pvt lock as this
function has to lock another (every) other pvt lock. Doing so can lead to a
classic deadlock. So, I am tracking down all of the code paths where this
can happen and fixing them.
The fix I committed earlier today was along the same theme. This patch fixes
some code down the path of authenticate_reply.
Russell Bryant [Mon, 13 Aug 2007 15:28:13 +0000 (15:28 +0000)]
Fix a potential deadlock in socket_process. check_provisioning can eventually
call find_callno. You can't hold a pvt lock while calling find_callno because
it goes through and locks every single one looking for a match.
Joshua Colp [Mon, 13 Aug 2007 14:18:04 +0000 (14:18 +0000)]
(closes issue #10437)
Reported by: haklin
Don't set the callerid name and number a second time on a newly created channel. ast_channel_alloc itself already sets it and setting it twice would cause a memory leak.
Russell Bryant [Fri, 10 Aug 2007 15:20:09 +0000 (15:20 +0000)]
The last set of changes that I made to "core show locks" made it not able to
track mutexes unless they were declared using AST_MUTEX_DEFINE_STATIC. Locks
initialized with ast_mutex_init() were not tracked. It should work now.
Joshua Colp [Fri, 10 Aug 2007 13:49:19 +0000 (13:49 +0000)]
(closes issue #10422)
Reported by: bhowell
Add note to sample configuration about module load order and how it can cause perfectly good queue members to be marked as invalid.
Mark Michelson [Thu, 9 Aug 2007 23:47:00 +0000 (23:47 +0000)]
Improved a bit of logic regarding comma-separated mailboxes in has_voicemail. Also added some braces to some compound if statements
since unbraced if statements scare me in general.
Mark Michelson [Thu, 9 Aug 2007 21:51:17 +0000 (21:51 +0000)]
Quite a few changes regarding IMAP storage.
1. instead of using inboxcount as the core message counting function, we use messagecount instead. This makes it possible to count messages in folders besides just INBOX and Old.
2. inboxcount and hasvoicemail now use messagecount as their means of determining return values.
3. Added a copy_message function for IMAP storage. Unfortunately I don't have the means to test it, but it seems like a pretty straightforward function.
4. Removed a #ifndef IMAP_STORAGE and matching #endif from leave_voicemail for a couple of reasons. One, we want to support copying mail to multiple IMAP boxes, and two, IMAP was
broken because a STORE macro had been moved into this section of code.
Mark Michelson [Thu, 9 Aug 2007 19:52:43 +0000 (19:52 +0000)]
I broke canreinvite...Now I'm fixing it. I put some new code in the wrong place and so I've reverted the canreinvite section to how it was and put my new code where it should be.