- for (fd = 0; (n_ready > 0) && (fd < FD_SETSIZE); fd++) {
- if (FD_ISSET (fd, &readfds)) {
-
- --n_ready;
-
- if (fd == sock_fd) {
- int conn;
-
- //printf("New Connection request.\n");
- if ((conn = accept (sock_fd, (struct sockaddr *) &sunx, &addrLength)) < 0) {
- perror_msg_and_die ("accept error");
- }
-
- FD_SET(conn, &fds);
- //printf("conn: %i, set_size: %i\n",conn,FD_SETSIZE);
- } else {
- //printf("Serving connection: %i\n",fd);
- if ( serveConnection(fd) <= 0 ) {
- close (fd);
- FD_CLR(fd, &fds);
- }
- } /* fd == sock_fd */
- }/* FD_ISSET() */
- }/* for */
+ if (FD_ISSET (sock_fd, &fds)) {
+ int i;
+ RESERVE_CONFIG_BUFFER(tmpbuf, BUFSIZ + 1);
+
+ memset(tmpbuf, '\0', BUFSIZ+1);
+ if ( (i = recv(sock_fd, tmpbuf, BUFSIZ, 0)) > 0) {
+ serveConnection(tmpbuf, i);
+ } else {
+ perror_msg_and_die ("UNIX socket error");
+ }
+ RELEASE_CONFIG_BUFFER (tmpbuf);
+ }/* FD_ISSET() */