[erlang-questions] erts_port_control() and binp
Salikhov Dinislam
Dinislam.Salikhov@REDACTED
Fri Dec 9 16:14:40 CET 2016
See ./erts/emulator/beam/io.c
erts_port_control() calls erts_refc_inc() if original binary should be used.
Then the pointer to binary is kept in sigdp->u.control.binp.
When the data is not needed any more, cleanup_scheduled_control() is
called. It calls erts_refc_dectest() if original binary is used.
On 12/09/2016 06:02 PM, Frank Muller wrote:
> Which code is responsible of incr/decr binary refcount?
>
>
> Le ven. 9 déc. 2016 à 16:01, Salikhov Dinislam
> <Dinislam.Salikhov@REDACTED
> <mailto:Dinislam.Salikhov@REDACTED>> a écrit :
>
> Finally, I've figured it out:
>
> bufp either contains a copy of data passed to port as binary or points
>
> to the data inside the passed binary.
>
> In the latter case refcount of the binary is incremented and the
> pointer
>
> to binary is kept in binp field, so the buffer in use wouldn't be
>
> garbage collected.
>
>
>
> Salikhov Dinislam
>
>
>
> On 12/09/2016 04:19 PM, Salikhov Dinislam wrote:
>
> > Hello!
>
> >
>
> > I'm looking through VM sources now.
>
> > In erts/emulator/beam/erl_port.h there is a 'struct
>
> > ErtsProc2PortSigData_' with a union as the last field.
>
> > One of the values of this union is 'struct control'.
>
> > I'm interesting in the field binp of the struct control.
>
> >
>
> > I grepped through the sources and found that the struct is used only
>
> > in a few places in erts/emulator/beam/io.c
>
> > Except the places where the field is set, it's used only as an
>
> > argument of cleanup_scheduled_control() in the same file.
>
> > So what's the meaning of the field binp? What is it needed for?
>
> >
>
> > Salikhov Dinislam
>
>
>
> _______________________________________________
>
> erlang-questions mailing list
>
> erlang-questions@REDACTED <mailto:erlang-questions@REDACTED>
>
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20161209/797fb410/attachment.htm>
More information about the erlang-questions
mailing list