From b07ef1dc5e76ba6ca3f99ac6a18eb1405328c15b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Thu, 8 Jan 2015 10:55:56 +0100 Subject: osd_work: moved thread count printing to KEEP_STATISTICS / prevent KEEP_STATISTICS loop from going out-of-bounds (nw) --- src/osd/modules/sync/work_osd.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/osd/modules/sync/work_osd.c b/src/osd/modules/sync/work_osd.c index 031884e3dd5..950f26ae530 100644 --- a/src/osd/modules/sync/work_osd.c +++ b/src/osd/modules/sync/work_osd.c @@ -223,10 +223,11 @@ osd_work_queue *osd_work_queue_alloc(int flags) allocthreadnum = queue->threads + 1; else allocthreadnum = queue->threads; -#if 0 - // tools like chdman are not linked with osd_printf_* - osd_printf_verbose("osdprocs: %d effecprocs: %d threads: %d allocthreads: %d osdthreads: %d maxthreads: %d queuethreads: %d\n", osd_num_processors, numprocs, threadnum, allocthreadnum, osdthreadnum, WORK_MAX_THREADS, queue->threads); + +#if KEEP_STATISTICS + printf("osdprocs: %d effecprocs: %d threads: %d allocthreads: %d osdthreads: %d maxthreads: %d queuethreads: %d\n", osd_num_processors, numprocs, threadnum, allocthreadnum, osdthreadnum, WORK_MAX_THREADS, queue->threads); #endif + queue->thread = (work_thread_info *)osd_malloc_array(allocthreadnum * sizeof(queue->thread[0])); if (queue->thread == NULL) goto error; @@ -382,7 +383,7 @@ void osd_work_queue_free(osd_work_queue *queue) allocthreadnum = queue->threads; // output per-thread statistics - for (threadnum = 0; threadnum <= allocthreadnum; threadnum++) + for (threadnum = 0; threadnum < allocthreadnum; threadnum++) { work_thread_info *thread = &queue->thread[threadnum]; osd_ticks_t total = thread->runtime + thread->waittime + thread->spintime; -- cgit v1.2.3