diff options
author | Xavi Hernandez <xhernandez@redhat.com> | 2019-01-24 18:31:10 +0100 |
---|---|---|
committer | Xavi Hernandez <xhernandez@redhat.com> | 2019-02-01 10:37:20 +0100 |
commit | 4674678951a1315975d66016fb55c49100b7819f (patch) | |
tree | 6572b7186f06c6405badc67cd1f3dbf450c4df6d /libglusterfs/src/syncop.c | |
parent | 6b98735956c599ea621fa560b201fb7de6c36cac (diff) |
core: make gf_thread_create() easier to use
This patch creates a specific function to set the thread name using a
string format and a variable argument list, like printf().
This function is used to set the thread name from gf_thread_create(),
which now accepts a variable argument list to create the full name. It's
not necessary anymore to use a local array to build the name of the
thread. This is done automatically.
Change-Id: Idd8d01fd462c227359b96e98699f8c6d962dc17c
Updates: bz#1193929
Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
Diffstat (limited to 'libglusterfs/src/syncop.c')
-rw-r--r-- | libglusterfs/src/syncop.c | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c index 6206d4cec7c..c05939a7915 100644 --- a/libglusterfs/src/syncop.c +++ b/libglusterfs/src/syncop.c @@ -695,9 +695,6 @@ syncenv_scale(struct syncenv *env) int scale = 0; int i = 0; int ret = 0; - char thread_name[GF_THREAD_NAMEMAX] = { - 0, - }; pthread_mutex_lock(&env->mutex); { @@ -717,11 +714,9 @@ syncenv_scale(struct syncenv *env) } env->proc[i].env = env; - snprintf(thread_name, sizeof(thread_name), "sproc%03hx", - (env->procs & 0x3ff)); ret = gf_thread_create(&env->proc[i].processor, NULL, syncenv_processor, &env->proc[i], - thread_name); + "sproc%03hx", env->procs & 0x3ff); if (ret) break; env->procs++; @@ -783,9 +778,6 @@ syncenv_new(size_t stacksize, int procmin, int procmax) struct syncenv *newenv = NULL; int ret = 0; int i = 0; - char thread_name[GF_THREAD_NAMEMAX] = { - 0, - }; if (!procmin || procmin < 0) procmin = SYNCENV_PROC_MIN; @@ -814,11 +806,9 @@ syncenv_new(size_t stacksize, int procmin, int procmax) for (i = 0; i < newenv->procmin; i++) { newenv->proc[i].env = newenv; - snprintf(thread_name, sizeof(thread_name), "%s%d", "sproc", - (newenv->procs)); ret = gf_thread_create(&newenv->proc[i].processor, NULL, - syncenv_processor, &newenv->proc[i], - thread_name); + syncenv_processor, &newenv->proc[i], "sproc%d", + newenv->procs); if (ret) break; newenv->procs++; |