Discussion:
Continuation suicide allowed?
Walt Karas
2018-11-13 01:38:34 UTC
Permalink
Is it safe to call TSContDestroy() from within the continuation's
function? Does it matter whether or not the continuation has a mutex?
Alan Carroll
2018-11-13 14:38:47 UTC
Permalink
It is generally required, actually. What else will clean it up? It's safer
with a mutex because then there's no race. But if you know for other
reasons the scope of access is limited it can be safe. Usually this is
done with either a transaction based Continuation destroyed in TXN_CLOSE,
or a one shot that gets an events, performs an action, then destroys itself.
Post by Walt Karas
Is it safe to call TSContDestroy() from within the continuation's
function? Does it matter whether or not the continuation has a mutex?
--
*Beware the fisherman who's casting out his line in to a dried up riverbed.*
*Oh don't try to tell him 'cause he won't believe. Throw some bread to the
ducks instead.*
*It's easier that way. *- Genesis : Duke : VI 25-28
Leif Hedstrom
2018-11-13 21:09:19 UTC
Permalink
Post by Alan Carroll
It is generally required, actually. What else will clean it up? It's safer
with a mutex because then there's no race. But if you know for other
reasons the scope of access is limited it can be safe. Usually this is
done with either a transaction based Continuation destroyed in TXN_CLOSE,
or a one shot that gets an events, performs an action, then destroys itself.
Or, perhaps a more common pattern in our remap plugins is that the configuration object holds the continuation, so you can reuse it for many transactions, and then you destroy it when the configuration is deleted.

Cheers,

— Leif
Post by Alan Carroll
Post by Walt Karas
Is it safe to call TSContDestroy() from within the continuation's
function? Does it matter whether or not the continuation has a mutex?
--
*Beware the fisherman who's casting out his line in to a dried up riverbed.*
*Oh don't try to tell him 'cause he won't believe. Throw some bread to the
ducks instead.*
*It's easier that way. *- Genesis : Duke : VI 25-28
Loading...