<p></p>
<blockquote>
<p>I have checked openssl sources, look as <code>BIO_printf</code> and <code>BIO_write</code> function to not use lock mechanism.</p>
<blockquote>
<p>The solution would be to either have a lock around and do every time: lock, open file, write, close, unlock;</p>
</blockquote>
<p>Why we cannot open the file once and use logic inside childrens</p>
<pre><code>lock, write, unlock
</code></pre>
</blockquote>
<p>You can read more on the net about opening a file before fork() and what happens after forking, etc ... In short, if you do not want to complicate the life a lot, it is not a good idea at all. Each process will have a clone of the file descriptor, with managing own states after fork ...</p>
<blockquote>
<blockquote>
<p>I also noticed that the file name is reallocated in pkg using a local variable in a function and not freed.</p>
</blockquote>
<p>is memory allocated here and not freed?</p>
<div class="highlight highlight-source-diff"><pre><span class="pl-mdr">@@ -636,6 +710,7 @@</span> int tls_h_mod_pre_init_f(void)
 #endif
        SSL_load_error_strings();
        tls_mod_preinitialized=1;
<span class="pl-mi1"><span class="pl-mi1">+</span>       prepare_keylog_file(cfg_get(tls, tls_cfg, session_keylog_filename));</span>
        return 0;
 }</pre></div>
</blockquote>
<p>I meant the <code>keylog_file</code> variable which is local to the function and then lost:</p>
<pre><code>+int prepare_keylog_file(str session_keylog_filename)
+{
+       char *keylog_file = NULL;
</code></pre>
<p>I couldn't spot where is freed.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/pull/2785#issuecomment-869505360">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABO7UZOII4LGR4YNTSC6XZTTVA2W7ANCNFSM47BQRZIA">unsubscribe</a>.<img src="https://github.com/notifications/beacon/ABO7UZIG6MG3G4PWITDVLRTTVA2W7A5CNFSM47BQRZIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOGPJZSUA.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/pull/2785#issuecomment-869505360",
"url": "https://github.com/kamailio/kamailio/pull/2785#issuecomment-869505360",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>