]> git.ipfire.org Git - thirdparty/asterisk.git/commit
CDR: Alter destruction pattern for CDR chains. 53/4153/1
authorMark Michelson <mmichelson@digium.com>
Tue, 18 Oct 2016 21:30:17 +0000 (16:30 -0500)
committerMark Michelson <mmichelson@digium.com>
Tue, 18 Oct 2016 22:14:43 +0000 (17:14 -0500)
commitf14ef51ead823103d55923ca8003c4a533c4191e
tree163c18b915fab283ace449b3460931bfd7123fc4
parent193a94a60fbee4d1920a806da883321a6dd6e056
CDR: Alter destruction pattern for CDR chains.

CDRs form chains. When the root of the chain is destroyed, it then
unreferences the next CDR in the chain. That CDR is destroyed, and it
then unreferences the next CDR in the chain. This repeats until the end
of the chain is reached. While this typically does not cause any sort of
problems, it is possible in strange scenarios for the CDR chain to grow
way longer than expected. In such a scenario, the destruction pattern
can result in a stack overflow.

This patch fixes the problem by switching from a recursive pattern to an
iterative pattern for destruction. When the root CDR is destroyed, it is
responsible for iterating over the rest of the CDRs and unreferencing
each one. Other CDRs in the chain, since they are not the root, will
simply destroy themselves and be done. This causes the stack depth not
to increase.

ASTERISK-26421 #close
Reported by Andrew Nagy

Change-Id: I3ca90c2b8051f3b7ead2e0e43f60d2c18fb204b8
main/cdr.c