Beispiel #1
0
static void progress_prepare(liServer *srv, liPlugin *p) {
	mod_progress_data *pd = p->data;
	guint i;

	pd->worker_data = g_slice_alloc0(sizeof(mod_progress_worker_data) * srv->worker_count);
	for (i = 0; i < srv->worker_count; i++) {
		liWorker *wrk = g_array_index(srv->workers, liWorker*, i);

		pd->worker_data[i].pd = pd;
		pd->worker_data[i].wrk_ndx = i;
		pd->worker_data[i].hash_table = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, progress_hashtable_free_callback);
		li_waitqueue_init(&(pd->worker_data[i].timeout_queue), wrk->loop, progress_timeout_callback, pd->ttl, &pd->worker_data[i]);
	}
}
Beispiel #2
0
static void mod_limit_prepare_worker(liServer *srv, liPlugin *p, liWorker *wrk) {
	static gint once = 0;
	mod_limit_data *mld;

	/* initialize once */
	if (g_atomic_int_compare_and_exchange(&once, 0, 1)) {
		mld = g_slice_new(mod_limit_data);
		p->data = mld;
		mld->timeout_queues = g_new0(liWaitQueue, srv->worker_count);
		g_atomic_int_set(&once, 2);
	} else {
		while (g_atomic_int_get(&once) != 2) { }
		mld = p->data;
	}

	li_waitqueue_init(&(mld->timeout_queues[wrk->ndx]), &wrk->loop, "mod_limit timeout queue", mod_limit_timeout_callback, 1.0, NULL);
}
Beispiel #3
0
liStatCache* li_stat_cache_new(liWorker *wrk, gdouble ttl) {
    liStatCache *sc;

    if (ttl < 0) {
        /* fall back to default if not sane */
        ttl = 10.0;
    } else if (ttl == 0) {
        /* ttl means disabled stat cache */
        return NULL;
    }

    sc = g_slice_new0(liStatCache);
    sc->ttl = ttl;
    sc->entries = g_hash_table_new_full((GHashFunc)g_string_hash, (GEqualFunc)g_string_equal, NULL, NULL);
    sc->dirlists = g_hash_table_new_full((GHashFunc)g_string_hash, (GEqualFunc)g_string_equal, NULL, NULL);

    li_waitqueue_init(&sc->delete_queue, &wrk->loop, "stat cache delete queue", stat_cache_delete_cb, ttl, sc);

    return sc;
}