]> Sergey Matveev's repositories - public-inbox.git/commit
ds: guard ToClose against DESTROY side-effects
authorEric Wong <e@yhbt.net>
Sun, 12 Jan 2020 21:17:50 +0000 (21:17 +0000)
committerEric Wong <e@yhbt.net>
Mon, 13 Jan 2020 23:21:24 +0000 (23:21 +0000)
commit8f23c134b6c9bfc9f23b3eed7811082e6d33a84c
treed13b03f5846ea2c903803825cba7a9c42e419cbd
parenteb9c415ba4421cecb5157967c843dc7f8720e916
ds: guard ToClose against DESTROY side-effects

This does not affect our current code, but theoretically a
DESTROY callback could call PublicInbox::DS::close to enqueue
elements into the ToClose array.  So take a similar strategy as
we do with other queues (e.g. $nextq) by swapping references to
arrays, rather than operating on the array itself.

Since close operations are relatively rare, we can rely on
auto-vivification via "push" ops to create the array on an
as-needed basis.

Since we're in the area, clean up the PostLoopCallback
invocation to use the ternary operator rather than a confusing
(to me) combination of statements.

Finally, add a prototype to strengthen compile-time checking,
and move it in front of our only caller to make use of
the prototype.
lib/PublicInbox/DS.pm