summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/glusterfs/common-utils.h
diff options
context:
space:
mode:
authorXavi Hernandez <xhernandez@redhat.com>2019-01-24 18:31:10 +0100
committerXavi Hernandez <xhernandez@redhat.com>2019-02-01 10:37:20 +0100
commit4674678951a1315975d66016fb55c49100b7819f (patch)
tree6572b7186f06c6405badc67cd1f3dbf450c4df6d /libglusterfs/src/glusterfs/common-utils.h
parent6b98735956c599ea621fa560b201fb7de6c36cac (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/glusterfs/common-utils.h')
-rw-r--r--libglusterfs/src/glusterfs/common-utils.h21
1 files changed, 17 insertions, 4 deletions
diff --git a/libglusterfs/src/glusterfs/common-utils.h b/libglusterfs/src/glusterfs/common-utils.h
index 89b38e02448..f03d2c1049a 100644
--- a/libglusterfs/src/glusterfs/common-utils.h
+++ b/libglusterfs/src/glusterfs/common-utils.h
@@ -147,9 +147,8 @@ trap(void);
/* pthread related */
/* as per the man page, thread-name should be at max 16 bytes */
/* with prefix of 'glfs_' (5), we are left with 11 more bytes */
-#define GF_THREAD_NAMEMAX 11
+#define GF_THREAD_NAME_LIMIT 16
#define GF_THREAD_NAME_PREFIX "glfs_"
-#define GF_THREAD_NAME_PREFIX_LEN 5
/*
* we could have initialized these as +ve values and treated
@@ -950,10 +949,24 @@ gf_set_timestamp(const char *src, const char *dest);
int
gf_thread_create(pthread_t *thread, const pthread_attr_t *attr,
- void *(*start_routine)(void *), void *arg, const char *name);
+ void *(*start_routine)(void *), void *arg, const char *name,
+ ...) __attribute__((__format__(__printf__, 5, 6)));
+
+int
+gf_thread_vcreate(pthread_t *thread, const pthread_attr_t *attr,
+ void *(*start_routine)(void *), void *arg, const char *name,
+ va_list args);
int
gf_thread_create_detached(pthread_t *thread, void *(*start_routine)(void *),
- void *arg, const char *name);
+ void *arg, const char *name, ...)
+ __attribute__((__format__(__printf__, 4, 5)));
+
+void
+gf_thread_set_name(pthread_t thread, const char *name, ...)
+ __attribute__((__format__(__printf__, 2, 3)));
+
+void
+gf_thread_set_vname(pthread_t thread, const char *name, va_list args);
gf_boolean_t
gf_is_pid_running(int pid);
gf_boolean_t