- * \param msg a \p NULL terminated buffer
- */
-void stat_client_write(char *msg)
-{
- struct stat_client *sc, *tmp;
- char *buf;
- ssize_t len;
- struct timeval tv = {0 , 0};
-
- if (!initialized)
- return;
- buf = make_message("%s\n", msg);
- len = strlen(buf);
- list_for_each_entry_safe(sc, tmp, &client_list, node) {
- int fd = sc->fd, ret;
- fd_set wfds;
- FD_ZERO(&wfds);
- FD_SET(fd, &wfds);
-// PARA_DEBUG_LOG("%s: p=%lx\n", __func__, (long)p);
- do
- ret = select(fd + 1, NULL, &wfds, NULL, &tv);
- while (ret < 0 && errno == EINTR);
- if (ret) {
- ret = write(fd, buf, len);
- PARA_DEBUG_LOG("dumped %s to fd %d, ret = %d\n", msg, fd, ret);
- if (ret == len )
- continue;
- }
- /* write error or fd not ready for writing */
- close(fd);
- del_close_on_fork_list(fd);
- num_clients--;
- PARA_INFO_LOG("deleting client on fd %d\n", fd);
- list_del(&sc->node);
- free(sc);
- dump_stat_client_list();
- }
- free(buf);
- PARA_DEBUG_LOG("%d client(s)\n", num_clients);
-}
-
-/**
- * send empty status list
- *
- * Send to each connected client the full status item list
- * with empty values.
- */
-void dump_empty_status(void)
-{
- int i;
- char *empty_items = NULL;
-
- if (!initialized)
- return;
- FOR_EACH_STAT_ITEM(i) {
- char *tmp = make_message("%s%s:\n", empty_items? empty_items : "",
- status_item_list[i]);
- free(empty_items);
- empty_items = tmp;
- }
- stat_client_write(empty_items);
- free(empty_items);
-}
-
-/**
- * check if line starts with known status item.