Add missing lock around the use of gethostbyaddr.

This cures the symptoms of ROOT-6828 ... however this will fails if any other code anywhere else also
uses gethostbyaddr .. the right solution is to replace the use of gethostbyaddr by getaddrinfo

(cherry picked from commit d22fcb4f7ce49ea788a8591e6aac495d26750e9f)
(cherry picked from commit 584eb4c3578b0b6c740dce497b5073c8b7488df5)