diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-03-13 22:21:19 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-03-13 22:21:19 +0000 |
commit | b018145a8b6dfacd2845d21c0c9b7f5dc6337ba3 (patch) | |
tree | 0e379621d1936a9146af917215cd5c289f668d81 /src | |
parent | 736880fc8bdb72f06e6a20abb218ad578ae43817 (diff) | |
download | rspamd-b018145a8b6dfacd2845d21c0c9b7f5dc6337ba3.tar.gz rspamd-b018145a8b6dfacd2845d21c0c9b7f5dc6337ba3.zip |
[Fix] Use CAS for atomic maps lock
Diffstat (limited to 'src')
-rw-r--r-- | src/libutil/map.c | 4 |
1 files changed, 1 insertions, 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 */ |