Пример #1
0
bool PortalsSystem::_initPortal(const shared_ptr<Portal> &portal, const String &path, bool recovery, bool start)
{
	shared_ptr<PortalOptions> options(OS_NEW PortalOptions());
	// Carica le impostazioni del portale
	if(options->readFromPath(path) == false)
		return false;

	if(options->getDeleted())
	{
		deletePortal(options, path);
		return false;		// Portale rimosso
	}

	if(portal->load(path, options, recovery) == false)
		return false;

	portal->setCachesSize(getCacheSize());

	if(start)
		portal->start();

	portal->save();

	return true;
}
Пример #2
0
/* stores the given token in our cache and returns true on success. */
bool 
token_cache::storeToken(const char* username, const char* domain_raw,
					   	HANDLE token) {

	char* domain = strdup(domain_raw);
	strupr(domain); // force all domain names to be upper case
	
	if ( getToken(username, domain) ) {
		// if we already have it, just return.
		free(domain);
		return true;
	}

	token_cache_entry *entry;
	MyString key(username);
	key += "@";
	key += domain;

	// now domain has been concatenated, so we can dump it
	free(domain);
	domain = NULL;

	entry = new(token_cache_entry);
	entry->user_token = token;
	entry->age = getNextAge();

	if ( getCacheSize() >= MAX_CACHE_SIZE ) {
		// we need to overwrite a cache entry, since the 
		// max cache size has been reached.

		dprintf(D_FULLDEBUG, "token_cache: Removing oldest token to make space.\n");
		removeOldestToken();
	}
	
	if ( TokenTable->insert(key, entry) < 0) {
		dprintf(D_ALWAYS, "token_cache: failed to cache token!\n");
		return false;
	}
	return true;
}
Пример #3
0
void
Prefetcher::run()
{
    for (;;)
    {
        mutex_req.lock();
        for (;;)
        {
            while (reqfiles.empty() || getCacheSize() == 0)
            {
                cond_req.wait(&mutex_req);
            }

            mutex.lock();
            if (task_filled >= files.count())
            {
                task_no = 0;
                task_filled = 0;
                files.clear();
                files = reqfiles;
                reqfiles.clear();
                cond_get.wakeAll();
                mutex.unlock();
                break;
            }
            mutex.unlock();
        }
        mutex_req.unlock();

        mutex.lock();
        while (task_filled < files.count())
        {
            cond_put.wait(&mutex);
        }
        mutex.unlock();
    }
}