<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Thanks to a suggestion from Florian Forster that dynamic objects are still open when fork() is called by the exec plugin, the attached patch appears to work pretty well.  I would like to submit it to be considered for inclusion into the
 codebase.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">It records every dynamic object's lt_dlhandle when it is opened/loaded.  Then, after the exec plugin has called fork(), the child process calls lt_dlclose() on all of those objects immediately before calling execvp().  Access to the list
 of lt_dlhandles is synchronized, so it should be thread-safe.  It is only in the child process and immediately before calling execvp() that the objects are closed.  The call to execvp() is moved from exec.c into plugin.c to avoid a situation where closing
 the dynamically loaded exec plugin would saw off the limb on which the execution thread was sitting.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Testing of the patch was done in the same environment in which the original problem (failure of the child process to do its thing) was seem.  Without the patch, failure happened about 30-50% of the time--rarely taking more than 3-5 attempts
 to see a failure.  With the patch, in over 50 attempts, there was not a single failure of the child process to launch and do its thing.  Oddly, in about 7 of the 50+ attempts, collectd printed the dl_open_worker assertion failure, but the child process survived
 and did its thing, perfectly as far as I could tell.  No other problematic symptoms were observed during testing.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I made my best attempt to code indentation and such in a manner consistent with each of the files--perhaps modulo some spaces vs. tabs.  Is there some additional process I should take this patch through in order to get it considered for
 inclusion into the codebase?  (Submission of the patch has been approved by my manager if that is a concern.)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Robert Riches<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>