Make D* functions thread safe, thanks to Patrick Zimmermann for the patch. https://bz.apache.org/bugzilla/show_bug.cgi?id=58039