From: Vsevolod Stakhov Date: Sun, 13 Mar 2016 22:21:19 +0000 (+0000) Subject: [Fix] Use CAS for atomic maps lock X-Git-Tag: 1.2.0~60 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b018145a8b6dfacd2845d21c0c9b7f5dc6337ba3;p=thirdparty%2Frspamd.git [Fix] Use CAS for atomic maps lock --- diff --git a/src/libutil/map.c b/src/libutil/map.c index cd4992eabf..377154b8f8 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 */