+ int *client_sd;
+ struct sockaddr_storage client_sa;
+ socklen_t client_sa_size;
+ pthread_t tid;
+
+ if (pollfds[i].revents == 0)
+ continue;
+
+ if ((pollfds[i].revents & (POLLIN | POLLPRI)) == 0)
+ {
+ RRDD_LOG (LOG_ERR, "listen_thread_main: "
+ "poll(2) returned something unexpected for listen FD #%i.",
+ pollfds[i].fd);
+ continue;
+ }
+
+ client_sd = (int *) malloc (sizeof (int));
+ if (client_sd == NULL)
+ {
+ RRDD_LOG (LOG_ERR, "listen_thread_main: malloc failed.");
+ continue;
+ }
+
+ client_sa_size = sizeof (client_sa);
+ *client_sd = accept (pollfds[i].fd,
+ (struct sockaddr *) &client_sa, &client_sa_size);
+ if (*client_sd < 0)
+ {
+ RRDD_LOG (LOG_ERR, "listen_thread_main: accept(2) failed.");
+ continue;
+ }
+
+ RRDD_LOG (LOG_DEBUG, "listen_thread_main: accept(2) returned fd #%i.",
+ *client_sd);
+
+ status = pthread_create (&tid, /* attr = */ NULL, connection_thread_main,
+ /* args = */ (void *) client_sd);
+ if (status != 0)
+ {
+ RRDD_LOG (LOG_ERR, "listen_thread_main: pthread_create failed.");
+ close (*client_sd);
+ free (client_sd);
+ continue;
+ }