]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Use stdio buffering to save symbols cache.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 18 Oct 2015 10:12:26 +0000 (11:12 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 18 Oct 2015 10:12:26 +0000 (11:12 +0100)
src/libserver/symbols_cache.c

index 927e84cd55a619d31d4441c687484bba3c4af5c6..df1c316a41c4e9001ec722283fd6b3623d71bfd1 100644 (file)
@@ -463,6 +463,7 @@ rspamd_symbols_cache_save_items (struct symbols_cache *cache, const gchar *name)
        struct ucl_emitter_functions *efunc;
        gpointer k, v;
        gint fd;
+       FILE *f;
        bool ret;
 
        fd = open (name, O_CREAT | O_TRUNC | O_WRONLY, 00644);
@@ -503,10 +504,13 @@ rspamd_symbols_cache_save_items (struct symbols_cache *cache, const gchar *name)
                ucl_object_insert_key (top, elt, k, 0, false);
        }
 
-       efunc = ucl_object_emit_fd_funcs (fd);
+       f = fdopen (fd, "a");
+       g_assert (f != NULL);
+
+       efunc = ucl_object_emit_file_funcs (f);
        ret = ucl_object_emit_full (top, UCL_EMIT_JSON_COMPACT, efunc);
        ucl_object_emit_funcs_free (efunc);
-       close (fd);
+       fclose (f);
 
        return ret;
 }