<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2016-08-02 19:59 GMT+02:00 Maksim Ivanov <span dir="ltr"><<a href="mailto:emaxx@google.com" target="_blank">emaxx@google.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Ludovic,</div><div><br></div><div>Thanks for the quick update.</div><div><br></div><div>Yes, looks like the suggested patch fixes the problem. Great that the resulting patch is so small.</div></div></blockquote><div><br></div><div>Thanks for the feedback.<br></div><div>It is now fixed in <a href="https://github.com/LudovicRousseau/PCSC/commit/bb07a905c896e7a67e3d7b37a24b3637ada0546d">https://github.com/LudovicRousseau/PCSC/commit/bb07a905c896e7a67e3d7b37a24b3637ada0546d</a><br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><span class="gmail-"><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I am not sure to understand your concern about srand (point 3).<br>I agree the code is not thread safe. So srand could be called twice. But that should not be an issue. srand would be called at least once in all cases. Or I am missing something?</blockquote></div><div><br></div></span><div>The effect of calling srand twice is the possible overlaps of the obtained pseudo-random numbers. Also, srand is not guaranteed to work correctly at all when used from multiple threads simultaneously.</div><div><br></div><div>Generally, why not just call srand once somewhere around the daemon's entry point (int main)? Then there would be no questions regarding which component and how should perform this initialization.</div></div></blockquote><br clear="all"></div>Good idea.<br>Fixed in <a href="https://github.com/LudovicRousseau/PCSC/commit/8b80aa4900cd60ab075802bdcc5a996027d0c74e">https://github.com/LudovicRousseau/PCSC/commit/8b80aa4900cd60ab075802bdcc5a996027d0c74e</a> and <a href="https://github.com/LudovicRousseau/PCSC/commit/8e820796b338cb1048c51ec462446f61a3979835">https://github.com/LudovicRousseau/PCSC/commit/8e820796b338cb1048c51ec462446f61a3979835</a><br><br><br></div><div class="gmail_extra">I also note that the number of different contexts is limited to RAND_MAX.<br></div><div class="gmail_extra">On my Debian GNU/Linux system I have RAND_MAX = 2147483647 so that should be enough but on some other systems may it be more limited (like 32767).<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">I opened a new feature request so I can remember to work on this (when time and motivation permits)<br><a href="https://alioth.debian.org/tracker/index.php?func=detail&aid=315434&group_id=30105&atid=410088">https://alioth.debian.org/tracker/index.php?func=detail&aid=315434&group_id=30105&atid=410088</a><br><br></div><div class="gmail_extra">Bye<br><br></div><div class="gmail_extra">-- <br><div class="gmail_signature"> Dr. Ludovic Rousseau</div>
</div></div>