static void* threadFunc(void* arg_ptr) { int j, k, startKey, endKey; int xid, count = 0; int bufferCurrentLength, bufferTotalSize; char* insertBuffer; /* Allocate the buffer that stores all outstanding hash table insertions. */ bufferTotalSize = BUFFER_INITIAL_LENGTH; bufferCurrentLength = 0; insertBuffer = stasis_malloc(bufferTotalSize, char); xid = Tbegin(); k = (intptr_t) arg_ptr; startKey = baseKey + (k * opsPerThread); endKey = startKey + opsPerThread; for (j = startKey; j < endKey; j++) { ThashInsert(xid, hashTable, (byte*)&j, sizeof(int), (byte*)&j, sizeof(int)); writeKeyToBuffer(&insertBuffer, &bufferCurrentLength, &bufferTotalSize, j); count++; if ((count % opsPerTransaction) == 0) { /* Prior to committing the transaction, write the hash table insertion buffer to * the insert-log so that we can keep track of which insertions were possibly * committed. After the Tcommit() call, write the insertion buffer to the commit- * log so that we can keep track of which insertions were definitely committed. */ writeBufferToLog(insertLog, insertBuffer, bufferCurrentLength); Tcommit(xid); writeBufferToLog(commitLog, insertBuffer, bufferCurrentLength); bufferCurrentLength = 0; xid = Tbegin(); count = 0; } } /* Prior to committing the transaction, write the hash table insertion buffer to * the insert-log so that we can keep track of which insertions were possibly * committed. After the Tcommit() call, write the insertion buffer to the commit- * log so that we can keep track of which insertions were definitely committed. */ writeBufferToLog(insertLog, insertBuffer, bufferCurrentLength); Tcommit(xid); writeBufferToLog(commitLog, insertBuffer, bufferCurrentLength); return NULL; }
static char* writePolicyToBuffer(KonohaContext *kctx, logconf_t *logconf, char *buftop, char *bufend, KTraceInfo *trace) { if((logconf->policy & HasLocation)) { buftop = writeKeyToBuffer(TEXTSIZE("LogPoint"), buftop, bufend); writeToBuffer('"', buftop, bufend); if(KFlag_Is(int, logconf->policy, PeriodicPoint)) { buftop = writeFixedTextToBuffer(TEXTSIZE("PeriodicPoint,"), buftop, bufend); } if(KFlag_Is(int, logconf->policy, ResponseCheckPoint)) { buftop = writeFixedTextToBuffer(TEXTSIZE("ResponseCheckPoint,"), buftop, bufend); } if(KFlag_Is(int, logconf->policy, SystemChangePoint)) { buftop = writeFixedTextToBuffer(TEXTSIZE("SystemChangePoint,"), buftop, bufend); } if(KFlag_Is(int, logconf->policy, SecurityAudit)) { buftop = writeFixedTextToBuffer(TEXTSIZE("SecurityAudit,"), buftop, bufend); } buftop[-1] = '"'; buftop[0] = ','; buftop[1] = ' '; buftop+=2; }
buftop = writeFixedTextToBuffer(TEXTSIZE("ResponseCheckPoint,"), buftop, bufend); } if(KFlag_Is(int, logconf->policy, SystemChangePoint)) { buftop = writeFixedTextToBuffer(TEXTSIZE("SystemChangePoint,"), buftop, bufend); } if(KFlag_Is(int, logconf->policy, SecurityAudit)) { buftop = writeFixedTextToBuffer(TEXTSIZE("SecurityAudit,"), buftop, bufend); } buftop[-1] = '"'; buftop[0] = ','; buftop[1] = ' '; buftop+=2; } if((logconf->policy & HasFault)) { if(!(logconf->policy & HasLocation)) { buftop = writeKeyToBuffer(TEXTSIZE("LogPoint"), buftop, bufend); buftop = writeTextToBuffer("ErrorPoint", buftop, bufend); buftop[0] = ','; buftop[1] = ' '; buftop+=2; } buftop = writeKeyToBuffer(TEXTSIZE("FaultType"), buftop, bufend); writeToBuffer('"', buftop, bufend); if(KFlag_Is(int, logconf->policy, SystemFault)) { buftop = writeFixedTextToBuffer(TEXTSIZE("SystemFault,"), buftop, bufend); } if(KFlag_Is(int, logconf->policy, SoftwareFault)) { buftop = writeFixedTextToBuffer(TEXTSIZE("SoftwareFault,"), buftop, bufend); } if(KFlag_Is(int, logconf->policy, UserFault)) { buftop = writeFixedTextToBuffer(TEXTSIZE("UserFault,"), buftop, bufend);