summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cli/src/cli-cmd.c12
-rw-r--r--cli/src/cli-cmd.h3
-rw-r--r--cli/src/cli.c4
-rw-r--r--libglusterfs/src/syncop-utils.c37
4 files changed, 11 insertions, 45 deletions
diff --git a/cli/src/cli-cmd.c b/cli/src/cli-cmd.c
index c8a84475b55..af009757e93 100644
--- a/cli/src/cli-cmd.c
+++ b/cli/src/cli-cmd.c
@@ -232,18 +232,6 @@ out:
}
int
-cli_cmd_cond_init()
-{
- pthread_mutex_init(&cond_mutex, NULL);
- pthread_cond_init(&cond, NULL);
-
- pthread_mutex_init(&conn_mutex, NULL);
- pthread_cond_init(&conn, NULL);
-
- return 0;
-}
-
-int
cli_cmd_lock()
{
pthread_mutex_lock(&cond_mutex);
diff --git a/cli/src/cli-cmd.h b/cli/src/cli-cmd.h
index b6bc5659936..c1c068c7085 100644
--- a/cli/src/cli-cmd.h
+++ b/cli/src/cli-cmd.h
@@ -102,9 +102,6 @@ int
cli_cmd_broadcast_response(int32_t status);
int
-cli_cmd_cond_init();
-
-int
cli_cmd_lock();
int
diff --git a/cli/src/cli.c b/cli/src/cli.c
index fac32d3e9ca..cb425c84bdc 100644
--- a/cli/src/cli.c
+++ b/cli/src/cli.c
@@ -854,10 +854,6 @@ main(int argc, char *argv[])
if (ret)
goto out;
- ret = cli_cmd_cond_init();
- if (ret)
- goto out;
-
ret = cli_input_init(&state);
if (ret)
goto out;
diff --git a/libglusterfs/src/syncop-utils.c b/libglusterfs/src/syncop-utils.c
index 4167db465f4..d9f1723856d 100644
--- a/libglusterfs/src/syncop-utils.c
+++ b/libglusterfs/src/syncop-utils.c
@@ -345,10 +345,8 @@ syncop_mt_dir_scan(call_frame_t *frame, xlator_t *subvol, loc_t *loc, int pid,
gf_dirent_t *tmp = NULL;
uint32_t jobs_running = 0;
uint32_t qlen = 0;
- pthread_cond_t cond;
- pthread_mutex_t mut;
- gf_boolean_t cond_init = _gf_false;
- gf_boolean_t mut_init = _gf_false;
+ pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+ pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
gf_dirent_t entries;
xlator_t *this = NULL;
@@ -378,15 +376,6 @@ syncop_mt_dir_scan(call_frame_t *frame, xlator_t *subvol, loc_t *loc, int pid,
INIT_LIST_HEAD(&entries.list);
INIT_LIST_HEAD(&q.list);
- ret = pthread_mutex_init(&mut, NULL);
- if (ret)
- goto out;
- mut_init = _gf_true;
-
- ret = pthread_cond_init(&cond, NULL);
- if (ret)
- goto out;
- cond_init = _gf_true;
while ((ret = syncop_readdir(subvol, fd, 131072, offset, &entries, xdata,
NULL))) {
@@ -452,21 +441,17 @@ syncop_mt_dir_scan(call_frame_t *frame, xlator_t *subvol, loc_t *loc, int pid,
out:
if (fd)
fd_unref(fd);
- if (mut_init && cond_init) {
- pthread_mutex_lock(&mut);
- {
- while (jobs_running)
- pthread_cond_wait(&cond, &mut);
- }
- pthread_mutex_unlock(&mut);
- gf_dirent_free(&q);
- gf_dirent_free(&entries);
+
+ pthread_mutex_lock(&mut);
+ {
+ while (jobs_running)
+ pthread_cond_wait(&cond, &mut);
}
+ pthread_mutex_unlock(&mut);
+
+ gf_dirent_free(&q);
+ gf_dirent_free(&entries);
- if (mut_init)
- pthread_mutex_destroy(&mut);
- if (cond_init)
- pthread_cond_destroy(&cond);
return ret | retval;
}