[libvirt PATCH 1/4] virthreadpool: Copy job name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Currently virThreadPoolNewFull relies on the caller to ensure the job
name outlives the thread pool. Which basically enforces static strings.
Let's drop this implicit requirement by making a copy of the job name.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 src/util/virthreadpool.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/util/virthreadpool.c b/src/util/virthreadpool.c
index 7bf4333885..426840e435 100644
--- a/src/util/virthreadpool.c
+++ b/src/util/virthreadpool.c
@@ -50,7 +50,7 @@ struct _virThreadPool {
     bool quit;
 
     virThreadPoolJobFunc jobFunc;
-    const char *jobName;
+    char *jobName;
     void *jobOpaque;
     virThreadPoolJobList jobList;
     size_t jobQueueDepth;
@@ -237,7 +237,7 @@ virThreadPoolNewFull(size_t minWorkers,
     pool->jobList.tail = pool->jobList.head = NULL;
 
     pool->jobFunc = func;
-    pool->jobName = name;
+    pool->jobName = g_strdup(name);
     pool->jobOpaque = opaque;
 
     if (identity)
@@ -312,6 +312,7 @@ void virThreadPoolFree(virThreadPool *pool)
     if (pool->identity)
         g_object_unref(pool->identity);
 
+    g_free(pool->jobName);
     g_free(pool->workers);
     virMutexUnlock(&pool->mutex);
     virMutexDestroy(&pool->mutex);
-- 
2.34.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux