From b018145a8b6dfacd2845d21c0c9b7f5dc6337ba3 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sun, 13 Mar 2016 22:21:19 +0000 Subject: [PATCH] [Fix] Use CAS for atomic maps lock --- src/libutil/map.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libutil/map.c b/src/libutil/map.c index cd4992eab..377154b8f 100644 --- a/src/libutil/map.c +++ b/src/libutil/map.c @@ -539,15 +539,13 @@ file_callback (gint fd, short what, void *ud) pool = map->pool; - if (g_atomic_int_get (map->locked)) { + if (!g_atomic_int_compare_and_exchange (map->locked, 0, 1)) { msg_info_pool ( "don't try to reread map as it is locked by other process, will reread it later"); jitter_timeout_event (map, TRUE, FALSE, FALSE); return; } - g_atomic_int_inc (map->locked); - if (stat (data->filename, &st) != -1 && (st.st_mtime > data->st.st_mtime || data->st.st_mtime == -1)) { /* File was modified since last check */ -- 2.39.5