Esempio n. 1
0
/*
 * Initialize the cache in shared memory, or attach to an existing one
 *
 */
void
workfile_mgr_cache_init(void)
{
	CacheCtl cacheCtl;
	MemSet(&cacheCtl, 0, sizeof(CacheCtl));

	cacheCtl.maxSize = gp_workfile_max_entries;
	cacheCtl.cacheName = "Workfile Manager Cache";
	cacheCtl.entrySize = sizeof(workfile_set);
	cacheCtl.keySize = sizeof(((workfile_set *)0)->key);
	cacheCtl.keyOffset = GPDB_OFFSET(workfile_set, key);

	cacheCtl.hash = int32_hash;
	cacheCtl.keyCopy = (HashCopyFunc) memcpy;
	cacheCtl.match = (HashCompareFunc) memcmp;
	cacheCtl.cleanupEntry = workfile_mgr_cleanup_set;
	cacheCtl.populateEntry = workfile_mgr_populate_set;

	cacheCtl.baseLWLockId = FirstWorkfileMgrLock;
	cacheCtl.numPartitions = NUM_WORKFILEMGR_PARTITIONS;

	workfile_mgr_cache = Cache_Create(&cacheCtl);
	Assert(NULL != workfile_mgr_cache);

	/*
	 * Initialize the WorkfileDiskspace and WorkfileQueryspace APIs
	 * to track disk space usage
	 */
	WorkfileDiskspace_Init();
}
Esempio n. 2
0
/*****************************************************************************
 * ContentDir_Create
 *****************************************************************************/
ContentDir* 
ContentDir_Create (void* talloc_context, 
		   UpnpClient_Handle ctrlpt_handle, 
		   IXML_Element* serviceDesc, 
		   const char* base_url)
{
	OBJECT_SUPER_CONSTRUCT (ContentDir, Service_Create, talloc_context,
				ctrlpt_handle, serviceDesc, base_url);
	if (self == NULL)
		goto error; // ---------->
	
	if (CACHE_SIZE > 0 && CACHE_TIMEOUT > 0) {
		self->cache = Cache_Create (self, CACHE_SIZE, CACHE_TIMEOUT,
					    cache_free_expired_data);
		if (self->cache == NULL)
			goto error; // ---------->
		ithread_mutex_init (&self->cache_mutex, NULL);
	}
	
	return self; // ---------->
	
error:
	Log_Print (LOG_ERROR, "ContentDir_Create error");
	if (self) 
		talloc_free (self);
	return NULL;
}
/*
 * Initialize the shared memory data structures needed for MD Versioning
 *
 */
void
mdver_shmem_init(void)
{
	CacheCtl cacheCtl;
	MemSet(&cacheCtl, 0, sizeof(CacheCtl));

	cacheCtl.maxSize = gp_mdver_max_entries;
	cacheCtl.cacheName = MDVER_GLOB_MDVN_SHMEM_NAME;
	cacheCtl.entrySize = sizeof(mdver_entry);
	cacheCtl.keySize = sizeof(((mdver_entry *)0)->key);
	cacheCtl.keyOffset = GPDB_OFFSET(mdver_entry, key);

	cacheCtl.hash = int32_hash;
	cacheCtl.keyCopy = (HashCopyFunc) memcpy;
	cacheCtl.match = (HashCompareFunc) memcmp;
	cacheCtl.equivalentEntries = mdver_entry_equivalent;
	cacheCtl.cleanupEntry = NULL; /* No cleanup necessary */
	cacheCtl.populateEntry = mdver_entry_populate;

	cacheCtl.baseLWLockId = FirstMDVersioningLock;
	cacheCtl.numPartitions = NUM_MDVERSIONING_PARTITIONS;

	mdver_glob_mdvsn = Cache_Create(&cacheCtl);
	Assert(NULL != mdver_glob_mdvsn);

	bool attach = false;
	/* Allocate or attach to shared memory area */
	void *shmem_base = ShmemInitStruct(MDVER_GLOBAL_VER_SHMEM_NAME,
			sizeof(*mdver_global_version_counter),
			&attach);

	mdver_global_version_counter = (int64 *)shmem_base;
	Assert(0 == *mdver_global_version_counter);

}
Esempio n. 4
0
/* ------------------------------------------------------------------------------------
 * Programme principal
 * -------------------
 * Décodage des arguments,
 * Création et initialisation le cache, 
 * Exécution des tests
 * Fermeture (et destruction) du cache.
 * ------------------------------------------------------------------------------------
 */
int main(int argc, char *argv[])
{   
	int i;

   /* Décodage des arguments de la ligne de commande */
     Scan_Args(argc, argv);

    /* Initialisation du cache */
    if ((The_Cache = Cache_Create(File, N_Blocks_in_Cache, N_Records_per_Block,
                                 Record_Size, N_Deref)) == NULL)
	Error("Cache_Init");
    Print_Parameters();

    /* Exécution des tests */
    for (i = 0; i < NTESTS; ++i)
    {
        if (Do_Test[i]) Tests[i]();
    }

    /* Fermeture du cache */
    if (!Cache_Close(The_Cache)) Error("Cache_Close");

    return 0;
}