Exemple #1
0
/*{{{ create / destroy */
CacheMng *cache_mng_create (Application *app)
{
    CacheMng *cmng;

    cmng = g_new0 (CacheMng, 1);
    cmng->app = app;
    cmng->h_entries = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, cache_entry_destroy);
    cmng->q_lru = g_queue_new ();
    cmng->size = 0;
    cmng->check_time = time (NULL);
    cmng->max_size = conf_get_uint (application_get_conf (cmng->app), "filesystem.cache_dir_max_size");
    cmng->cache_dir = g_strdup_printf ("%s/%s", 
        conf_get_string (application_get_conf (cmng->app), "filesystem.cache_dir"), CACHE_MNGR_DIR);
    cmng->cache_hits = 0;
    cmng->cache_miss = 0;

    cache_mng_rm_cache_dir (cmng);
    if (g_mkdir_with_parents (cmng->cache_dir, 0700) != 0) {
        LOG_err (CMNG_LOG, "Failed to remove directory: %s", cmng->cache_dir);
        cache_mng_destroy (cmng);
        return NULL;
    }

    return cmng;
}
Exemple #2
0
/*{{{ application_destroy */
static void application_destroy (Application *app)
{
    LOG_debug (APP_LOG, "Destroying application !");

    g_free (app->conf_path);
    if (app->read_client_pool)
        client_pool_destroy (app->read_client_pool);
    if (app->write_client_pool)
        client_pool_destroy (app->write_client_pool);
    if (app->ops_client_pool)
        client_pool_destroy (app->ops_client_pool);

    if (app->dir_tree)
        dir_tree_destroy (app->dir_tree);

    if (app->cmng)
        cache_mng_destroy (app->cmng);

    if (app->sigint_ev)
        event_free (app->sigint_ev);
    if (app->sigterm_ev)
        event_free (app->sigterm_ev);
    if (app->sigpipe_ev)
        event_free (app->sigpipe_ev);
    if (app->sigusr1_ev)
        event_free (app->sigusr1_ev);
     if (app->sigusr2_ev)
        event_free (app->sigusr2_ev);

    if (app->service_con)
        http_connection_destroy (app->service_con);

    if (app->stat_srv)
        stat_srv_destroy (app->stat_srv);

    // destroy Fuse
    if (app->rfuse)
        rfuse_destroy (app->rfuse);

    if (app->dns_base)
        evdns_base_free (app->dns_base, 0);
    if (app->evbase)
        event_base_free (app->evbase);

    if (app->uri)
        evhttp_uri_free (app->uri);

    if (app->conf)
        conf_destroy (app->conf);

    if (app->fuse_opts)
        g_free (app->fuse_opts);

#ifdef SSL_ENABLED
    SSL_CTX_free (app->ssl_ctx);
#endif

#ifdef MAGIC_ENABLED
    magic_close(app->magic_ctx);
#endif

    logger_destroy ();

    if (app->f_log)
        fclose (app->f_log);

    if (app->log_file_name)
        g_free (app->log_file_name);

    g_free (app);

    ENGINE_cleanup ();
    CRYPTO_cleanup_all_ex_data ();
    ERR_free_strings ();
    ERR_remove_thread_state (NULL);
    EVP_cleanup ();
}