From a6f235f3416c3ecb635420033572d790b7db0ede Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 22 Aug 2018 21:05:29 -0400 Subject: [PATCH] lib: Seperate out Poll data from thread memory statistics We were storing Poll data for the read and write memory information in MTYPE_THREAD, so a show run would not be able to show actual amount of memory associated with the `struct thread`. Remove unnecessary NULL checks on malloc. Signed-off-by: Donald Sharp --- lib/thread.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/lib/thread.c b/lib/thread.c index 898e9e9fce..c6894be4ee 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -36,6 +36,7 @@ DEFINE_MTYPE_STATIC(LIB, THREAD, "Thread") DEFINE_MTYPE_STATIC(LIB, THREAD_MASTER, "Thread master") +DEFINE_MTYPE_STATIC(LIB, THREAD_POLL, "Thread Poll Info") DEFINE_MTYPE_STATIC(LIB, THREAD_STATS, "Thread stats") #if defined(__APPLE__) @@ -423,19 +424,11 @@ struct thread_master *thread_master_create(const char *name) /* Initialize I/O task data structures */ getrlimit(RLIMIT_NOFILE, &limit); rv->fd_limit = (int)limit.rlim_cur; - rv->read = - XCALLOC(MTYPE_THREAD, sizeof(struct thread *) * rv->fd_limit); - if (rv->read == NULL) { - XFREE(MTYPE_THREAD_MASTER, rv); - return NULL; - } - rv->write = - XCALLOC(MTYPE_THREAD, sizeof(struct thread *) * rv->fd_limit); - if (rv->write == NULL) { - XFREE(MTYPE_THREAD, rv->read); - XFREE(MTYPE_THREAD_MASTER, rv); - return NULL; - } + rv->read = XCALLOC(MTYPE_THREAD_POLL, + sizeof(struct thread *) * rv->fd_limit); + + rv->write = XCALLOC(MTYPE_THREAD_POLL, + sizeof(struct thread *) * rv->fd_limit); rv->cpu_record = hash_create_size( 8, (unsigned int (*)(void *))cpu_record_hash_key, @@ -580,7 +573,7 @@ static void thread_array_free(struct thread_master *m, m->alloc--; } } - XFREE(MTYPE_THREAD, thread_array); + XFREE(MTYPE_THREAD_POLL, thread_array); } static void thread_queue_free(struct thread_master *m, struct pqueue *queue) -- 2.39.5