Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is res_query thread-safe?

Is res_query (int res_query(const char *dname, int class, int type,unsigned char *answer, int anslen);) thread-safe?

I think so, because it writes its answer to an user-allocated buffer (in contrast to gethostbyname that uses a statically allocated buffer).

Does somebody know for sure?

like image 730
IanH Avatar asked Apr 01 '26 02:04

IanH


1 Answers

You were right that res_query is not threadsafe. You have to use res_nquery, which takes a 'res_state' argument first. From everything I've read, that is how the query should be done in a thread safe manner.

like image 97
Philip J Avatar answered Apr 03 '26 17:04

Philip J



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!