]> source.dussan.org Git - rspamd.git/commitdiff
Remove statfile pool size as it was broken.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 15 Nov 2013 17:13:05 +0000 (17:13 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 15 Nov 2013 17:13:05 +0000 (17:13 +0000)
src/main.c
src/statfile.c
src/statfile.h

index 4e62ec76803077e0b99eb2fb36efefc681e071e4..50e295398de73a5272e2939df83affda96801284 100644 (file)
@@ -1228,7 +1228,7 @@ main (gint argc, gchar **argv, gchar **env)
        setproctitle ("main process");
 
        /* Init statfile pool */
-       rspamd_main->statfile_pool = statfile_pool_new (rspamd_main->server_pool, rspamd_main->cfg->max_statfile_size, rspamd_main->cfg->mlock_statfile_pool);
+       rspamd_main->statfile_pool = statfile_pool_new (rspamd_main->server_pool, rspamd_main->cfg->mlock_statfile_pool);
 
        event_init ();
        g_mime_init (0);
index c2ca572130b968452cfb804772afe9de56476604..9930e0fe05e5f9a333db3ec417c91c4638295bea 100644 (file)
@@ -167,51 +167,13 @@ statfile_pool_check (stat_file_t * file)
 }
 
 
-struct expiration_data {
-       statfile_pool_t                *pool;
-       guint64                         oldest;
-       gchar                           *filename;
-};
-
-
-static gint
-statfile_pool_expire (statfile_pool_t * pool)
-{
-       struct expiration_data          exp;
-       stat_file_t                    *file;
-       gint                            i;
-
-       if (pool->opened == 0) {
-               return -1;
-       }
-
-       exp.pool = pool;
-       exp.oldest = ULLONG_MAX;
-       exp.filename = NULL;
-
-       for (i = 0; i < pool->opened; i++) {
-               file = &pool->files[i];
-               if ((guint64) file->access_time < exp.oldest) {
-                       exp.oldest = file->access_time;
-                       exp.filename = file->filename;
-               }
-       }
-
-       if (exp.filename) {
-               statfile_pool_close (pool, file, TRUE);
-       }
-
-       return 0;
-}
-
 statfile_pool_t                *
-statfile_pool_new (memory_pool_t *pool, size_t max_size, gboolean use_mlock)
+statfile_pool_new (memory_pool_t *pool, gboolean use_mlock)
 {
        statfile_pool_t                *new;
 
        new = memory_pool_alloc0 (pool, sizeof (statfile_pool_t));
        new->pool = memory_pool_new (memory_pool_get_size ());
-       new->max = max_size;
        new->files = memory_pool_alloc0 (new->pool, STATFILES_MAX * sizeof (stat_file_t));
        new->lock = memory_pool_get_mutex (new->pool);
        new->mlock_ok = use_mlock;
@@ -344,28 +306,13 @@ statfile_pool_open (statfile_pool_t * pool, gchar *filename, size_t size, gboole
                return NULL;
        }
 
-       if (!forced && (gsize)st.st_size > pool->max) {
-               msg_info ("cannot attach file to pool, too large: %Hz", (size_t) st.st_size);
-               return NULL;
-       }
-
        memory_pool_lock_mutex (pool->lock);
        if (!forced && abs (st.st_size - size) > (gint)sizeof (struct stat_file)) {
                memory_pool_unlock_mutex (pool->lock);
                msg_warn ("need to reindex statfile old size: %Hz, new size: %Hz", st.st_size, size);
                return statfile_pool_reindex (pool, filename, st.st_size, size);
        }
-       memory_pool_unlock_mutex (pool->lock);
-
-       while (!forced && (pool->max + pool->opened * sizeof (struct stat_file) * 2 < pool->occupied + st.st_size)) {
-               if (statfile_pool_expire (pool) == -1) {
-                       /* Failed to find any more free space in pool */
-                       msg_info ("expiration for pool failed, opening file %s failed", filename);
-                       return NULL;
-               }
-       }
 
-       memory_pool_lock_mutex (pool->lock);
        new_file = &pool->files[pool->opened++];
        bzero (new_file, sizeof (stat_file_t));
        if ((new_file->fd = open (filename, O_RDWR)) == -1) {
@@ -404,7 +351,6 @@ statfile_pool_open (statfile_pool_t * pool, gchar *filename, size_t size, gboole
        }
        unlock_file (new_file->fd, FALSE);
 
-       pool->occupied += st.st_size;
        new_file->open_time = time (NULL);
        new_file->access_time = new_file->open_time;
        new_file->lock = memory_pool_get_mutex (pool->pool);
@@ -439,7 +385,6 @@ statfile_pool_close (statfile_pool_t * pool, stat_file_t * file, gboolean keep_s
        /* Move the remain statfiles */
        memmove (pos, ((guint8 *)pos) + sizeof (stat_file_t),
                        (--pool->opened - (pos - pool->files)) * sizeof (stat_file_t));
-       pool->occupied -= file->len;
 
        memory_pool_unlock_mutex (pool->lock);
 
@@ -753,18 +698,6 @@ statfile_pool_add_section (statfile_pool_t * pool, stat_file_t * file, guint32 c
        fsync (file->fd);
        file->len += length;
 
-       if (file->len > pool->max) {
-               msg_info ("cannot attach file to pool, too large: %z", file->len);
-               return FALSE;
-       }
-
-       while (pool->max <= pool->occupied + file->len) {
-               if (statfile_pool_expire (pool) == -1) {
-                       /* Failed to find any more free space in pool */
-                       msg_info ("expiration for pool failed, opening file %s failed", file->filename);
-                       return FALSE;
-               }
-       }
        if ((file->map = mmap (NULL, file->len, PROT_READ | PROT_WRITE, MAP_SHARED, file->fd, 0)) == NULL) {
                msg_info ("cannot mmap file %s, error %d, %s", file->filename, errno, strerror (errno));
                return FALSE;
index b6c6d001174c781972980bb635a20e044dbf6a18..ced4f2207f10ba31ae6db81227c264289031a090 100644 (file)
@@ -88,8 +88,6 @@ typedef struct statfile_pool_s {
        stat_file_t *files;                                             /**< hash table of opened files indexed by name */
        void **maps;                                                    /**< shared hash table of mmaped areas indexed by name  */
        gint opened;                                                            /**< number of opened files                             */
-       size_t max;                                                             /**< maximum size                                               */
-       size_t occupied;                                                /**< current size                                               */
        memory_pool_t *pool;                                    /**< memory pool object                                 */
        memory_pool_mutex_t *lock;                              /**< mutex                                                              */
        struct event  *invalidate_event;        /**< event for pool invalidation        */
@@ -106,7 +104,7 @@ struct statfile;
  * @param max_size maximum size
  * @return statfile pool object
  */
-statfile_pool_t* statfile_pool_new (memory_pool_t *pool, size_t max_size, gboolean use_mlock);
+statfile_pool_t* statfile_pool_new (memory_pool_t *pool, gboolean use_mlock);
 
 /**
  * Open statfile and attach it to pool