summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/common-utils.c30
-rw-r--r--libglusterfs/src/common-utils.h3
-rw-r--r--libglusterfs/src/libglusterfs-messages.h10
3 files changed, 42 insertions, 1 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index a225c957f2e..97d9ef8da1a 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -3555,6 +3555,36 @@ gf_thread_create (pthread_t *thread, const pthread_attr_t *attr,
}
int
+gf_thread_create_detached (pthread_t *thread,
+ void *(*start_routine)(void *), void *arg)
+{
+ pthread_attr_t attr;
+ int ret = -1;
+
+ ret = pthread_attr_init (&attr);
+ if (ret) {
+ gf_msg (THIS->name, GF_LOG_ERROR, ret,
+ LG_MSG_PTHREAD_ATTR_INIT_FAILED,
+ "Thread attribute initialization failed");
+ return -1;
+ }
+
+ pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
+
+ ret = gf_thread_create (thread, &attr, start_routine, arg);
+ if (ret) {
+ gf_msg (THIS->name, GF_LOG_ERROR, ret,
+ LG_MSG_PTHREAD_FAILED,
+ "Thread creation failed");
+ ret = -1;
+ }
+
+ pthread_attr_destroy (&attr);
+
+ return ret;
+}
+
+int
gf_skip_header_section (int fd, int header_len)
{
int ret = -1;
diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h
index 09d585ad9c3..4741d430a03 100644
--- a/libglusterfs/src/common-utils.h
+++ b/libglusterfs/src/common-utils.h
@@ -766,6 +766,9 @@ int 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);
+int gf_thread_create_detached (pthread_t *thread,
+ void *(*start_routine)(void *), void *arg);
+
gf_boolean_t
gf_is_service_running (char *pidfile, int *pid);
int
diff --git a/libglusterfs/src/libglusterfs-messages.h b/libglusterfs/src/libglusterfs-messages.h
index c0bcabac798..d18f4cb3112 100644
--- a/libglusterfs/src/libglusterfs-messages.h
+++ b/libglusterfs/src/libglusterfs-messages.h
@@ -36,7 +36,7 @@
*/
#define GLFS_LG_BASE GLFS_MSGID_COMP_LIBGLUSTERFS
-#define GLFS_LG_NUM_MESSAGES 205
+#define GLFS_LG_NUM_MESSAGES 206
#define GLFS_LG_MSGID_END (GLFS_LG_BASE + GLFS_LG_NUM_MESSAGES + 1)
/* Messaged with message IDs */
#define glfs_msg_start_lg GLFS_LG_BASE, "Invalid: Start of messages"
@@ -1754,6 +1754,14 @@
* @recommendedaction
*
*/
+#define LG_MSG_PTHREAD_ATTR_INIT_FAILED (GLFS_LG_BASE + 206)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
/*------------*/
#define glfs_msg_end_lg GLFS_LG_MSGID_END, "Invalid: End of messages"