<div dir="ltr"><div>ok, thanks! I missed that nuance.<br><br></div>-- vyzo<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 26, 2018 at 3:34 PM, Marc Feeley <span dir="ltr"><<a href="mailto:feeley@iro.umontreal.ca" target="_blank">feeley@iro.umontreal.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The ___release_rc_tls_context function is passed to ___NONNULLPOINTER_to_SCMOBJ to build the foreign obj (scm_ctx) that is returned to Scheme:<br>
<br>
  if ((scm_e =___NONNULLPOINTER_to_SCMOBJ<br>
               (___PSTATE,<br>
                ___CAST(void*,c),<br>
                ___FAL,<br>
                ___release_rc_tls_context,<br>
                &scm_ctx,<br>
                ___RETURN_POS)) != ___FIX(___NO_ERR))<br>
    {<br>
      ___release_rc_tls_context (c);<br>
      return scm_e;<br>
    }<br>
<br>
So the ___release_rc_tls_context function will be called when the foreign object is reclaimed by the GC.<br>
<span class="HOEnZb"><font color="#888888"><br>
Marc<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
<br>
> On Mar 26, 2018, at 3:47 AM, Dimitris Vyzovitis <<a href="mailto:vyzo@hackzen.org">vyzo@hackzen.org</a>> wrote:<br>
><br>
> Wrt question 2, experiments suggest that the tls context can be safely reused.<br>
><br>
> -- vyzo<br>
><br>
> On Mon, Mar 26, 2018 at 10:38 AM, Dimitris Vyzovitis <<a href="mailto:vyzo@hackzen.org">vyzo@hackzen.org</a>> wrote:<br>
> Marc,<br>
><br>
> Post refcount release bug, I've been looking more closely into the implementation of tls contexts, and I have a couple of questions<br>
><br>
> 1. The tls context contains internally allocated data, that is released immediately with ___release_rc_tls_context in failure paths of ___os_make_tls_context.<br>
>     However, I am not convinced it gets cleaned up when the tls context is reclaimed by the gc.<br>
>     Is there a finalizer for tls contexts or do we leak that internal memory?<br>
><br>
> 2. Is there a need to make a tls context per socket or can the tls context be reused and shared among many (concurrent) sockets?<br>
>     Currently I make a new context every time I make an https request, but it would be very nice if a single context could be<br>
>     reused.<br>
><br>
> -- vyzo<br>
><br>
<br>
</div></div></blockquote></div><br></div>