asterisk/main
Mark Michelson 0a74c80300 scheduler: Use queue for allocating sched IDs.
It has been observed that on long-running busy systems, a scheduler
context can eventually hit INT_MAX for its assigned IDs and end up
overflowing into a very low negative number. When this occurs, this can
result in odd behaviors, because a negative return is interpreted by
callers as being a failure. However, the item actually was successfully
scheduled. The result may be that a freed item remains in the scheduler,
resulting in a crash at some point in the future.

The scheduler can overflow because every time that an item is added to
the scheduler, a counter is bumped and that counter's current value is
assigned as the new item's ID.

This patch introduces a new method for assigning scheduler IDs. Instead
of assigning from a counter, a queue of available IDs is maintained.
When assigning a new ID, an ID is pulled from the queue. When a
scheduler item is released, its ID is pushed back onto the queue. This
way, IDs may be reused when they become available, and the growth of ID
numbers is directly related to concurrent activity within a scheduler
context rather than the uptime of the system.

Change-Id: I532708eef8f669d823457d7fefdad9a6078b99b2
2015-09-15 13:28:05 -05:00
..
editline main/editline: Add .gitignore. 2015-04-12 07:12:45 -04:00
stdtime git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
.gitignore Fixes for OS X 2015-06-05 11:23:16 -05:00
abstract_jb.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
acl.c Restrict functionality when ACLs are misconfigured. 2015-04-30 10:43:51 -05:00
adsi.c Allow Asterisk to compile under GCC 4.10 2014-05-09 22:49:26 +00:00
alaw.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
aoc.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
app.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
ast_expr2.c MALLOC_DEBUG: Replace WRAP_LIBC_MALLOC with ASTMM_LIBC. 2015-05-13 21:55:07 -04:00
ast_expr2.fl Git Conversion: Switch Non-C files to ASTERISK_REGISTER_FILE. 2015-04-29 01:02:10 -04:00
ast_expr2.h Allow the REALTIME() function to report errors back to the caller. 2012-07-11 17:16:50 +00:00
ast_expr2.y MALLOC_DEBUG: Replace WRAP_LIBC_MALLOC with ASTMM_LIBC. 2015-05-13 21:55:07 -04:00
ast_expr2f.c MALLOC_DEBUG: Replace WRAP_LIBC_MALLOC with ASTMM_LIBC. 2015-05-13 21:55:07 -04:00
asterisk.c media cache: Add a core API and facade for a backend agnostic media cache 2015-07-12 20:44:16 -05:00
asterisk.dynamics Fix error loading res_monitor. 2014-04-23 15:02:39 +00:00
asterisk.exports.in Add _IO_stdin_used in version-script to fix SIGBUSes on Sparc. 2013-08-22 08:26:55 +00:00
astfd.c astfd: Fix buffer overflow in DEBUG_FD_LEAKS. 2015-07-02 05:24:43 -05:00
astmm.c MALLOC_DEBUG: Replace WRAP_LIBC_MALLOC with ASTMM_LIBC. 2015-05-13 21:55:07 -04:00
astobj2.c Astobj2: Run weakproxy subscription callbacks in reverse order. 2015-05-22 17:09:47 -05:00
astobj2_container.c Astobj2: Allow reference debugging to be enabled/disabled by config. 2015-04-27 18:37:26 -04:00
astobj2_container_private.h Astobj2: Allow reference debugging to be enabled/disabled by config. 2015-04-27 18:37:26 -04:00
astobj2_hash.c Astobj2: Correctly treat hash_fn returning INT_MIN 2015-05-25 02:18:58 -05:00
astobj2_private.h Astobj2: Allow reference debugging to be enabled/disabled by config. 2015-04-27 18:37:26 -04:00
astobj2_rbtree.c Astobj2: Allow reference debugging to be enabled/disabled by config. 2015-04-27 18:37:26 -04:00
audiohook.c audiohook.c: Simplify variable usage in audiohook_read_frame_both(). 2015-08-13 17:59:18 -05:00
autochan.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
autoservice.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
backtrace.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
bridge.c bridge.c: Fixed race condition during attended transfer 2015-07-13 12:57:56 -05:00
bridge_after.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
bridge_basic.c features: Fix crash when transferee hangs up during DTMF attended transfer. 2015-05-05 18:23:38 -05:00
bridge_channel.c bridge: Kick channel from bridge if hung up during action. 2015-08-24 11:12:57 -05:00
bridge_roles.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
bucket.c media cache: Add a core API and facade for a backend agnostic media cache 2015-07-12 20:44:16 -05:00
buildinfo.c fix a few small things found by using sparse 2008-10-30 16:49:02 +00:00
callerid.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
ccss.c Detect potential forwarding loops based on count. 2015-04-17 15:58:07 -05:00
cdr.c main/cdr: Carry over the disable flag when 'disable all' is specified 2015-06-15 10:35:01 -05:00
cel.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
channel.c Add a test event for inband ringing. 2015-07-29 12:27:18 -05:00
channel_internal_api.c Channel alert pipe: improve diagnostic error return 2015-07-01 16:53:17 -05:00
chanvars.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
cli.c CLI: Cosmetic issue - core show uptime 2015-06-05 02:17:59 -05:00
codec.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
codec_builtin.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
config.c sorcery/realtime: Add a bit of debug and warning messages for bad configs 2015-07-02 07:31:56 -05:00
config_options.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
core_local.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
core_unreal.c Local channels: Alternate solution to ringback problem. 2015-07-24 09:35:17 -05:00
crypt.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
cygload.c Kill off red blobs in most of main/* 2012-03-22 19:51:16 +00:00
data.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
datastore.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
db.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
devicestate.c main/devicestate: Prevent duplicate registration of device state providers 2015-07-11 10:33:38 -05:00
dial.c Detect potential forwarding loops based on count. 2015-04-17 15:58:07 -05:00
dns.c dns_core: Allow zero-length DNS responses. 2015-07-31 09:44:20 -05:00
dns_core.c dns_core: Allow zero-length DNS responses. 2015-07-31 09:44:20 -05:00
dns_naptr.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
dns_query_set.c DNS: Fix some corner cases. 2015-06-10 18:06:15 -05:00
dns_recurring.c dns: Fix crash when invoking cancel in DNS recurring unit test. 2015-07-02 08:54:51 -03:00
dns_srv.c dns_srv: Fix SRV sorting when records with priority zero exist with non-zero. 2015-05-10 10:39:32 -03:00
dns_system_resolver.c DNS: Create a system-level DNS resolver 2015-07-07 21:31:49 -05:00
dns_test.c dns: Fix build when TEST_FRAMEWORK is not defined. 2015-04-10 13:32:24 +00:00
dns_tlsa.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
dnsmgr.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
dsp.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
ecdisa.h Kill off red blobs in most of main/* 2012-03-22 19:51:16 +00:00
endpoints.c endpoint snapshot: avoid second cleanup on alloc failure 2015-09-04 09:26:46 -05:00
enum.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
event.c Clang: change previous tautological-compare fixes. 2015-04-23 11:39:13 -05:00
features.c Remove unneeded uses of optional_api providers. 2015-05-02 19:31:12 -05:00
features_config.c Allow for transferer to retry when dialing an invalid extension. 2014-11-17 16:58:52 +00:00
file.c app_playback: Suppress warnings on playback if channel hung up 2015-05-20 19:10:49 -05:00
fixedjitterbuf.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
fixedjitterbuf.h Kill off red blobs in most of main/* 2012-03-22 19:51:16 +00:00
format.c main/format: Add an API call for retrieving format attributes 2015-08-10 12:47:56 -05:00
format_cache.c Astobj2: Allow reference debugging to be enabled/disabled by config. 2015-04-27 18:37:26 -04:00
format_cap.c main/format_cap: Parse capabilities generated by ast_format_cap_get_names 2015-07-11 16:06:13 -05:00
format_compatibility.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
frame.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
framehook.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
fskmodem.c Multiple revisions 369001-369002 2012-06-15 16:20:16 +00:00
fskmodem_float.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
fskmodem_int.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
global_datastores.c Detect potential forwarding loops based on count. 2015-04-17 15:58:07 -05:00
hashtab.c MALLOC_DEBUG: Replace WRAP_LIBC_MALLOC with ASTMM_LIBC. 2015-05-13 21:55:07 -04:00
heap.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
http.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
image.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
indications.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
io.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
jitterbuf.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
json.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
libasteriskssl.c tcptls: Avoiding ERR_remove_state in OpenSSL. 2015-05-05 11:38:54 -05:00
libasteriskssl.exports.in Address OpenSSL initialization issues when using third-party libraries. 2012-01-30 21:21:16 +00:00
loader.c ARI: Added new functionality to get information on a single module. 2015-07-13 14:29:27 -05:00
lock.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
logger.c ARI: Retrieve existing log channels 2015-08-07 14:57:45 -05:00
Makefile Replaces clock_gettime() with ast_tsnow() 2015-08-07 19:35:13 -05:00
manager.c manager: Fix build due to missing variable usage. 2015-05-06 06:32:54 -03:00
manager_bridges.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
manager_channels.c AMI: Add Linkedid to the standard channel snapshot AMI event headers. 2015-06-26 10:34:31 -05:00
manager_endpoints.c res_pjsip: Add AMI events for chan_pjsip contact lifecycle changes 2015-05-26 16:47:55 -05:00
manager_mwi.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
manager_system.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
max_forwards.c Detect potential forwarding loops based on count. 2015-04-17 15:58:07 -05:00
md5.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
media_cache.c media cache: Add CLI commands 2015-07-12 20:44:16 -05:00
media_index.c media formats: re-architect handling of media for performance improvements 2014-07-20 22:06:33 +00:00
message.c Message.c: Clear message channel frames on cleanup 2015-05-14 11:25:09 -05:00
mixmonitor.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
named_acl.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
netsock.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
netsock2.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
optional_api.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
parking.c Modules: Make ast_module_info->self available to auxiliary sources. 2015-05-04 20:47:01 -04:00
pbx.c pbx: Fix crash when issuing "core show hints" with long pattern match. 2015-09-02 12:47:51 -05:00
pickup.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
plc.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
poll.c Merged revisions 285268 via svnmerge from 2010-09-07 19:09:08 +00:00
presencestate.c AMI: Escape string values. 2015-06-08 09:44:04 -05:00
privacy.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
rtp_engine.c rtp_engine.c: Get current or create a needed rx payload type mapping. 2015-08-20 11:56:13 -05:00
say.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
sched.c scheduler: Use queue for allocating sched IDs. 2015-09-15 13:28:05 -05:00
sdp_srtp.c Merge "main/sdp_srtp.c: allow SDP crypto tag to be up to 9 digits" 2015-05-21 05:15:41 -05:00
security_events.c Clang: change previous tautological-compare fixes. 2015-04-23 11:39:13 -05:00
sem.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
sha1.c Doxygen Updates - janitor work 2012-09-21 17:14:59 +00:00
sip_api.c Don't make chan_sip export global symbols. 2012-10-11 15:49:02 +00:00
slinfactory.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
smoother.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
sorcery.c CHAOS: prevent sorcery object with null id 2015-08-17 11:03:06 -05:00
sounds_index.c Replace most uses of ast_register_atexit with ast_register_cleanup. 2015-03-26 22:24:26 +00:00
srv.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
stasis.c Stasis: Fix unsafe use of stasis_unsubscribe in modules. 2015-05-22 22:30:22 -05:00
stasis_bridges.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
stasis_cache.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
stasis_cache_pattern.c Revert "endpoint/stasis: Eliminate duplicate events on endpoint status change" 2015-05-29 14:52:41 -05:00
stasis_channels.c AMI: Escape string values. 2015-06-08 09:44:04 -05:00
stasis_endpoints.c res_pjsip: Add AMI events for chan_pjsip contact lifecycle changes 2015-05-26 16:47:55 -05:00
stasis_message.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
stasis_message_router.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
stasis_system.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
strcompat.c Add builtin roundf() for systems lacking it. 2013-01-19 20:54:07 +00:00
strings.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
stun.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
syslog.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
taskprocessor.c taskprocessor: Fix race condition between unreferencing and finding. 2015-08-29 10:44:27 -05:00
tcptls.c tcptls.c: Don't use OpenSSL functions when no SSL support is present. 2015-06-02 11:53:17 -05:00
tdd.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
term.c term: send proper reset sequence when black background is forced 2015-05-01 22:17:17 -05:00
test.c test.c: Add unit test registration checks for summary and description. 2015-06-24 17:13:31 -05:00
threadpool.c threadpool, res_pjsip: Add serializer group shutdown API calls. 2015-06-25 14:33:44 -05:00
threadstorage.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
timing.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
translate.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
udptl.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
ulaw.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
uri.c uri: Quiet warning about type qualifiers ignored on function return type 2014-08-21 14:42:12 +00:00
utils.c Core/General: Add #ifdef needed on FreeBSD. 2015-09-03 21:29:37 -05:00
uuid.c Fix printf problems with high ascii characters after r413586 (1.8). 2014-12-17 10:23:32 +00:00
xml.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00
xmldoc.c git migration: Refactor the ASTERISK_FILE_VERSION macro 2015-04-13 03:48:57 -04:00