summaryrefslogtreecommitdiff
path: root/include/asterisk/lock.h
AgeCommit message (Collapse)Author
2012-08-21Add scoped locks to Asterisk.Mark Michelson
With the SCOPED_LOCK macro, you can create a variable that locks a specific lock and unlocks the lock when the variable goes out of scope. This is useful for situations where many breaks, continues, returns, or other interruptions would require separate unlock statements. With a scoped lock, these aren't necessary. There are specializations for mutexes, read locks, write locks, ao2 locks, ao2 read locks, ao2 write locks, and channel locks. Each of these is a SCOPED_LOCK at heart though. Review: https://reviewboard.asterisk.org/r/2060 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@371582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-02-28Astobj2 locking enhancement.Richard Mudgett
Add the ability to specify what kind of locking an ao2 object has when it is allocated. The locking could be one of: MUTEX, RWLOCK, or none. New API: ao2_t_alloc_options() ao2_alloc_options() ao2_t_container_alloc_options() ao2_container_alloc_options() ao2_rdlock() ao2_wrlock() ao2_tryrdlock() ao2_trywrlock() The OBJ_NOLOCK and AO2_ITERATOR_DONTLOCK flags have a slight meaning change. They no longer mean that the object is protected by an external mechanism. They mean the lock associated with the object has already been manually obtained by one of the ao2_lock calls. This change is necessary for RWLOCK support since they are not reentrant. Also an operation on an ao2 container may require promoting a read lock to a write lock by releasing the already held read lock to re-acquire as a write lock. Replaced API calls: ao2_t_link_nolock() ao2_link_nolock() ao2_t_unlink_nolock() ao2_unlink_nolock() with the respective ao2_t_link_flags() ao2_link_flags() ao2_t_unlink_flags() ao2_unlink_flags() API calls to be more flexible and to allow an anticipated enhancement to control linking duplicate objects into a container. The changes to format.c and format_cap.c are taking advantange of the new ao2 locking options to simplify the use of the format capabilities containers. Review: https://reviewboard.asterisk.org/r/1554/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@357272 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-01-31Merged revisions 305040 via svnmerge from Tilghman Lesher
https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r305040 | tilghman | 2011-01-31 01:51:40 -0600 (Mon, 31 Jan 2011) | 2 lines Use the non-specific API aliases, to avoid a problem with building the utils directory. ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@305041 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-01-31Merged revisions 304950 via svnmerge from Tilghman Lesher
https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r304950 | tilghman | 2011-01-31 00:41:36 -0600 (Mon, 31 Jan 2011) | 18 lines Change mutex tracking so that it only consumes memory in the core mutex object when it's actually being used. This reduces the overall size of a mutex which was 3016 bytes before this back down to 216 bytes (this is on 64-bit Linux with a glibc-implemented mutex). The exactness of the numbers here may vary slightly based upon how mutexes are implemented on a platform, but the long and short of it is that prior to this commit, chan_iax2 held down 98MB of memory on a 64-bit system for nothing more than a table of 32767 locks. After this commit, the same table occupies a mere 7MB of memory. (closes issue #18194) Reported by: job Patches: 20110124__issue18194.diff.txt uploaded by tilghman (license 14) Tested by: tilghman Review: https://reviewboard.asterisk.org/r/1066 ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@304951 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-07-03Merged revisions 273793 via svnmerge from Tilghman Lesher
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r273793 | tilghman | 2010-07-02 16:36:39 -0500 (Fri, 02 Jul 2010) | 9 lines Have the DEADLOCK_AVOIDANCE macro warn when an unlock fails, to help catch potentially large software bugs. (closes issue #17407) Reported by: pdf Patches: 20100527__issue17407.diff.txt uploaded by tilghman (license 14) Review: https://reviewboard.asterisk.org/r/751/ ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@273830 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-04-22Remove ABI differences that occured when compiling with DEBUG_THREADS.Jason Parker
"Bad Things" would happen if Asterisk was compiled with DEBUG_THREADS, but a loaded module was not (or vice versa). This also immensely simplifies the lock code, since there are no longer 2 separate versions of them. Review: https://reviewboard.asterisk.org/r/508/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@258557 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-04-06Mac OS X does not support comparing a mutex to its initializer. Create a ↵Tilghman Lesher
test for this. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@256370 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-04-01Fix DEBUG_THREADS build on Darwin.Tilghman Lesher
(closes issue #16828) Reported by: oej Patches: 20100331__issue16828.diff.txt uploaded by tilghman (license 14) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@255796 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-11-09Merged revisions 228827 via svnmerge from Matthew Nicholson
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r228827 | mnicholson | 2009-11-09 08:16:03 -0600 (Mon, 09 Nov 2009) | 8 lines Perform limited bounds checking when destroying ast_mutex_t structures to make sure we don't try to use negative indices. (closes issue #15588) Reported by: zerohalo Patches: 20090820__issue15588.diff.txt uploaded by tilghman (license 14) Tested by: zerohalo ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@228858 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-10-21Finish implementaton of astobj2 OBJ_MULTIPLE, and convert ↵Kevin P. Fleming
ast_channel_iterator to use it. This patch finishes the implementation of OBJ_MULTIPLE in astobj2 (the case where multiple results need to be returned; OBJ_NODATA mode already was supported). In addition, it converts ast_channel_iterators (only the targeted versions, not the ones that iterate over all channels) to use this method. During this work, I removed the 'ao2_flags' arguments to the ast_channel_iterator constructor functions; there were no uses of that argument yet, there is only one possible flag to pass, and it made the iterators less 'opaque'. If at some point in the future someone really needs an ast_channel_iterator that does not lock the container, we can provide constructor(s) for that purpose. Review: https://reviewboard.asterisk.org/r/379/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@225244 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-09-04Fix trunk breakage.Tilghman Lesher
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@216551 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-09-04make sure canlog is set so we can compile with DEBUG_THREADS enabled on OpenBSDMichiel van Baak
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@216437 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24Convert the ast_channel data structure over to the astobj2 framework.Russell Bryant
There is a lot that could be said about this, but the patch is a big improvement for performance, stability, code maintainability, and ease of future code development. The channel list is no longer an unsorted linked list. The main container for channels is an astobj2 hash table. All of the code related to searching for channels or iterating active channels has been rewritten. Let n be the number of active channels. Iterating the channel list has gone from O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1). Searching for a channel by extension is still O(n), but uses a new method for doing so, which is more efficient. The ast_channel object is now a reference counted object. The benefits here are plentiful. Some benefits directly related to issues in the previous code include: 1) When threads other than the channel thread owning a channel wanted access to a channel, it had to hold the lock on it to ensure that it didn't go away. This is no longer a requirement. Holding a reference is sufficient. 2) There are places that now require less dealing with channel locks. 3) There are places where channel locks are held for much shorter periods of time. 4) There are places where dealing with more than one channel at a time becomes _MUCH_ easier. ChanSpy is a great example of this. Writing code in the future that deals with multiple channels will be much easier. Some additional information regarding channel locking and reference count handling can be found in channel.h, where a new section has been added that discusses some of the rules associated with it. Mark Michelson also assisted with the development of this patch. He did the conversion of ChanSpy and introduced a new API, ast_autochan, which makes it much easier to deal with holding on to a channel pointer for an extended period of time and having it get automatically updated if the channel gets masqueraded. Mark was also a huge help in the code review process. Thanks to David Vossel for his assistance with this branch, as well. David did the conversion of the DAHDIScan application by making it become a wrapper for ChanSpy internally. The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch. Review: http://reviewboard.digium.com/r/203/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-22Merged revisions 190092 via svnmerge from Tilghman Lesher
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r190092 | tilghman | 2009-04-22 16:35:03 -0500 (Wed, 22 Apr 2009) | 7 lines Detect availability of pthread_rwlock_timedwrlock() before using it. (closes issue #14930) Reported by: tilghman Patches: 20090420__bug14930.diff.txt uploaded by tilghman (license 14) Tested by: mvanbaak, tilghman ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190093 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-10Modify headers and macros, according to Russell's suggestions on the -dev listTilghman Lesher
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@187599 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-09Merged revisions 187428 via svnmerge from Tilghman Lesher
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r187428 | tilghman | 2009-04-09 13:08:20 -0500 (Thu, 09 Apr 2009) | 8 lines Race condition between ast_cli_command() and 'module unload' could cause a deadlock. Add lock timeouts to avoid this potential deadlock. (closes issue #14705) Reported by: jamessan Patches: 20090320__bug14705.diff.txt uploaded by tilghman (license 14) Tested by: jamessan ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@187483 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-27Fix some issues with rwlock corruption that caused deadlock like symptoms.Russell Bryant
When dvossel and I were doing some load testing last week, we noticed that we could make Asterisk trunk lock up instantly when we started generating a bunch of calls. The backtraces of locked threads were bizarre, and many were stuck on an _unlock_ of an rwlock. The changes are: 1) Fix a number of places where a backtrace would be loaded into an invalid index of the backtrace array. It's an off by one error, which ends up writing over the rwlock itself. 2) Ensure that in the array of held locks, we NULL out an index once it is not being used so that it's not confusing when analyzing its contents. 3) Remove a bunch of logging referring to an rwlock operating being done with "deep reentrancy". It is normal for _many_ threads to hold a read lock on an rwlock. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@184531 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-09Add Doxygen documentation for API changes from 1.6.0 to 1.6.1Jeff Peeler
Copied from my review board description: This is a continuation of the API changes documentation started for describing changes between releases. Most of the API changes were pretty simple needing only to be brought to attention via the new "Asterisk API Changes" list. However, if you see anything that needs further explanation feel free to supplement what is there. The current method of documenting is to add (in the header file): \version <ver number> <description of changes> and then to add the function to the change list in doxyref.h on the AstAPIChanges page. I also made sure all the functions that were newly added were tagged with \since 1.6.1. I think this is a good habit to start both for the historical aspect as well as for the future ability to easily add a "New Asterisk API" page. Review: http://reviewboard.digium.com/r/190/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@180719 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-11-29incorporates r159808 from branches/1.4:Kevin P. Fleming
------------------------------------------------------------------------ r159808 | kpfleming | 2008-11-29 10:58:29 -0600 (Sat, 29 Nov 2008) | 7 lines update dev-mode compiler flags to match the ones used by default on Ubuntu Intrepid, so all developers will see the same warnings and errors since this branch already had some printf format attributes, enable checking for them and tag functions that didn't have them format attributes in a consistent way ------------------------------------------------------------------------ in addition: move some format attributes from main/utils.c to the header files they belong in, and fix up references to the relevant functions based on new compiler warnings git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@159818 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-07-16(closes issue #13089)Steve Murphy
Reported by: murf Most of this bug was already fixed by Tilghman before I opened it; Many thanks to Tilghman for his fix in svn version 125794. That fix cleared up some of the fields in the lock_info. This commit changes the address that is stored for the lock in the lock_info struct, so that it is the same as that passed into the locking macros. This makes searching for a lock_info (as in log_show_lock()) by its lock addr possible. The lock_addr field is infinitely more useful if it is the same as what is 'publicly' available outside the lock_info code. Many thanks to kpfleming, putnopvut, and Russell for their invaluable insights earlier today. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@131570 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-06-30Merged revisions 126573 via svnmerge from Russell Bryant
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r126573 | russell | 2008-06-30 11:05:08 -0500 (Mon, 30 Jun 2008) | 10 lines Fix a typo in the non-DEBUG_THREADS version of the recently added DEADLOCK_AVOIDANCE() macro. This caused the lock to not actually be released, and as a result, not avoid deadlocks at all. This resolves the issues reported in the last while about Asterisk locking up all over the place (and most commonly, in chan_iax2). (closes issue #12927) (closes issue #12940) (closes issue #12925) (potentially closes others ...) ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@126574 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-06-27Document DLA_UNLOCK and DLA_LOCKTilghman Lesher
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@125895 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-06-27Optimization suggested by Russell to cache the value of pthread_self() soMark Michelson
that it isn't evaluated every time through the loop. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@125880 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-06-27Merged revisions 125793 via svnmerge from Tilghman Lesher
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r125793 | tilghman | 2008-06-27 08:45:03 -0500 (Fri, 27 Jun 2008) | 2 lines In this debugging function, copy to a buffer instead of using potentially unsafe pointers. ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@125794 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-06-25Fix indentationMark Michelson
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@125135 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-06-25Fix a bug in the rwlock tracking. ast_rwlock_unlock did not take intoMark Michelson
account that multiple threads could hold the same rdlock at the same time. As such, it expected that when a thread released a lock that it must have been the last to acquire the lock as well. Erroneous error messages would be sent to the console stating that a thread was attempting to unlock a lock it did not own. Now all threads are examined to be sure that the message is only printed when it is supposed to be printed. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@125133 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-06-25More expansion of the deadlock avoidance macro, including a macro to do lockingTilghman Lesher
of the channel lock git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@125020 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-06-25Merged revisions 124965 via svnmerge from Tilghman Lesher
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r124965 | tilghman | 2008-06-24 19:46:24 -0500 (Tue, 24 Jun 2008) | 7 lines Pvt deadlock causes some channels to get stuck in Reserved status. (closes issue #12621) Reported by: fabianoheringer Patches: 20080612__bug12621.diff.txt uploaded by Corydon76 (license 14) Tested by: fabianoheringer ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@124966 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-06-03fix build for non debug threadsRussell Bryant
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@120066 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-06-03Add lock tracking for rwlocks. Previously, lock.h only had the ability toRussell Bryant
hold tracking information for mutexes. Now, the "core show locks" output will output information about who is holding a rwlock when a thread is waiting on it. (closes issue #11279) Reported by: ys Patches: trunk_lock_utils.v8.diff uploaded by ys (license 281) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@120064 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-05-29Merged revisions 118954 via svnmerge from Tilghman Lesher
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r118954 | tilghman | 2008-05-29 12:33:01 -0500 (Thu, 29 May 2008) | 2 lines Define also when not DEBUG_THREADS ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@118957 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-05-29Merged revisions 118953 via svnmerge from Tilghman Lesher
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r118953 | tilghman | 2008-05-29 12:20:16 -0500 (Thu, 29 May 2008) | 3 lines Add some debugging code that ensures that when we do deadlock avoidance, we don't lose the information about how a lock was originally acquired. ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@118955 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-05-23Make sure not to include non-existent headers if they indeed are non-existentMark Michelson
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@118175 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-05-23A new feature thanks to the fine folks at Switchvox!Mark Michelson
If a deadlock is detected, then the typical lock information will be printed along with a backtrace of the stack for the offending threads. Use of this requires compiling with DETECT_DEADLOCKS and having glibc installed. Furthermore, issuing the "core show locks" CLI command will print the normal lock information as well as a backtraces for each lock. This requires that DEBUG_THREADS is enabled and that glibc is installed. All the backtrace features may be disabled by running the configure script with --without-execinfo as an argument git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@118173 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-05-13Merged revisions 116088 via svnmerge from Mark Michelson
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r116088 | mmichelson | 2008-05-13 18:47:49 -0500 (Tue, 13 May 2008) | 12 lines A change to the way channel locks are handled when DEBUG_CHANNEL_LOCKS is defined. After debugging a deadlock, it was noticed that when DEBUG_CHANNEL_LOCKS is enabled in menuselect, the actual origin of channel locks is obscured by the fact that all channel locks appear to happen in the function ast_channel_lock(). This code change redefines ast_channel_lock to be a macro which maps to __ast_channel_lock(), which then relays the proper file name, line number, and function name information to the core lock functions so that this information will be displayed in the case that there is some sort of locking error or core show locks is issued. ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@116089 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-16A small enhancement-- I added the routine log_show_lock to utils.c, which if ↵Steve Murphy
the mentioned lock has been acquired, this routine will log to the console the normal info about that lock you'd see from the CLI when you do a 'core show locks'. It's solely for debug-- if the lock is NOT acquired, there is no output. I use it to show 'unexpected' locks, to see where/why a lock is pre-locked. This command is to be called from points of interest, like just before a trylock, and helps to spot fleeting, highly temporal locks that normally are not locked... git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@114187 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-10Merged revisions 114051 via svnmerge from Mark Michelson
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r114051 | mmichelson | 2008-04-10 15:59:49 -0500 (Thu, 10 Apr 2008) | 3 lines Fix 1.4 build when LOW_MEMORY is enabled. ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@114052 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-02-28Merged revisions 105116 via svnmerge from Russell Bryant
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r105116 | russell | 2008-02-28 16:23:05 -0600 (Thu, 28 Feb 2008) | 8 lines Fix a bug in the lock tracking code that was discovered by mmichelson. The issue is that if the lock history array was full, then the functions to mark a lock as acquired or not would adjust the stats for whatever lock is at the end of the array, which may not be itself. So, do a sanity check to make sure that we're updating lock info for the proper lock. (This explains the bizarre stats on lock #63 in BE-396, thanks Mark!) ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@105144 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-12-14Merged revisions 92875 via svnmerge from Mark Michelson
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r92875 | mmichelson | 2007-12-13 19:24:06 -0600 (Thu, 13 Dec 2007) | 7 lines When compiling with DETECT_DEADLOCKS, don't spam the CLI with messages about possible deadlocks. Instead just print the intended single message every five seconds. (closes issue 11537, reported and patched by dimas) ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@92876 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-12-07Merged revisions 91828 via svnmerge from Russell Bryant
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r91828 | russell | 2007-12-07 15:17:24 -0600 (Fri, 07 Dec 2007) | 6 lines Fix another bug in the DEBUG_THREADS code. The ast_mutex_init() function had the mutex attribute object marked as static. This means that multiple threads initializing locks at the same time could step on each other and end up with improperly initialized locks. (found when tracking down locking issues related to issue #11080) ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@91829 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-12-07Merged revisions 91826 via svnmerge from Russell Bryant
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r91826 | russell | 2007-12-07 15:11:08 -0600 (Fri, 07 Dec 2007) | 6 lines I love fixing lock related errors in the lock debugging code. That's about as ironic as it gets in Asterisk programming land. Anyway, I spotted this bug while trying to track down why systems are locking up and acting weird in issue #11080. The mutex attribute object was marked as static in this function when it should not have been. ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@91827 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-12-05Merged revisions 91070 via svnmerge from Russell Bryant
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r91070 | russell | 2007-12-04 18:35:31 -0600 (Tue, 04 Dec 2007) | 11 lines Fix some crashes in chan_iax2 that were reported as happening on Mac systems. It turns out that the problem was the Mac version of the ast_atomic_fetchadd_int() function. The Mac atomic add function returns the _new_ value, while this function is supposed to return the old value. So, the crashes happened on unreferencing objects. If the reference count was decreased to 1, ao2_ref() thought that it had been decreased to zero, and called the destructor. However, there was still an outstanding reference around. (closes issue #11176) (closes issue #11289) ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@91114 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-29Fix build of trunkTilghman Lesher
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@90157 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-19move the declaration of struct ast_channel ast_frame and ast_moduleLuigi Rizzo
to compat.h so it is always available - hopefully this will let us reduce the number of inclusions of channel.h and frame.h git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89426 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-17Use autoconf logic to determine the presence of ↵Joshua Colp
PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP and PTHREAD_MUTEX_RECURSIVE_NP. Enclose error message from network.h in " git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89394 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-17compatibility fixes for cygwinLuigi Rizzo
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89371 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-16whitespace only change - adjust indentation and add someLuigi Rizzo
comments on the content of these two files. utils.h (which is included in over 150 files) contains a lot of unrelated functions which require the inclusion of a large number of other headers. At some point we should partition its content in a better way. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89341 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-15access channel locks through ast_channel_lock/unlock/trylock and notLuigi Rizzo
through ast_mutex primitives. To detect all occurrences, I have renamed the lock field in struct ast_channel so it is clear that it shouldn't be used directly. There are some uses in res/res_features.c (see details of the diff) that are error prone as they try and lock two channels without caring about the order (or without explaining why it is safe). git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89293 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-13This fixes a build error on my mac. It also works on my linux box. Let meRussell Bryant
know if it breaks any other platform ... git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89253 65c4cc65-6c06-0410-ace0-fbb531ad65f3