int pool_init_new(struct PagePool *pp, char *name, uint16_t page_size, pageno_t pool_size, size_t cache_size) { pooli_init(pp, name, page_size, pool_size, cache_size); pp->fd = open(name, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH); check(pp->fd != -1, "Can't open file '%s' for read/write", name); check(preallocateFile(pp->fd, pool_size) != -1, "Can't preallocate file '%s'", name); bitmask_init(pp); return 0; error: exit(-1); }
/** * Initialise the polling system we are using for the gateway. * * In this case we are using the Linux epoll mechanism */ void poll_init() { int i; if (epoll_fd != -1) return; if ((epoll_fd = epoll_create(MAX_EVENTS)) == -1) { perror("epoll_create"); exit(-1); } memset(&pollStats, 0, sizeof(pollStats)); memset(&queueStats, 0, sizeof(queueStats)); bitmask_init(&poll_mask); n_threads = config_threadcount(); if ((thread_data = (THREAD_DATA *)malloc(n_threads * sizeof(THREAD_DATA))) != NULL) { for (i = 0; i < n_threads; i++) { thread_data[i].state = THREAD_STOPPED; } } #if MUTEX_EPOLL simple_mutex_init(&epoll_wait_mutex, "epoll_wait_mutex"); #endif hktask_add("Load Average", poll_loadav, NULL, POLL_LOAD_FREQ); n_avg_samples = 15 * 60 / POLL_LOAD_FREQ; avg_samples = (double *)malloc(sizeof(double) * n_avg_samples); for (i = 0; i < n_avg_samples; i++) avg_samples[i] = 0.0; evqp_samples = (int *)malloc(sizeof(int) * n_avg_samples); for (i = 0; i < n_avg_samples; i++) evqp_samples[i] = 0.0; number_poll_spins = config_nbpolls(); max_poll_sleep = config_pollsleep(); #if PROFILE_POLL plog = memlog_create("EventQueueWaitTime", ML_LONG, 10000); #endif }