[CRIU] [PATCH 01/14] criu/img-remote-proto.c: use static mutex init
Kir Kolyshkin
kir at openvz.org
Tue Mar 21 15:00:53 PDT 2017
I see no need to do dynamic init here.
Cc: Rodrigo Bruno <rbruno at gsd.inesc-id.pt>
Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
criu/img-remote-proto.c | 21 +++------------------
1 file changed, 3 insertions(+), 18 deletions(-)
diff --git a/criu/img-remote-proto.c b/criu/img-remote-proto.c
index 3751b6f..9e2714d 100644
--- a/criu/img-remote-proto.c
+++ b/criu/img-remote-proto.c
@@ -19,12 +19,12 @@
#include "image.h"
LIST_HEAD(rimg_head);
-pthread_mutex_t rimg_lock;
+pthread_mutex_t rimg_lock = PTHREAD_MUTEX_INITIALIZER;
-pthread_mutex_t proxy_to_cache_lock;
+pthread_mutex_t proxy_to_cache_lock = PTHREAD_MUTEX_INITIALIZER;
LIST_HEAD(workers_head);
-pthread_mutex_t workers_lock;
+pthread_mutex_t workers_lock = PTHREAD_MUTEX_INITIALIZER;
sem_t workers_semph;
struct rimage * (*wait_for_image) (struct wthread *wt);
@@ -69,21 +69,6 @@ static struct wthread *get_wt_by_name(const char *snapshot_id, const char *path)
static int init_sync_structures(void)
{
- if (pthread_mutex_init(&rimg_lock, NULL) != 0) {
- pr_perror("Remote image list mutex init failed");
- return -1;
- }
-
- if (pthread_mutex_init(&proxy_to_cache_lock, NULL) != 0) {
- pr_perror("Remote image connection mutex init failed");
- return -1;
- }
-
- if (pthread_mutex_init(&workers_lock, NULL) != 0) {
- pr_perror("Workers mutex init failed");
- return -1;
- }
-
if (sem_init(&workers_semph, 0, 0) != 0) {
pr_perror("Workers semaphore init failed");
return -1;
--
2.9.3
More information about the CRIU
mailing list