예제 #1
0
파일: pmaxd.c 프로젝트: thefrip/pmaxd
void packetManager(struct PlinkBuffer  * commandBuffer) {
  if (deFormatBuffer(commandBuffer)) {
    DEBUG(LOG_DEBUG, "Packet received");
    logBuffer(LOG_DEBUG,commandBuffer);         
    int cmd_not_recognized=1;
    int i;
    for (i=0;i<Pmax_NBCOMMAND;i++)  {
      if (findCommand(commandBuffer, &PmaxCommand[i]))  {
        PmaxCommand[i].action(commandBuffer);
        cmd_not_recognized=0;
        break;
      }   
    }  
    if ( cmd_not_recognized==1 )  {
      DEBUG(LOG_INFO, "Packet not recognized");
      logBuffer(LOG_INFO, commandBuffer);
      sendBuffer(&PowerlinkCommand[Pmax_ACK]);    
    }                  
  }                                                         
  else  {
    DEBUG(LOG_ERR, "Packet not correctly formated");
    logBuffer(LOG_ERR,commandBuffer);
  }              
  //command has been treated, reset the commandbuffer
  commandBuffer->size=0;                    
        
  DEBUG(LOG_DEBUG, "End of packet treatment");
}
예제 #2
0
static
int
run(int argc, char** argv, ILogOutputter* outputter, StartupFunc startup)
{
	// general initialization
	ARG->m_synergyAddress = new CNetworkAddress;
	ARG->m_config         = new CConfig;
	ARG->m_pname          = ARCH->getBasename(argv[0]);

	// install caller's output filter
	if (outputter != NULL) {
		CLOG->insert(outputter);
	}

	// save log messages
	CBufferedLogOutputter logBuffer(1000);
	CLOG->insert(&logBuffer, true);

	// make the task bar receiver.  the user can control this app
	// through the task bar.
	s_taskBarReceiver = createTaskBarReceiver(&logBuffer);

	// run
	int result = startup(argc, argv);

	// done with task bar receiver
	delete s_taskBarReceiver;

	// done with log buffer
	CLOG->remove(&logBuffer);

	delete ARG->m_config;
	delete ARG->m_synergyAddress;
	return result;
}
예제 #3
0
shaderprogram_t* program_create(shader_t& vertexShader, const char* vertexName, shader_t& fragmentShader, const char* fragmentName)
{
	GLint handle = glCreateProgram();

	glAttachShader(handle, vertexShader.buffer);
	glAttachShader(handle, fragmentShader.buffer);
	glLinkProgram(handle);
	mint_CHECKFORGLERROR;
		
	int32_t logLength, linked;
	glGetProgramiv(handle, GL_LINK_STATUS, &linked);
	glGetProgramiv(handle, GL_INFO_LOG_LENGTH, &logLength);
	if (logLength)
	{
		int32_t charsWritten;
		ScopedRawBuffer<GLchar> logBuffer(malloc(logLength+128));
		glGetProgramInfoLog(handle, logLength, &charsWritten, logBuffer.get());
		log_errorf(ERROR_NONE,"Link results: %s", logBuffer.get());
	}
	if(!linked)
	{
		log_errorf(ERROR_NONE, "Link failed when creating shader program from %s and %s", vertexName, fragmentName);
		return NULL;
	}

	shaderprogram_t* shaderProgram = (shaderprogram_t*) memory_allocate(sizeof(shaderprogram_t), 4, MEMORY_PERSISTENT);
	shaderProgram->program = handle;
	shaderProgram->vertexShader = vertexShader;
	shaderProgram->fragmentShader = fragmentShader;
	return shaderProgram;
}
/*!
	@brief Outputs a log of starting a Checkpoint.
*/
void CheckpointOperationHandler::writeCheckpointStartLog(
	util::StackAllocator &alloc, int32_t mode, PartitionGroupId pgId,
	PartitionId pId, CheckpointId cpId) {
	try {
		util::XArray<uint64_t> dirtyChunkList(alloc);

		util::XArray<ClientId> activeClientIds(alloc);
		util::XArray<TransactionId> activeTxnIds(alloc);
		util::XArray<ContainerId> activeRefContainerIds(alloc);
		util::XArray<StatementId> activeLastExecStmtIds(alloc);
		util::XArray<int32_t> activeTimeoutIntervalSec(alloc);

		TransactionId maxAssignedTxnId = 0;


		transactionManager_->backupTransactionActiveContext(pId,
			maxAssignedTxnId, activeClientIds, activeTxnIds,
			activeRefContainerIds, activeLastExecStmtIds,
			activeTimeoutIntervalSec);

		util::XArray<uint8_t> logBuffer(alloc);
		logManager_->putCheckpointStartLog(logBuffer, pId, maxAssignedTxnId,
			logManager_->getLSN(pId), activeClientIds, activeTxnIds,
			activeRefContainerIds, activeLastExecStmtIds,
			activeTimeoutIntervalSec);
	}
	catch (std::exception &e) {
		GS_RETHROW_USER_ERROR(
			e, "Write checkpoint start log failed. (pgId="
				   << pgId << ", pId=" << pId << ", mode=" << mode << ", cpId="
				   << cpId << ", reason=" << GS_EXCEPTION_MESSAGE(e) << ")");
	}
}
예제 #5
0
int WINAPI
WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int)
{
	CArch arch(instance);
	CLOG;
	CArgs args;

	// save instance
	CMSWindowsScreen::init(instance);

	// get program name
	ARG->m_pname = ARCH->getBasename(__argv[0]);

	// send PRINT and FATAL output to a message box
	CLOG->insert(new CMessageBoxOutputter);

	// save log messages
	CBufferedLogOutputter logBuffer(1000);
	CLOG->insert(&logBuffer, true);

	// make the task bar receiver.  the user can control this app
	// through the task bar.
	s_taskBarReceiver = new CMSWindowsClientTaskBarReceiver(instance,
															&logBuffer);
	s_taskBarReceiver->setQuitJob(new CQuitJob(CThread::getCurrentThread()));

	int result;
	try {
		// run in foreground or as a daemon
		result = run(__argc, __argv);
	}
	catch (...) {
		// note that we don't rethrow thread cancellation.  we'll
		// be exiting soon so it doesn't matter.  what we'd like
		// is for everything after this try/catch to be in a
		// finally block.
		result = kExitFailed;
	}

	// done with task bar receiver
	delete s_taskBarReceiver;

	// done with log buffer
	CLOG->remove(&logBuffer);

	// let user examine any messages if we're running as a backend
	// by putting up a dialog box before exiting.
	if (ARG->m_backend && s_hasImportantLogMessages) {
		char msg[1024];
		msg[0] = '\0';
		LoadString(instance, IDS_FAILED, msg, sizeof(msg) / sizeof(msg[0]));
		MessageBox(NULL, msg, ARG->m_pname, MB_OK | MB_ICONWARNING);
	}

	delete CLOG;
	return result;
}
예제 #6
0
void Logger::log(Priority priority, const char* function, const char* file, int line, const char* name_space, const char* format, ...)
{
    if(priority <= mPriority)
    {
        char buffer[1024];
        va_list arguments;

        va_start(arguments, format);
        vsnprintf(buffer, sizeof(buffer), format, arguments);
        va_end(arguments);

        logBuffer(priority,function,file,line,name_space,buffer);
    }
}
예제 #7
0
파일: pmaxd.c 프로젝트: thefrip/pmaxd
void sendBuffer(struct PlinkBuffer * Buff)  {
  int i,err;
  struct PlinkBuffer writeBuffer;
  DEBUG(LOG_DEBUG, "Sending the following buffer");  
  logBuffer(LOG_DEBUG,Buff);
  writeBuffer.buffer[0]=0x0D;
  for (i=0;i<(Buff->size);i++)
    writeBuffer.buffer[i+1]=Buff->buffer[i];
  writeBuffer.buffer[Buff->size+1]=calculChecksum(Buff);
  writeBuffer.buffer[2+Buff->size]=0x0A;
  writeBuffer.size=Buff->size+3;
  err=write(fd,writeBuffer.buffer,Buff->size+3);
  DEBUG(LOG_DEBUG, "Result of write: %i",err); 	
}
/*!
	@brief Outputs a log of metadata of Chunk.
*/
void CheckpointOperationHandler::writeChunkMetaDataLog(
	util::StackAllocator &alloc, int32_t mode, PartitionGroupId pgId,
	PartitionId pId, CheckpointId cpId, bool isRestored) {
	try {
		if (isRestored) {
			int32_t count = 0;
			util::XArray<uint8_t> logBuffer(alloc);
			util::XArray<uint8_t> metaDataBinary(alloc);

			ChunkCategoryId categoryId;
			ChunkId chunkId;
			ChunkId startChunkId = 0;
			int64_t scanSize = chunkManager_->getScanSize(pId);
			ChunkManager::MetaChunk *metaChunk =
				chunkManager_->begin(pId, categoryId, chunkId);
			GS_TRACE_INFO(CHECKPOINT_SERVICE_DETAIL, GS_TRACE_CP_STATUS,
				"writeChunkMetaDataLog: pId=" << pId <<
					",chunkId" << chunkId);


			for (int64_t index = 0; index < scanSize; index++) {
				uint8_t tmp[LogManager::LOGMGR_VARINT_MAX_LEN * 2 + 1];
				uint8_t *addr = tmp;
				if (!metaChunk) {
					tmp[0] = 0xff;
					++addr;
					uint32_t dummyData = 0;
					addr += util::varIntEncode64(addr, dummyData);  
					if (chunkManager_->isBatchFreeMode(categoryId)) {
						addr += util::varIntEncode32(addr, dummyData);
					}
				}
				else {
					tmp[0] = metaChunk->getUnoccupiedSize();
					++addr;
					int64_t filePos = metaChunk->getCheckpointPos();
					assert(filePos != -1);
					addr += util::varIntEncode64(addr, filePos);
					if (chunkManager_->isBatchFreeMode(categoryId)) {
						addr += util::varIntEncode32(
							addr, metaChunk->getChunkKey());
					}
					GS_TRACE_DEBUG(CHECKPOINT_SERVICE_DETAIL,
						GS_TRACE_CP_STATUS,
						"chunkMetaData: (chunkId,"
							<< chunkId << ",freeInfo,"
							<< (int32_t)metaChunk->getUnoccupiedSize()
							<< ",pos," << metaChunk->getCheckpointPos()
							<< ",chunkKey," << metaChunk->getChunkKey());
				}
				metaDataBinary.push_back(tmp, (addr - tmp));
				++count;
				if (count == CHUNK_META_DATA_LOG_MAX_NUM) {
					logManager_->putChunkMetaDataLog(logBuffer, pId, categoryId,
						startChunkId, count, &metaDataBinary, false);
					GS_TRACE_INFO(CHECKPOINT_SERVICE_DETAIL, GS_TRACE_CP_STATUS,
						"writeChunkMetaDaLog,pgId,"
							<< pgId << ",pId," << pId << ",chunkCategoryId,"
							<< (int32_t)categoryId << ",startChunkId,"
							<< startChunkId << ",chunkNum," << count);

					startChunkId += count;
					count = 0;
					metaDataBinary.clear();
					logBuffer.clear();
				}

				ChunkCategoryId prevCategoryId = categoryId;
				metaChunk = chunkManager_->next(pId, categoryId, chunkId);
				if (categoryId != prevCategoryId) {
					if (count > 0) {

						logManager_->putChunkMetaDataLog(logBuffer, pId,
							prevCategoryId, startChunkId, count,
							&metaDataBinary, false);
						GS_TRACE_INFO(CHECKPOINT_SERVICE_DETAIL,
							GS_TRACE_CP_STATUS,
							"writeChunkMetaDaLog,pgId,"
								<< pgId << ",pId," << pId << ",chunkCategoryId,"
								<< (int32_t)prevCategoryId << ",startChunkId,"
								<< startChunkId << ",chunkNum," << count);
						startChunkId = 0;
						count = 0;
						metaDataBinary.clear();
						logBuffer.clear();
					}
				}
			}  

			logBuffer.clear();
			logManager_->putChunkMetaDataLog(
				logBuffer, pId, UNDEF_CHUNK_CATEGORY_ID, 0, 1, NULL, true);
		}
		else {
			util::XArray<uint8_t> logBuffer(alloc);
			logManager_->putChunkMetaDataLog(
				logBuffer, pId, UNDEF_CHUNK_CATEGORY_ID, 0, 0, NULL, true);
		}  
	}
	catch (std::exception &e) {
		GS_RETHROW_USER_ERROR(
			e, "Write chunk meta data log failed. (pgId="
				   << pgId << ", pId=" << pId << ", mode=" << mode << ", cpId="
				   << cpId << ", reason=" << GS_EXCEPTION_MESSAGE(e) << ")");
	}
}