[Asterisk-code-review] scheduler: Use stack for allocating sched IDs. (asterisk[certified/13.1])
Richard Mudgett
asteriskteam at digium.com
Fri Sep 11 15:14:01 CDT 2015
Richard Mudgett has posted comments on this change.
Change subject: scheduler: Use stack for allocating sched IDs.
......................................................................
Patch Set 1:
(7 comments)
https://gerrit.asterisk.org/#/c/1257/1/main/sched.c
File main/sched.c:
Line 121: size_t id_stack_size;
This can just be an int since the scheduler ids can only be 1-MAX_INT. Also size_t is an unsigned quantity and you are mixing the value with ints in comparisons elsewhere.
Line 244: ast_free(task->sched_id);
> You may want to add a comment about why this is possible.
This should be an ast_assert(task->sched_id == NULL) because there should not be any paths that don't have the pointer set to NULL when the struct is being destroyed.
Line 294: new_size = con->id_stack_size + ID_STACK_INCREMENT;
Check for overflow? This was the original reason for the patch. Though if you get an overflow with this patch you have way too many scheduled events pending.
Line 322: /*
: * Add to the cache, or just free() if we
: * already have too many cache entries
: */
This comment is now physically disassociated with the original code block that it refers.
Line 328: AST_LIST_INSERT_HEAD(&con->id_stack, tmp->sched_id, list);
Change this to AST_LIST_INSERT_TAIL() then there is less likely hood of reusing the just freed scheduler id on the next request.
Line 354: {
: tmp = ast_calloc(1, sizeof(*tmp));
: ast_cond_init(&tmp->cond, NULL);
: }
Need to test tmp for ast_calloc failure.
Line 359: if (set_sched_id(con, tmp)) {
: sched_release(con, tmp);
: }
Need to return NULL if we sched_release() tmp.
--
To view, visit https://gerrit.asterisk.org/1257
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I532708eef8f669d823457d7fefdad9a6078b99b2
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: certified/13.1
Gerrit-Owner: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
Gerrit-HasComments: Yes
More information about the asterisk-code-review
mailing list