void PQappendNotify(char *relname, int pid) { PQNotifyList *p; if (pqNotifyList == NULL) pqNotifyList = DLNewList(); p = (PQNotifyList*)pbuf_alloc(sizeof(PQNotifyList)); strncpy(p->relname, relname, NAMEDATALEN); p->be_pid = pid; p->valid = 1; DLAddTail(pqNotifyList, DLNewElem(p)); }
void PQnotifies_init() { Dlelem *e; PQNotifyList *p; if (pqNotifyList == NULL) { pqNotifyList = DLNewList(); } else { /* clean all notifies */ for (e = DLGetHead(pqNotifyList); e != NULL; e = DLGetSucc(e)) { p = (PQNotifyList*)DLE_VAL(e); p->valid = 0; } PQcleanNotify(); } }
/* * Create a new cache instance, or attach to an existing one in shared * memory. * * The cache descriptor is allocated in the top memory context since * we need it for entry cleanup in case of error */ Cache * Cache_Create(CacheCtl *cacheCtl) { Assert(NULL != cacheCtl); Assert(0 != cacheCtl->maxSize); Assert(0 != cacheCtl->keySize); Assert(0 != cacheCtl->entrySize); Assert(NULL != cacheCtl->keyCopy); Assert(NULL != cacheCtl->hash); Assert(NULL != cacheCtl->match); Assert(NULL != cacheCtl->equivalentEntries); Assert(NULL != cacheCtl->cleanupEntry); MemoryContext oldcxt; /* * Create Cache in the TopMemoryContext since this memory context * is still available when calling the transaction callback at the * time when the transaction aborts */ oldcxt = MemoryContextSwitchTo(TopMemoryContext); Cache *cache = (Cache *) palloc0(sizeof(Cache)); cache->keyCopy = cacheCtl->keyCopy; cache->hash = cacheCtl->hash; cache->match = cacheCtl->match; cache->equivalentEntries = cacheCtl->equivalentEntries; cache->cleanupEntry = cacheCtl->cleanupEntry; cache->populateEntry = cacheCtl->populateEntry; /* Create new linked lists in top memory context for cleanup */ cache->ownedEntries = DLNewList(); cache->cacheName = pstrdup(cacheCtl->cacheName); Cache_InitHashtable(cacheCtl, cache); Cache_InitSharedMem(cacheCtl, cache); INSTR_TIME_SET_ZERO(timedOpStart); oldcxt = MemoryContextSwitchTo(oldcxt); return cache; }