2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

2134. [func] Additional statistics support. [RT #16666]

This commit is contained in:
Mark Andrews
2007-02-13 02:49:08 +00:00
parent 149e7eacf0
commit 96ea716328
22 changed files with 654 additions and 46 deletions

View File

@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: task.c,v 1.102 2007/01/12 00:14:51 marka Exp $ */
/* $Id: task.c,v 1.103 2007/02/13 02:49:08 marka Exp $ */
/*! \file
* \author Principal Author: Bob Halley
@@ -38,6 +38,7 @@
#include <isc/task.h>
#include <isc/thread.h>
#include <isc/util.h>
#include <isc/xml.h>
#ifndef ISC_PLATFORM_USETHREADS
#include "task_p.h"
@@ -67,6 +68,10 @@ typedef enum {
task_state_done
} task_state_t;
static const char *statenames[] = {
"idle", "ready", "running", "done",
};
#define TASK_MAGIC ISC_MAGIC('T', 'A', 'S', 'K')
#define VALID_TASK(t) ISC_MAGIC_VALID(t, TASK_MAGIC)
@@ -1296,3 +1301,86 @@ isc_task_endexclusive(isc_task_t *task) {
UNUSED(task);
#endif
}
#ifdef HAVE_LIBXML2
void
isc_taskmgr_renderxml(isc_taskmgr_t *mgr, xmlTextWriterPtr writer)
{
isc_task_t *task;
LOCK(&mgr->lock);
/*
* Write out the thread-model, and some details about each depending
* on which type is enabled.
*/
xmlTextWriterStartElement(writer, ISC_XMLCHAR "thread-model");
#ifdef ISC_PLATFORM_USETHREADS
xmlTextWriterStartElement(writer, ISC_XMLCHAR "type");
xmlTextWriterWriteString(writer, ISC_XMLCHAR "threaded");
xmlTextWriterEndElement(writer); /* type */
xmlTextWriterStartElement(writer, ISC_XMLCHAR "worker-threads");
xmlTextWriterWriteFormatString(writer, "%d", mgr->workers);
xmlTextWriterEndElement(writer); /* worker-threads */
#else /* ISC_PLATFORM_USETHREADS */
xmlTextWriterStartElement(writer, ISC_XMLCHAR "type");
xmlTextWriterWriteString(writer, ISC_XMLCHAR "non-threaded");
xmlTextWriterEndElement(writer); /* type */
xmlTextWriterStartElement(writer, ISC_XMLCHAR "references");
xmlTextWriterWriteFormatString(writer, "%d", mgr->refs);
xmlTextWriterEndElement(writer); /* references */
#endif /* ISC_PLATFORM_USETHREADS */
xmlTextWriterStartElement(writer, ISC_XMLCHAR "default-quantum");
xmlTextWriterWriteFormatString(writer, "%d", mgr->default_quantum);
xmlTextWriterEndElement(writer); /* default-quantum */
xmlTextWriterStartElement(writer, ISC_XMLCHAR "tasks-running");
xmlTextWriterWriteFormatString(writer, "%d", mgr->tasks_running);
xmlTextWriterEndElement(writer); /* tasks-running */
xmlTextWriterEndElement(writer); /* thread-model */
xmlTextWriterStartElement(writer, ISC_XMLCHAR "tasks");
task = ISC_LIST_HEAD(mgr->tasks);
while (task != NULL) {
LOCK(&task->lock);
xmlTextWriterStartElement(writer, ISC_XMLCHAR "task");
if (task->name[0] != 0) {
xmlTextWriterStartElement(writer, ISC_XMLCHAR "name");
xmlTextWriterWriteFormatString(writer, "%s",
task->name);
xmlTextWriterEndElement(writer); /* name */
}
xmlTextWriterStartElement(writer, ISC_XMLCHAR "references");
xmlTextWriterWriteFormatString(writer, "%d", task->references);
xmlTextWriterEndElement(writer); /* references */
xmlTextWriterStartElement(writer, ISC_XMLCHAR "id");
xmlTextWriterWriteFormatString(writer, "%p", task);
xmlTextWriterEndElement(writer); /* id */
xmlTextWriterStartElement(writer, ISC_XMLCHAR "state");
xmlTextWriterWriteFormatString(writer, "%s",
statenames[task->state]);
xmlTextWriterEndElement(writer); /* state */
xmlTextWriterStartElement(writer, ISC_XMLCHAR "quantum");
xmlTextWriterWriteFormatString(writer, "%d", task->quantum);
xmlTextWriterEndElement(writer); /* quantum */
xmlTextWriterEndElement(writer);
UNLOCK(&task->lock);
task = ISC_LIST_NEXT(task, link);
}
xmlTextWriterEndElement(writer); /* tasks */
UNLOCK(&mgr->lock);
}
#endif /* HAVE_LIBXML2 */