X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fnetwork%2Fres_msend.c;h=3e018009ebc61e10c3eb24e0e6039e8fac5e01c4;hb=4554f155dd23a65fcdfd39f1d5af8af55ba37694;hp=a47d18ddbffb4697542d533bbb74128c0c03ea1c;hpb=1563587b45a39512df9b5810dcc5961d4d21a910;p=musl diff --git a/src/network/res_msend.c b/src/network/res_msend.c index a47d18dd..3e018009 100644 --- a/src/network/res_msend.c +++ b/src/network/res_msend.c @@ -52,7 +52,6 @@ int __res_msend_rc(int nqueries, const unsigned char *const *queries, timeout = 1000*conf->timeout; attempts = conf->attempts; - nns = conf->nns; for (nns=0; nnsnns; nns++) { const struct address *iplit = &conf->ns[nns]; if (iplit->family == AF_INET) { @@ -77,7 +76,11 @@ int __res_msend_rc(int nqueries, const unsigned char *const *queries, fd = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0); family = AF_INET; } - if (fd < 0 || bind(fd, (void *)&sa, sl) < 0) return -1; + if (fd < 0 || bind(fd, (void *)&sa, sl) < 0) { + if (fd >= 0) close(fd); + pthread_setcancelstate(cs, 0); + return -1; + } /* Past this point, there are no errors. Each individual query will * yield either no reply (indicated by zero length) or an answer