X-Git-Url: https://git.distorted.org.uk/~mdw/adns/blobdiff_plain/c32f3e300172b1be39e40694854164c2b52479ad..8c09a4c65fb124c379c349f2ef8b84ad9e440545:/src/setup.c diff --git a/src/setup.c b/src/setup.c index 09f044b..b51502f 100644 --- a/src/setup.c +++ b/src/setup.c @@ -12,7 +12,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) + * the Free Software Foundation; either version 3, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, @@ -21,8 +21,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * along with this program; if not, write to the Free Software Foundation. */ #include @@ -580,7 +579,7 @@ static int init_begin(adns_state *ads_r, adns_initflags flags, LIST_INIT(ads->intdone); ads->forallnext= 0; ads->nextid= 0x311f; - ads->nudp= 0; + ads->nudpsockets= 0; ads->tcpsocket= -1; adns__vbuf_init(&ads->tcpsend); adns__vbuf_init(&ads->tcprecv); @@ -604,7 +603,7 @@ static int init_finish(adns_state ads) { struct sockaddr_in sin; struct protoent *proto; struct udpsocket *udp; - int i, j; + int i; int r; if (!ads->nservers) { @@ -618,16 +617,16 @@ static int init_finish(adns_state ads) { } proto= getprotobyname("udp"); if (!proto) { r= ENOPROTOOPT; goto x_free; } - ads->nudp= 0; + ads->nudpsockets= 0; for (i=0; inservers; i++) { if (adns__udpsocket_by_af(ads, ads->servers[i].addr.sa.sa_family)) continue; - assert(ads->nudp < MAXUDP); - udp= &ads->udpsocket[ads->nudp]; + assert(ads->nudpsockets < MAXUDP); + udp= &ads->udpsockets[ads->nudpsockets]; udp->af= ads->servers[i].addr.sa.sa_family; udp->fd= socket(udp->af,SOCK_DGRAM,proto->p_proto); if (udp->fd < 0) { r= errno; goto x_free; } - ads->nudp++; + ads->nudpsockets++; r= adns__setnonblock(ads,udp->fd); if (r) { r= errno; goto x_closeudp; } } @@ -635,7 +634,7 @@ static int init_finish(adns_state ads) { return 0; x_closeudp: - for (j=0; jnudp; j++) close(ads->udpsocket[j].fd); + for (i=0; inudpsockets; i++) close(ads->udpsockets[i].fd); x_free: free(ads); return r; @@ -752,7 +751,7 @@ void adns_finish(adns_state ads) { else if (ads->intdone.head) adns__cancel(ads->output.head); else break; } - for (i=0; inudp; i++) close(ads->udpsocket[i].fd); + for (i=0; inudpsockets; i++) close(ads->udpsockets[i].fd); if (ads->tcpsocket >= 0) close(ads->tcpsocket); adns__vbuf_free(&ads->tcpsend); adns__vbuf_free(&ads->tcprecv);