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.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@80362 65c4cc65-6c06-0410-ace0-fbb531ad65f3
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)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@80183 65c4cc65-6c06-0410-ace0-fbb531ad65f3
ast_read to return NULL in the case that the channel has been hung up.
(crash reported by anonymouz666 on IRC in #asterisk-dev)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@79912 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Caused by fix for issue 9938.
I basically took the code that existed before 9938 was fixed, and
copied it into a new function - ast_unescape_semicolon
There should be very few places this will be needed (pbx_config
does NOT need this (see issue 9938 for details))
Issue 10430, patch by me, with help/ideas from murf (thanks murf).
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@79904 65c4cc65-6c06-0410-ace0-fbb531ad65f3
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)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@79857 65c4cc65-6c06-0410-ace0-fbb531ad65f3
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)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@79756 65c4cc65-6c06-0410-ace0-fbb531ad65f3
ringinuse=no for the queue.
(closes issue #10215, reported by Doug, repaired by me)
Special thanks to fkasumovic for pointing out the source of the problem and to bweschke for helping to come up with a solution!
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@79748 65c4cc65-6c06-0410-ace0-fbb531ad65f3
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.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@79523 65c4cc65-6c06-0410-ace0-fbb531ad65f3
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.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@79272 65c4cc65-6c06-0410-ace0-fbb531ad65f3
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.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@79214 65c4cc65-6c06-0410-ace0-fbb531ad65f3
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.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@79174 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Now matches are made on both the IP address and port number, or if the insecure setting is set to "port" then just match on the
IP address.
In order to accomplish this, I also added a new API call, ast_category_root, which returns the first variable of an ast_category struct
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@78103 65c4cc65-6c06-0410-ace0-fbb531ad65f3
will just return immediately. Also, fix some logic so the thread's lock
isn't unlocked twice in the weird case of dynamic threads getting acquired
right after a timeout.
(pointed out by SteveK)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@78028 65c4cc65-6c06-0410-ace0-fbb531ad65f3
during the first time it runs. This shouldn't ever happen, but we should
account for it anyway.
(pointed out by pete, who works with mihai)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@77949 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Also rearrange messages to better fit with what a wireshark trace shows it should be.
Issue 10299, initial patch and solution by sbisker, modified by me to fit with wireshark trace.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@77947 65c4cc65-6c06-0410-ace0-fbb531ad65f3
thread timed out waiting for something to do, but was acquired to perform an
action immediately afterwords, then wait on the condition again to give the
other thread a chance to finish setting up the data for what action this thread
should perform. Otherwise, if it immediately continues, it will perform the
wrong action.
(reported on IRC by mihai, patch by me)
(related to issue #10289)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@77943 65c4cc65-6c06-0410-ace0-fbb531ad65f3
The most notable problem is that people have been seeing storms of VNAK frames
being sent due to really old frames mysteriously being in the retransmission
queue and never getting removed.
It was possible that a dynamic thread got created, but did not acquire its lock
before the thread that created it signals it to perform an action. When this
happens, the thread will sleep until it hits a timeout, and then get destroyed.
So, the action never gets performed and in some cases, means a frame doesn't
get transmitted and never gets freed since the scheduler never gets a chance
to reschedule transmission.
Another less severe race condition is in the handling of a timeout for a dynamic
thread. It was possible for it to be acquired to perform at action at the same
time that it hit a timeout. When this occurs, whatever action it was acquired
for would never get performed.
(patch contributed by Mihai and SteveK)
(closes issue #10289)
(closes issue #10248)
(closes issue #10232)
(possibly related to issue #10359)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@77887 65c4cc65-6c06-0410-ace0-fbb531ad65f3
due to sending packets in the wrong order during hangup.
Also make sure we clear tones/messages on the correct line/instance.
Issue 10291, patch by DEA, tested by sbisker and myself.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@77883 65c4cc65-6c06-0410-ace0-fbb531ad65f3
servers between endpoints, the Asterisk servers will not keep retransmitting the re-invites.
(closes issue #10274, reported by cstadlmann, patched by me with approval from file)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@77824 65c4cc65-6c06-0410-ace0-fbb531ad65f3
queue. In the network_thread() loop, it traverses the list using the
AST_LIST_TRAVERSE_SAFE macro. However, to remove an element of the list within
this loop, it used AST_LIST_REMOVE, instead of AST_LIST_REMOVE_CURRENT, which I
believe could leave some of the internal variables of the SAFE macro invalid.
Mihai says that he already made this change in his local copy and it didn't help
his VNAK storm issues, but I still think it's wrong. :)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@77794 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Reported by: julianjm
Patches:
chan_sip_device_state_hold_fix.v1.diff.txt uploaded by julianjm (license 99)
Clear ONHOLD flag when decrementing the onHold peer count. If we did not do this the count may keep decreasing.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@77536 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Reported by: mvanbaak
Patches:
chan_skinny_openbsd.diff uploaded by mvanbaak (license 7)
Add another OS that has to use the Macros for byte ordering.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@76519 65c4cc65-6c06-0410-ace0-fbb531ad65f3
the network. Using an unsigned value here made it impossible to handle an
error returned from recvfrom(). Furthermore, in the case that recvfrom()
did return an error, this would cause a crash due to a heap overflow.
(closes issue #10265, reported by and fix suggested by timrobbins)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@76485 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Cancel ringing if endpoint hangs up before answering.
Fixes were backported from trunk (there was apparently a bit of confusion during merge of a previous patch).
(closes issue #10241)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@76178 65c4cc65-6c06-0410-ace0-fbb531ad65f3
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r75927 | russell | 2007-07-19 10:49:42 -0500 (Thu, 19 Jul 2007) | 6 lines
When processing full frames, take sequence number wraparound into account when
deciding whether or not we need to request retransmissions by sending a VNAK.
This code could cause VNAKs to be sent erroneously in some cases, and to not
be sent in other cases when it should have been.
(closes issue #10237, reported and patched by mihai)
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@75928 65c4cc65-6c06-0410-ace0-fbb531ad65f3
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r75757 | russell | 2007-07-18 16:09:13 -0500 (Wed, 18 Jul 2007) | 5 lines
When traversing the queue of frames for possible retransmission after
receiving a VNAK, handle sequence number wraparound so that all frames that
should be retransmitted actually do get retransmitted.
(issue #10227, reported and patched by mihai)
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@75759 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Reported by: elandivar
It is possible for hold status to exist without call limits set, so we need to ensure update_call_counter is executed regardless.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@75621 65c4cc65-6c06-0410-ace0-fbb531ad65f3
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r75444 | russell | 2007-07-17 15:45:27 -0500 (Tue, 17 Jul 2007) | 5 lines
Ensure that when encoding the contents of an ast_frame into an iax_frame, that
the size of the destination buffer is known in the iax_frame so that code
won't write past the end of the allocated buffer when sending outgoing frames.
(ASA-2007-014)
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@75445 65c4cc65-6c06-0410-ace0-fbb531ad65f3
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r75052 | russell | 2007-07-13 14:10:00 -0500 (Fri, 13 Jul 2007) | 12 lines
(closes issue #9660)
Reported by: mmacvicar
Patches submitted by: bbryant, russell
Tested by: mmacvicar, marco, arcivanov, jmhunter, explidous
When using a TDM400P (and probably other analog cards) there was a chance that
you could hang up and pick the phone back up where it has been long enough to
be not considered a flash hook, but too soon such that the device reports that
it is busy and the person on the phone will only hear silence. This patch
makes chan_zap more tolerant of this and gives the device a couple of seconds
to succeed so the person on the phone happily gets their dialtone.
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@75053 65c4cc65-6c06-0410-ace0-fbb531ad65f3
since loginstart is used after logoff. Thanks to makoto for pointing this out and suggesting the fix.
(closes issue #10178, reported and patched by makoto, with modification by me)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@74998 65c4cc65-6c06-0410-ace0-fbb531ad65f3
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r74766 | russell | 2007-07-11 17:53:26 -0500 (Wed, 11 Jul 2007) | 5 lines
The function make_trunk() can fail and return -1 instead of a valid new call
number. Fix the uses of this function to handle this instead of treating it
as the new call number. This would cause a deadlock and memory corruption.
(possible cause of issue #9614 and others, patch by me)
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@74767 65c4cc65-6c06-0410-ace0-fbb531ad65f3
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r74158 | qwell | 2007-07-09 15:18:15 -0500 (Mon, 09 Jul 2007) | 8 lines
Several chan_zap options were not working on reload because they were arbitrarily
disallowed when reloading some/most PRI options (such as signalling) was disallowed.
Options such as polarityonanswerdelay and answeronpolarityswitch can safely be changed on a reload.
This corrects that behavior.
Issue 9186, patch by tzafrir.
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@74159 65c4cc65-6c06-0410-ace0-fbb531ad65f3
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r73678 | russell | 2007-07-06 10:55:41 -0500 (Fri, 06 Jul 2007) | 7 lines
(closes issue #10125)
Reported by: makoto
Patches submitted by: makoto
This fixes a crash in chan_sip that happens when the bindaddr setting is not
valid on Asterisk startup, gets fixed, and then a reload gets issued.
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@73679 65c4cc65-6c06-0410-ace0-fbb531ad65f3
set to ease debugging
* When deferring a full frame for processing, stick it into the queue for the
thread that is processing frames for that call, not the one that read the
current frame and is about to go back into the idle list
(related to issue #9937)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@73551 65c4cc65-6c06-0410-ace0-fbb531ad65f3