+ struct stat_client *sc;
+
+ list_for_each_entry(sc, &client_list, node)
+ PARA_INFO_LOG("stat client on fd %d\n", sc->fd);
+}
+/**
+ * Add a status client to the list.
+ *
+ * \param fd The file descriptor of the client.
+ * \param mask Bitfield of status items for this client.
+ * \param parser_friendly Enable parser-friendly output mode.
+ *
+ * Only those status items having the bit set in \a mask will be
+ * sent to the client.
+ *
+ * \return Positive value on success, or -E_TOO_MANY_CLIENTS if
+ * the number of connected clients exceeds #MAX_STAT_CLIENTS.
+ */
+static int stat_client_add(int fd, uint64_t mask, int parser_friendly)
+{
+ struct stat_client *new_client;
+ int ret;
+
+ if (num_clients >= MAX_STAT_CLIENTS) {
+ PARA_ERROR_LOG("maximal number of stat clients (%d) exceeded\n",
+ MAX_STAT_CLIENTS);
+ return -E_TOO_MANY_CLIENTS;
+ }
+ ret = dup(fd);
+ if (ret < 0)
+ return -ERRNO_TO_PARA_ERROR(errno);
+ new_client = para_calloc(sizeof(*new_client));
+ new_client->fd = ret;
+ PARA_INFO_LOG("adding client on fd %d\n", new_client->fd);
+ new_client->item_mask = mask;
+ if (parser_friendly)
+ new_client->flags = SCF_PARSER_FRIENDLY;
+ para_list_add(&new_client->node, &client_list);
+ dump_stat_client_list();
+ num_clients++;
+ return 1;