diff options
Diffstat (limited to 'lib/thread.c')
| -rw-r--r-- | lib/thread.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/lib/thread.c b/lib/thread.c index 055587434c..2760b83fb3 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -52,10 +52,10 @@ DEFINE_MTYPE_STATIC(LIB, THREAD_STATS, "Thread stats") } while (0); /* control variable for initializer */ -pthread_once_t init_once = PTHREAD_ONCE_INIT; +static pthread_once_t init_once = PTHREAD_ONCE_INIT; pthread_key_t thread_current; -pthread_mutex_t masters_mtx = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t masters_mtx = PTHREAD_MUTEX_INITIALIZER; static struct list *masters; static void thread_free(struct thread_master *master, struct thread *thread); @@ -93,10 +93,9 @@ static void cpu_record_hash_free(void *a) static void vty_out_cpu_thread_history(struct vty *vty, struct cpu_thread_history *a) { - vty_out(vty, "%5"PRIdFAST32" %10lu.%03lu %9"PRIuFAST32 - " %8lu %9lu %8lu %9lu", a->total_active, - a->cpu.total / 1000, a->cpu.total % 1000, a->total_calls, - a->cpu.total / a->total_calls, a->cpu.max, + vty_out(vty, "%5zu %10zu.%03lu %9zu %8zu %9zu %8lu %9lu", + a->total_active, a->cpu.total / 1000, a->cpu.total % 1000, + a->total_calls, a->cpu.total / a->total_calls, a->cpu.max, a->real.total / a->total_calls, a->real.max); vty_out(vty, " %c%c%c%c%c %s\n", a->types & (1 << THREAD_READ) ? 'R' : ' ', @@ -414,8 +413,6 @@ struct thread_master *thread_master_create(const char *name) pthread_once(&init_once, &initializer); rv = XCALLOC(MTYPE_THREAD_MASTER, sizeof(struct thread_master)); - if (rv == NULL) - return NULL; /* Initialize master mutex */ pthread_mutex_init(&rv->mtx, NULL); @@ -484,8 +481,7 @@ void thread_master_set_name(struct thread_master *master, const char *name) { pthread_mutex_lock(&master->mtx); { - if (master->name) - XFREE(MTYPE_THREAD_MASTER, master->name); + XFREE(MTYPE_THREAD_MASTER, master->name); master->name = XSTRDUP(MTYPE_THREAD_MASTER, name); } pthread_mutex_unlock(&master->mtx); @@ -649,8 +645,7 @@ void thread_master_free(struct thread_master *m) hash_free(m->cpu_record); m->cpu_record = NULL; - if (m->name) - XFREE(MTYPE_THREAD_MASTER, m->name); + XFREE(MTYPE_THREAD_MASTER, m->name); XFREE(MTYPE_THREAD_MASTER, m->handler.pfds); XFREE(MTYPE_THREAD_MASTER, m->handler.copy); XFREE(MTYPE_THREAD_MASTER, m); |
