[Tarantool-patches] [PATCH 5/7] box/error: clarify purpose of reference counting in struct error
Nikita Pettik
korablev at tarantool.org
Wed Mar 25 04:40:10 MSK 2020
On 23 Feb 18:43, Vladislav Shpilevoy wrote:
> Thanks for the patch!
>
> How about merging this commit into the previous one?
>
> On 19/02/2020 15:16, Nikita Pettik wrote:
> > ---
> > src/lib/core/diag.h | 9 +++++++++
> > 1 file changed, 9 insertions(+)
> >
> > diff --git a/src/lib/core/diag.h b/src/lib/core/diag.h
> > index 5271733cb..a9181c522 100644
> > --- a/src/lib/core/diag.h
> > +++ b/src/lib/core/diag.h
> > @@ -72,6 +72,15 @@ struct error {
> > error_f raise;
> > error_f log;
> > const struct type_info *type;
> > + /**
> > + * Reference counting is basically required since
> > + * instances of this structure are available in Lua
> > + * as well (as cdata with overloaded fields and methods
> > + * by the means of introspection). Thus, it may turn
> > + * out that Lua's GC attempts at releasing object
> > + * meanwhile it is still used in C internals or vice
> > + * versa. For details see luaT_pusherror().
>
> Hmm, no, it can't anymore.
Now it can't. But it used to, until ref in luaT_pusherror() was
introduced. So may comment refer to that quite ancient fix (I just
wondered why can't we get rid of ref counter and came up with
this explanation).
> Lua can't delete an error object,
> if it is still used in C. This looks like an artifact from the
> previous patch version, were you unreferenced all errors when
> diag was cleared.
>
> > + */
> > int refs;
> > /**
> > * Errno at the moment of the error
> >
More information about the Tarantool-patches
mailing list