<div dir="ltr">Thanks for the pointers, with your help I'm making progress. I think I found the source for Apple's getaddrinfo.<div><br></div><div>In Apple's Libinfo version 222.4.12, the man page says getaddrinfo isn't thread-safe:<div><br></div><div><a href="http://www.opensource.apple.com/source/Libinfo/Libinfo-222.4.12/lookup.subproj/getaddrinfo.3">http://www.opensource.apple.com/source/Libinfo/Libinfo-222.4.12/lookup.subproj/getaddrinfo.3</a><br></div><div><br></div><div>And here's its source:</div><div><br></div><div><a href="http://www.opensource.apple.com/source/Libinfo/Libinfo-222.4.12/lookup.subproj/getaddrinfo.c">http://www.opensource.apple.com/source/Libinfo/Libinfo-222.4.12/lookup.subproj/getaddrinfo.c</a><br></div><div><br></div><div>Glancing at the source naïvely, I might see the data race: getaddrinfo calls gai_lookupd, which reads and writes the global static variable "gai_proc". I can't see what will go wrong as a result of the race, but it sure LOOKS bad. =)</div><div><br></div><div>In the next release, version 278, the thread-safety warning is gone from the man page:</div></div><div><br></div><div><a href="http://www.opensource.apple.com/source/Libinfo/Libinfo-278/lookup.subproj/getaddrinfo.3">http://www.opensource.apple.com/source/Libinfo/Libinfo-278/lookup.subproj/getaddrinfo.3</a><br></div><div><br></div><div>And getaddrinfo is largely rewritten:</div><div><br></div><div><a href="http://www.opensource.apple.com/source/Libinfo/Libinfo-278/lookup.subproj/getaddrinfo.c">http://www.opensource.apple.com/source/Libinfo/Libinfo-278/lookup.subproj/getaddrinfo.c</a><br></div><div><br></div><div>It calls a new function, "ds_getaddrinfo". But ds_getaddrinfo still accesses the global static variable "gai_proc"; I wonder why this is considered thread-safe now?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jan 3, 2016 at 12:14 AM, Siobhan Lynch <span dir="ltr"><<a href="mailto:slynch2112@me.com" target="_blank">slynch2112@me.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">OK… try and look at the revision histories of these three files:<div><br></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">     <b>#include</b> <b><sys/types.h></b></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">     <b>#include</b> <b><sys/socket.h></b></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">     <b>#include</b> <b><netdb.h></b></div><div><br></div><div><br></div><div><b>-Trish</b></div><div>
<div style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><br></div></div></div><br></div></div></blockquote></div><br></div>