[Asterisk-code-review] scheduler: Use stack for allocating sched IDs. (asterisk[11])

Mark Michelson asteriskteam at digium.com
Tue Sep 15 11:10:55 CDT 2015


Mark Michelson has uploaded a new patch set (#2).

Change subject: scheduler: Use stack for allocating sched IDs.
......................................................................

scheduler: Use stack 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 stack of available IDs is maintained.
When assigning a new ID, an ID is pulled from the stack. When a
scheduler item is released, its ID is pushed back onto the stack. 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
---
M main/sched.c
1 file changed, 147 insertions(+), 37 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/58/1258/2
-- 
To view, visit https://gerrit.asterisk.org/1258
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I532708eef8f669d823457d7fefdad9a6078b99b2
Gerrit-PatchSet: 2
Gerrit-Project: asterisk
Gerrit-Branch: 11
Gerrit-Owner: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>



More information about the asterisk-code-review mailing list