- if (udpfd) close(udpfd); udpfd = 0;
- if (tunfd) close(tunfd); tunfd = 0;
- if (snoopfd) close(snoopfd); snoopfd = 0;
- for (i = 0; i < config->num_radfds; i++)
- if (radfds[i]) close(radfds[i]);
- if (ifrfd) close(ifrfd); ifrfd = 0;
- if (cluster_sockfd) close(cluster_sockfd); cluster_sockfd = 0;
- if (clifd) close(clifd); clifd = 0;
+ if (tunfd != -1) close(tunfd);
+ if (udpfd != -1) close(udpfd);
+ if (controlfd != -1) close(controlfd);
+ if (snoopfd != -1) close(snoopfd);
+ if (ifrfd != -1) close(ifrfd);
+ if (ifr6fd != -1) close(ifr6fd);
+ if (cluster_sockfd != -1) close(cluster_sockfd);
+ if (clifd != -1) close(clifd);
+
+ for (i = 0; radfds && i < config->num_radfds; i++)
+ close(radfds[i]);