mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
virthreadpool: Copy job name
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@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
47ee68e8cc
commit
fb96b6a052
@ -50,7 +50,7 @@ struct _virThreadPool {
|
|||||||
bool quit;
|
bool quit;
|
||||||
|
|
||||||
virThreadPoolJobFunc jobFunc;
|
virThreadPoolJobFunc jobFunc;
|
||||||
const char *jobName;
|
char *jobName;
|
||||||
void *jobOpaque;
|
void *jobOpaque;
|
||||||
virThreadPoolJobList jobList;
|
virThreadPoolJobList jobList;
|
||||||
size_t jobQueueDepth;
|
size_t jobQueueDepth;
|
||||||
@ -237,7 +237,7 @@ virThreadPoolNewFull(size_t minWorkers,
|
|||||||
pool->jobList.tail = pool->jobList.head = NULL;
|
pool->jobList.tail = pool->jobList.head = NULL;
|
||||||
|
|
||||||
pool->jobFunc = func;
|
pool->jobFunc = func;
|
||||||
pool->jobName = name;
|
pool->jobName = g_strdup(name);
|
||||||
pool->jobOpaque = opaque;
|
pool->jobOpaque = opaque;
|
||||||
|
|
||||||
if (identity)
|
if (identity)
|
||||||
@ -312,6 +312,7 @@ void virThreadPoolFree(virThreadPool *pool)
|
|||||||
if (pool->identity)
|
if (pool->identity)
|
||||||
g_object_unref(pool->identity);
|
g_object_unref(pool->identity);
|
||||||
|
|
||||||
|
g_free(pool->jobName);
|
||||||
g_free(pool->workers);
|
g_free(pool->workers);
|
||||||
virMutexUnlock(&pool->mutex);
|
virMutexUnlock(&pool->mutex);
|
||||||
virMutexDestroy(&pool->mutex);
|
virMutexDestroy(&pool->mutex);
|
||||||
|
Loading…
Reference in New Issue
Block a user