From: Alan T. DeKok Date: Thu, 4 Sep 2008 08:35:03 +0000 (+0200) Subject: Leverage configure checks && use select X-Git-Tag: release_2_1_0~16 X-Git-Url: http://www.project-moonshot.org/gitweb/?a=commitdiff_plain;h=6b0aa596636f69683a3f96cd0b9ff02e60dbc4df;p=freeradius.git Leverage configure checks && use select --- diff --git a/src/main/radmin.c b/src/main/radmin.c index 94420b2..8cadc2d 100644 --- a/src/main/radmin.c +++ b/src/main/radmin.c @@ -32,12 +32,13 @@ RCSID("$Id$") #include #endif -/* - * FIXME: configure checks. - */ -#include +#ifdef HAVE_SYS_SOCKET_H #include +#endif + +#ifdef HAVE_SYS_UN_H #include +#endif static int fr_domain_socket(const char *path) @@ -180,6 +181,21 @@ int main(int argc, char **argv) memset(buffer, 0, sizeof(buffer)); while (port == 1) { + int rcode; + fd_set readfds; + + FD_ZERO(&readfds); + FD_SET(sockfd, &readfds); + + rcode = select(sockfd + 1, &readfds, NULL, NULL, NULL); + if (rcode < 0) { + if (errno == EINTR) continue; + + fprintf(stderr, "Failed selecting: %s\n", + strerror(errno)); + exit(1); + } + len = recv(sockfd, buffer + size, sizeof(buffer) - size - 1, MSG_DONTWAIT); if (len < 0) {