<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    See ./erts/emulator/beam/io.c<br>
    erts_port_control() calls erts_refc_inc() if original binary should
    be used.<br>
    Then the pointer to binary is kept in sigdp->u.control.binp.<br>
    When the data is not needed any more, cleanup_scheduled_control() is
    called. It calls erts_refc_dectest() if original binary is used.<br>
    <br>
    <div class="moz-cite-prefix">On 12/09/2016 06:02 PM, Frank Muller
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAFA6GnCqPepHdhUX-m8=2U=z+JNOixS=_0B5zpwBzCYFJYJrgA@mail.gmail.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <div>Which code is responsible of incr/decr binary refcount?</div>
      <div><br>
      </div>
      <div><br>
        <div class="gmail_quote">
          <div>Le ven. 9 déc. 2016 à 16:01, Salikhov Dinislam <<a
              moz-do-not-send="true"
              href="mailto:Dinislam.Salikhov@kaspersky.com"><a class="moz-txt-link-abbreviated" href="mailto:Dinislam.Salikhov@kaspersky.com">Dinislam.Salikhov@kaspersky.com</a></a>>
            a écrit :<br>
          </div>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">Finally,
            I've figured it out:<br class="gmail_msg">
            <br>
            bufp either contains a copy of data passed to port as binary
            or points<br class="gmail_msg">
            <br>
            to the data inside the passed binary.<br class="gmail_msg">
            <br>
            In the latter case refcount of the binary is incremented and
            the pointer<br class="gmail_msg">
            <br>
            to binary is kept in binp field, so the buffer in use
            wouldn't be<br class="gmail_msg">
            <br>
            garbage collected.<br class="gmail_msg">
            <br>
            <br class="gmail_msg">
            <br>
            Salikhov Dinislam<br class="gmail_msg">
            <br>
            <br class="gmail_msg">
            <br>
            On 12/09/2016 04:19 PM, Salikhov Dinislam wrote:<br
              class="gmail_msg">
            <br>
            > Hello!<br class="gmail_msg">
            <br>
            ><br class="gmail_msg">
            <br>
            > I'm looking through VM sources now.<br
              class="gmail_msg">
            <br>
            > In erts/emulator/beam/erl_port.h there is a 'struct<br
              class="gmail_msg">
            <br>
            > ErtsProc2PortSigData_' with a union as the last field.<br
              class="gmail_msg">
            <br>
            > One of the values of this union is 'struct control'.<br
              class="gmail_msg">
            <br>
            > I'm interesting in the field binp of the struct
            control.<br class="gmail_msg">
            <br>
            ><br class="gmail_msg">
            <br>
            > I grepped through the sources and found that the struct
            is used only<br class="gmail_msg">
            <br>
            > in a few places in erts/emulator/beam/io.c<br
              class="gmail_msg">
            <br>
            > Except the places where the field is set, it's used
            only as an<br class="gmail_msg">
            <br>
            > argument of cleanup_scheduled_control() in the same
            file.<br class="gmail_msg">
            <br>
            > So what's the meaning of the field binp? What is it
            needed for?<br class="gmail_msg">
            <br>
            ><br class="gmail_msg">
            <br>
            > Salikhov Dinislam<br class="gmail_msg">
            <br>
            <br class="gmail_msg">
            <br>
            _______________________________________________<br
              class="gmail_msg">
            <br>
            erlang-questions mailing list<br class="gmail_msg">
            <br>
            <a moz-do-not-send="true"
              href="mailto:erlang-questions@erlang.org"
              class="gmail_msg" target="_blank">erlang-questions@erlang.org</a><br
              class="gmail_msg">
            <br>
            <a moz-do-not-send="true"
              href="http://erlang.org/mailman/listinfo/erlang-questions"
              rel="noreferrer" class="gmail_msg" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br
              class="gmail_msg">
            <br>
          </blockquote>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>