bool CServiceManager::incomingLoad(const Service::Uid & service) { LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__); mSystemServicesMutex.lock(); tServiceSet::const_iterator it = mSystemServices.find(service); if (mSystemServices.end() == it) { LOG4CPLUS_ERROR( msLogger, "incomingLoad(" + service.value() + "): failed to find service"); mSystemServicesMutex.unlock(); return false; } mSystemServicesMutex.unlock(); if(isServiceAlreadyLoaded(service)) { return true; } CService * pService = new CService(mXmlPath, mAppInfo, service); mCallbacksMutex.lock(); if (!pService->incomingLoad(mCallbacks)) { mCallbacksMutex.unlock(); delete pService; LOG4CPLUS_ERROR( msLogger, "pService->incomingLoad(" + service.value() + ") return false"); return false; } mCallbacksMutex.unlock(); mActiveServicesMutex.lock(); mActiveServices[service] = pService; mActiveServicesMutex.unlock(); return true; }
int main(int, char **) { Logger logger = Logger::getInstance(LOG4CPLUS_TEXT("utils.Test")); PropertyConfigurator::doConfigure(LOG4CPLUS_TEXT("log4cplus.properties")); LOG4CPLUS_ERROR(logger, "Test start"); CTimeoutManager * pInstance = CTimeoutManager::getInstance(); pInstance->addSubscriber(new CSubscriber("\n### three ###\n", 3), 500); pInstance->addSubscriber(new CSubscriber("\n### one ###\n", 1), 450); CSubscriber * pSub = new CSubscriber("\n### empty ###\n", -10); pInstance->addSubscriber(pSub, 500); pInstance->addSubscriber(new CSubscriber("\n### four ###\n", 4), 900); pInstance->removeSubscriber(pSub); pInstance->addSubscriber(new CSubscriber("\n### two ###\n", 2), 450); gSem.waitTimeout(2000); if (5 == gCount) { LOG4CPLUS_ERROR(logger, "Test passed!\n OK OK OK OK OK OK OK OK OK OK OK OK"); } else { LOG4CPLUS_ERROR(logger, "Test failed, gCount = " + convertIntegerToString(gCount)); } CTimeoutManager::deleteInstance(); CTimeoutManager::getInstance(); // check quick deleteing of CTimeoutManager instance CTimeoutManager::deleteInstance(); }
bool PmpIpcProtocol::getProfileLibPathResponse(const std::string & path, iviLink::Ipc::DirectionID const& dirId) { LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__ ); CBuffer writeBuf = mWriteBufMgr.getBuffer(); ProfileManager::Ipc::PmMessage* req = reinterpret_cast<ProfileManager::Ipc::PmMessage*>(writeBuf.get()); req->header.type = ProfileManager::Ipc::PMP_PMAL_GET_PROFILE_LIB_PATH; iviLink::Ipc::Helpers::CBufferWriter writer(req->data, writeBuf.getSize() - sizeof(req->header)); BaseError err = writer.write(path); if (!err.isNoError()) { LOG4CPLUS_ERROR(msLogger, static_cast<std::string>(err)); return false; } req->header.size = writer.getUsedSize(); iviLink::Ipc::MsgID id = mMsgIdGen.getNext(); UInt32 const reqSize = sizeof(ProfileManager::Ipc::PmMessage) + req->header.size; err = mIpc->asyncRequest(id, writeBuf.get(), reqSize, &dirId); if (!err.isNoError()) { LOG4CPLUS_ERROR(msLogger, static_cast<std::string>(err)); return false; } return true; }
/** * brief: * * @returns */ void RespProcessor::doIt() { char buffer[16*1024] = {'\0'}; ResponseManager* pRespMgr = ResponseManager::getInstance(); assert(NULL != pRespMgr); while(true) { CmdTask resp; bool ret = pRespMgr->getRespTask(resp); if(!ret) { LOG4CPLUS_WARN(CLogger::logger, "response array is empty."); continue; } SessionBase* pSession = _sess_mgr_prt->getSession(resp.seqno); if(NULL == pSession) { LOG4CPLUS_ERROR(CLogger::logger, "can't find the session by " << resp.seqno); delete resp.pCmd; resp.pCmd = NULL; continue; } int64_t uid = resp.pCmd->get_userid(); string name = resp.pCmd->get_cmd_name(); memset(buffer, '\0', 16 * 1024); int length = resp.pCmd->header_length() + resp.pCmd->body_length(); ret = resp.pCmd->encode((byte*)buffer, length); resp.releaseCmd(); if(!ret) { LOG4CPLUS_ERROR(CLogger::logger, "command encode failed for " << name); continue; } pSession->write2Send(string(buffer, length)); int iret = pSession->sendBuffer(); uint64_t data = U64(resp.seqno, pSession->getFd()); if(SOCKET_EAGAIN == iret) //socket»º³åÇøдÂú { _epoll_svr_ptr->notify(pSession->getFd(), data, EVENT_WRITE); } else if(SOCKET_ERR == iret) //socket ³ö´í { _epoll_svr_ptr->notify(pSession->getFd(), data, EVENT_ERROR); _sess_mgr_prt->freeSession(pSession); _client_mgr_prt->freeClient(uid, resp.seqno); } LOG4CPLUS_INFO(CDebugLogger::logger, "TimeTace: request[" << resp.idx << "] to response[" << name << "] spend time " << current_time_usec() - resp.timestamp); Index::free(resp.idx); } }
CServerControl::CServerControl(IMediaControlServerProfile_API::Callbacks* callbacks) : //mpMutex(new CMutex()), mVTranscode(VCODE) , mATranscode(ACODE) , mServerPath(MediaServerName) , mFd(0) , mStop ("stop;") , mResume("resume;") , mPause("pause;") , mAudio("audio") , mVideo("video") , mPlay ("play;") { LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__); assert(callbacks); pipe (fds); char path[MAXPATHLEN]; getcwd(path, MAXPATHLEN); LOG4CPLUS_INFO(msLogger, "!!!!!!!!!!!!!!!!!!!!!!!!!!"); LOG4CPLUS_INFO(msLogger, "path: " + std::string(path)); mServerPath = std::string(path) + "/" + mServerPath; LOG4CPLUS_INFO(msLogger, "full path: "+ mServerPath); #ifndef ANDROID pid_t pid = fork(); switch (pid) { case -1: { LOG4CPLUS_ERROR(msLogger, "after fork pid = -1"); return; break; } case 0: { LOG4CPLUS_INFO(msLogger, "child"); close(fds[1]); char fd_str[15]; sprintf(fd_str, "%i", fds[0]); if (execl(mServerPath.c_str(), mServerPath.c_str(), fd_str, NULL)) { LOG4CPLUS_ERROR(msLogger, "execl(server) failed"); killProcess(1); } killProcess(1); } default: { LOG4CPLUS_INFO(msLogger, "parent"); close(fds[0]); file = fdopen(fds[1], "w"); break; } } #else callbacks->startVlcServer(fds[0], true); file = fdopen(fds[1], "w"); #endif //ANDROID }
static void ForwardString(log4cplus::Logger &app_instance, LogLevel log_level, const char *out_string) { if (out_string == NULL) out_string = ""; #ifdef _Windows # pragma warning(push) # pragma warning(disable:4127) #endif // #ifdef _Windows switch (log_level) { case LogLevel_Literal : LOG4CPLUS_TRACE(app_instance, out_string); break; case LogLevel_Spam : LOG4CPLUS_TRACE(app_instance, out_string); break; case LogLevel_Minutiae : LOG4CPLUS_TRACE(app_instance, out_string); break; case LogLevel_Debug : LOG4CPLUS_DEBUG(app_instance, out_string); break; case LogLevel_Detail : LOG4CPLUS_DEBUG(app_instance, out_string); break; case LogLevel_Info : LOG4CPLUS_INFO(app_instance, out_string); break; case LogLevel_Notice : LOG4CPLUS_WARN(app_instance, out_string); break; case LogLevel_Warning : LOG4CPLUS_WARN(app_instance, out_string); break; case LogLevel_Error : LOG4CPLUS_ERROR(app_instance, out_string); break; case LogLevel_Critical : LOG4CPLUS_ERROR(app_instance, out_string); break; case LogLevel_Alert : LOG4CPLUS_ERROR(app_instance, out_string); break; case LogLevel_Emergency : LOG4CPLUS_ERROR(app_instance, out_string); break; case LogLevel_Fatal : LOG4CPLUS_FATAL(app_instance, out_string); break; default : LOG4CPLUS_ERROR(app_instance, out_string); break; #ifdef _Windows # pragma warning(pop) #endif // #ifdef _Windows } }
void RTSPMJPEGClient::threadLoop(RTSPMJPEGClientParameters *parameters) { int clientId = parameters->clientId; RTSPMJPEGClient *instance = getInstance(); RTSPMJPEGClientStruct *pClient = instance->clients[clientId]; if (pClient == NULL) { pClient = new RTSPMJPEGClientStruct; pClient->clientId = clientId; pClient->state = RTSPMJPEGCLIENT_STATE_CLEANED; pClient->isWaiting = false; pClient->newFramesNum = 0; pClient->next = 0; for (int i = 0; i < RTSPMJPEGCLIENT_FRAME_QUEUE_LEN; i++) { pClient->frameQueue[i] = (uint8_t * ) av_malloc(RTSPMJPEGCLIENT_FRAME_BUFFER_SIZE); pClient->frameSizes[i] = 0; } instance->clients[clientId] = pClient; LOG4CPLUS_DEBUG(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_OUTPUT_LOGGER)), "[CLIENT " << pClient->clientId << "] allocated space for a new client..."); } LOG4CPLUS_TRACE(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_OUTPUT_LOGGER)), "[CLIENT " << pClient->clientId << "] threadLoop()..."); pClient->address = ((RTSPMJPEGClientParameters * ) parameters)->address; delete parameters; if (instance->_init(pClient) < 0) { instance->_clean(pClient, RTSPMJPEGCLIENT_STATE_ERROR); LOG4CPLUS_ERROR(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_ERROR_LOGGER)), "[CLIENT " << pClient->clientId << "] init failed!"); LOG4CPLUS_ERROR(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_OUTPUT_LOGGER)), "[CLIENT " << pClient->clientId << "] init failed!"); return; } pClient->state = RTSPMJPEGCLIENT_STATE_LOOPING; while (pClient->state == RTSPMJPEGCLIENT_STATE_LOOPING && instance->_readFrame(pClient) == 0) LOG4CPLUS_DEBUG(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_OUTPUT_LOGGER)), "[CLIENT " << pClient->clientId << "] while()..."); // set CLEANED only if it was correctly stopped. ERROR otherwise. Don't set // any state greater then CLEANED because they're all states indicating an // action being taken instance->_clean(pClient, pClient->state == RTSPMJPEGCLIENT_STATE_STOPPING ? RTSPMJPEGCLIENT_STATE_CLEANED : RTSPMJPEGCLIENT_STATE_ERROR); }
void RTSPMJPEGClient::_logAVError(RTSPMJPEGClientStruct *pClient, int error) { if (av_strerror(error, pClient->errbuf, RTSPMJPEGCLIENT_ERRBUF_SIZE) == 0) { LOG4CPLUS_ERROR(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_ERROR_LOGGER)), "[CLIENT " << pClient->clientId << "] LibAV error: " << pClient->errbuf); LOG4CPLUS_ERROR(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_OUTPUT_LOGGER)), "[CLIENT " << pClient->clientId << "] LibAV error: " << pClient->errbuf); } else { LOG4CPLUS_ERROR(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_ERROR_LOGGER)), "[CLIENT " << pClient->clientId << "] LibAV error: Unknown error..."); LOG4CPLUS_ERROR(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_OUTPUT_LOGGER)), "[CLIENT " << pClient->clientId << "] LibAV error: Unknown error..."); } }
bool TestManager::RunUpdateConsumption(TestParameters* testParameters) const { Logger logger = Logger::getInstance(TESTER_LOGGER_NAME); char* pcEnd; string sCartridgeNum = GetValue("CartridgeNum", testParameters); unsigned char ucCartridgeNum = (unsigned char)strtol(sCartridgeNum.c_str(), &pcEnd, 10); if (*pcEnd != 0) { LOG4CPLUS_ERROR(logger, "Invalid cartridge num (" << sCartridgeNum << ")."); return false; } string sConsumption = GetValue("Consumption", testParameters); string sMaxConsumption; size_t idx = sConsumption.find(".."); if (idx != string::npos) { sMaxConsumption = sConsumption.substr(idx + 2, sConsumption.length() - (idx + 2)); sConsumption = sConsumption.substr(0, idx); } else { sMaxConsumption = sConsumption; } unsigned int uiConsumption = (unsigned int)strtol(sConsumption.c_str(), &pcEnd, 10); if (*pcEnd != 0) { LOG4CPLUS_ERROR(logger, "Invalid consumption (" << sConsumption << ")."); return false; } unsigned int uiMaxConsumption = (unsigned int)strtol(sMaxConsumption.c_str(), &pcEnd, 10); if (*pcEnd != 0) { LOG4CPLUS_ERROR(logger, "Invalid consumption (" << sMaxConsumption << ")."); return false; } uiConsumption += (rand() % (uiMaxConsumption - uiConsumption + 1)); unsigned int originalVolume = m_volumes[ucCartridgeNum]; testParameters->Result = materialMonitor->UpdateConsumption(ucCartridgeNum, uiConsumption, &m_volumes[ucCartridgeNum]); if (testParameters->Result != IDTLIB_SUCCESS) { m_volumes[ucCartridgeNum] = originalVolume; } return testParameters->Result == testParameters->ExpectedResult; }
bool PmpIpcProtocol::incomingProfile(iviLink::BaseUid const& profileUid, iviLink::Profile::ApiUid const& papiUid, iviLink::Profile::IUid const& piuid, iviLink::Service::Uid const& serviceUID, iviLink::Ipc::DirectionID const& dirId) { LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__ ); CBuffer writeBuf = mWriteBufMgr.getBuffer(); ProfileManager::Ipc::PmMessage* req = reinterpret_cast<ProfileManager::Ipc::PmMessage*>(writeBuf.get()); req->header.type = ProfileManager::Ipc::PMP_PMAL_INCOMMING_PROFILE; iviLink::Ipc::Helpers::CBufferWriter writer(req->data, writeBuf.getSize() - sizeof(req->header)); BaseError err = writer.write(profileUid); if (!err.isNoError()) { LOG4CPLUS_ERROR(msLogger, static_cast<std::string>(err)); return false; } err = writer.write(papiUid); if (!err.isNoError()) { LOG4CPLUS_ERROR(msLogger, static_cast<std::string>(err)); return false; } err = writer.write(piuid); if (!err.isNoError()) { LOG4CPLUS_ERROR(msLogger, static_cast<std::string>(err)); return false; } err = writer.write(serviceUID); if (!err.isNoError()) { LOG4CPLUS_ERROR(msLogger, static_cast<std::string>(err)); return false; } req->header.size = writer.getUsedSize(); iviLink::Ipc::MsgID id = mMsgIdGen.getNext(); UInt32 const reqSize = sizeof(ProfileManager::Ipc::PmMessage) + req->header.size; err = mIpc->asyncRequest(id, writeBuf.get(), reqSize, &dirId); return err.isNoError(); }
ErrorCode DiskWriteTask::ExecuteDiskWrite(boost::shared_ptr<SmallFileLocalDisk> disk) { boost::filesystem::path resource_folder_path = disk->GetResourceFolderPath(resource_identifier_); LOG4CPLUS_TRACE(Loggers::LocalDisk(), "DiskWriteTask::Execute(): Writing "<<resource_identifier_.GetResourceName()<<"("<<blocks_.size()<<" blocks) into disk " << disk->GetDiskPath()); if (boost::filesystem::exists(resource_folder_path)) { LOG4CPLUS_TRACE(Loggers::LocalDisk(), "DiskWriteTask::Execute(): resource directory "<<resource_folder_path<<" already exists."); } else if (!boost::filesystem::create_directories(resource_folder_path)) { LOG4CPLUS_ERROR(Loggers::LocalDisk(), "DiskWriteTask::Execute(): Failed to create directory "<<resource_folder_path); return ErrorCodes::DiskWriteFailure; } size_t resource_size = 0; assert(blocks_.size() > 0); if (blocks_.size() == 0) { LOG4CPLUS_WARN(Loggers::LocalDisk(), "DiskWriteTask::Execute(): An attempt to write empty blocks to "<<resource_folder_path<<" is rejected."); return ErrorCodes::UnknownError; } for(std::map<size_t, boost::shared_ptr<BlockData> >::const_iterator iter = blocks_.begin(); iter != blocks_.end(); ++iter) { size_t block_index = iter->first; boost::shared_ptr<BlockData> block_data = iter->second; if (block_data) { boost::filesystem::path block_file_path = disk->GetResourceBlockFilePath(resource_identifier_, block_index); LOG4CPLUS_TRACE(Loggers::LocalDisk(), "DiskWriteTask::Execute(): Writing block file "<<block_file_path); if (block_data->WriteFile(block_file_path)) { resource_size += block_data->Size(); } else { LOG4CPLUS_ERROR(Loggers::LocalDisk(), "DiskWriteTask::Execute(): Failed to write "<<block_file_path); } } } disk->UpdateResource(resource_identifier_); return ErrorCodes::Success; }
BlockData::BlockData(const boost::filesystem::path& block_file_path) { block_data_bytes_ = 0; bytes_ = 0; int file_descriptor = open(block_file_path.file_string().c_str(), O_RDONLY | O_DIRECT); if (file_descriptor < 0) { LOG4CPLUS_ERROR(Loggers::Service(), "Failed to open file "<<block_file_path<<" to read."); return; } block_data_bytes_ = reinterpret_cast<char*>(BlockDataAllocator::Instance().Allocate()); if (!block_data_bytes_) { LOG4CPLUS_ERROR(Loggers::Service(), "Failed to allocate aligned memory buffer."); close(file_descriptor); return; } //read up to MaxBlockSize bytes to the buffer size_t offset(0); int bytes_read(0); int bytes_left(BlockData::MaxBlockSize); do { bytes_read = pread(file_descriptor, block_data_bytes_ + offset, bytes_left, offset); if (bytes_read > 0) { bytes_left -= bytes_read; offset += bytes_read; } } while (bytes_left > 0 && bytes_read > 0); if (bytes_read < 0) { LOG4CPLUS_ERROR(Loggers::Service(), "An error occurred while reading file file "<<block_file_path); close(file_descriptor); BlockDataAllocator::Instance().Free(block_data_bytes_); block_data_bytes_ = 0; return; } close(file_descriptor); bytes_ = offset; }
void ChannelServer::send_data_stress_test_core(bool confirm) { iviLink::Error error = iviLink::Channel::allocateChannel(gSendData, this, cid); if (!error.isNoError() || cid == 0) { LOG4CPLUS_ERROR(logger, "send_data_stress_test allocation failed"); return; } else { LOG4CPLUS_ERROR(logger, "send_data_stress_test allocation successful, signaling to client"); } mCliSyncSem.signal(); mSrvSyncSem.wait(); }
bool writeToQueue(std::string jsonResult) { try { Beanstalk::Client client(BEANSTALK_QUEUE_HOST, BEANSTALK_PORT); client.use(BEANSTALK_TUBE_NAME); int id = client.put(jsonResult); if (id <= 0) { LOG4CPLUS_ERROR(logger, "Failed to write data to queue"); return false; } LOG4CPLUS_DEBUG(logger, "put job id: " << id ); } catch (const std::runtime_error& error) { LOG4CPLUS_WARN(logger, "Error connecting to Beanstalk. Result has not been saved."); return false; } return true; }
void ScreenSharingViewer::onInitDone(iviLink::ELaunchInfo launcher) { if (iviLink::LAUNCHED_BY_USER == launcher) { startedByUser = true; LOG4CPLUS_INFO(msLogger, "started by user"); registerProfileCallbacks(iviLink::Profile::ApiUid("ScreenSharingProfile_PAPI_UID"), this); //loading service with required UID iviLink::Error loadError = loadService(iviLink::Service::Uid("ScreenSharingViewerService")); if (loadError.isNoError()) { LOG4CPLUS_INFO(msLogger, "ScreenSharingViewer::initDone() : sending data : " + getMessageTypeStr(iviLink::SCR_SHARING_START) ); if (mpViewerProfileProxy) mpViewerProfileProxy->sendData(getMessageTypeStr(iviLink::SCR_SHARING_START) ); } else { LOG4CPLUS_ERROR(msLogger, "service NOT started: " + loadError.toString()); qApp->quit(); } } //if application was launched by other side else { startedByUser = false; LOG4CPLUS_INFO(msLogger, "started by iviLink"); } }
void NaviPlayer::onInitDone(iviLink::ELaunchInfo launcher) { LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__); if (iviLink::LAUNCHED_BY_USER == launcher) { LOG4CPLUS_INFO(msLogger, "started by user"); LOG4CPLUS_INFO(msLogger, "Registering profile callbacks"); registerProfileCallbacks(iviLink::Profile::ApiUid("NaviReceiverProfile_PAPI_UID"),this); mpParent->setText("Loading..."); iviLink::Error loadError = loadService(iviLink::Service::Uid(SERVICE)); if (loadError.isNoError()) { LOG4CPLUS_INFO(msLogger, "service started successfully!"); mpParent->setText("Click to exit"); mpParent->setEnabled(true); } else { LOG4CPLUS_ERROR(msLogger, std::string("service NOT started") + loadError.toString()); kill(getpid(), SIGKILL); } } else { LOG4CPLUS_INFO(msLogger, "started by iviLink"); } }
void config_handler::handle_request(const request& req, reply& rep) { timer t; mem_counter mc; boost::scoped_ptr<argos::common::ExecutionContext> pctx(the_index_->create_context()); argos::common::ExecutionContext &ctx=*(pctx.get()); try { rep.content=the_index_->get_field_config()->serialize(); rep.status = reply::ok; rep.headers.resize(2); rep.headers[0].name = "Content-Length"; rep.headers[0].value = boost::lexical_cast<std::string>(rep.content.size()); rep.headers[1].name = "Content-Type"; rep.headers[1].value = "application/xml"; } catch(...) { rep=reply::stock_reply(reply::internal_server_error); LOG4CPLUS_ERROR(err, "CLIENT:" << req.peer << ", CODE:" << rep.status << " - " << req.uri); } LOG4CPLUS_INFO(acc, "CLIENT:" << req.peer << ", CODE:" << rep.status << ", TIME:" << t*1000 << "ms, MEM:" << mc << ", CL:" << rep.content.size() << ", QID:[], URL:" << req.uri); if (ctx.temp_pool->get_used_size()>3*1024*1024) { ctx.temp_pool->reset(); } }
/** * Callback that should be invoked by application library thread * after initialization application in application manager */ void CBasicSample::onInitDone(iviLink::ELaunchInfo launcher) { //if application was launched by user if (iviLink::LAUNCHED_BY_USER == launcher) { LOG4CPLUS_INFO(msLogger, "started by user"); //loading service with required UID iviLink::Error loadError = loadService(iviLink::Service::Uid("BasicSampleService")); if (loadError.isNoError()) { LOG4CPLUS_INFO(msLogger, "service started"); //loading profile proxy which corresponds to given service UID CBasicSampleProfileProxy sampleProxy(iviLink::Service::Uid("BasicSampleService")); //using method from profile API sampleProxy.sendOperands(8,21); } else { LOG4CPLUS_ERROR(msLogger, std::string("service NOT started: ") + loadError.toString()); mpSemaphore->signal(); } } //if application was launched by other side else { LOG4CPLUS_INFO(msLogger, "started by iviLink"); } }
bool Sampling::QueryUserHead(UserLLink userhead) { LOG4CPLUS_INFO(LogUtil::GetInstance()->GetLogger() ,"QueryUserHead start"); vector<PrunUser> prunUserV; string query = "select uid,value from userHead order by value asc"; if(DbUtil::GetInstance()->DbQueryPrunUser(query,prunUserV)) { LOG4CPLUS_ERROR(LogUtil::GetInstance()->GetLogger() ,"DbQueryPrunUser fail"); return false; } for(unsigned int i=0;i<prunUserV.size();i++) { UserL *q = (struct UserL *)malloc(sizeof(UserL)); q->uid = prunUserV[i].uid; q->value = prunUserV[i].value; q->next = userhead->next; userhead->next = q; } LOG4CPLUS_INFO(LogUtil::GetInstance()->GetLogger() ,"QueryUserHead end"); return true; }
void ChannelSupervisorWatchdog::checkChannels() { LOG4CPLUS_TRACE_METHOD(mLogger, __PRETTY_FUNCTION__); time_t currentTime; ChannelInfo channelInfo; UInt32 channelId = CHANNEL_ID_START_NUMBER + 1; for (; channelId < Map::getInstance()->getNextFreeChannelId(); ++channelId) { time(¤tTime); if (Map::getInstance()->getChannelInfo(channelId, channelInfo)) { if (channelInfo.mTag.empty()) { LOG4CPLUS_WARN(mLogger, "tag for channel id is empty " + convertIntegerToString(channelId)); continue; } UInt32 diffMillis = (UInt32) difftime(currentTime, channelInfo.mTimeStamp) * 1000; LOG4CPLUS_INFO(mLogger, "diffMillis for " + convertIntegerToString(channelId) + "|" + channelInfo.mTag + " is " + convertIntegerToString(diffMillis)); if (diffMillis > DEALLOCATE_TIMEOUT_MS) { LOG4CPLUS_ERROR(mLogger, "ChannelSupervisorWatchdog::checkChannels: channel " + convertIntegerToString(channelId) + "|" + channelInfo.mTag + " not responsive"); ::forceChannelDeallocation(channelId); Map::getInstance()->invalidateChannelInfo(channelId); LOG4CPLUS_INFO(mLogger, "ChannelSupervisorWatchdog::checkChannels: channel " + convertIntegerToString(channelId) + " deallocated"); } } else { LOG4CPLUS_WARN(mLogger, "channel id not in map: " + convertIntegerToString(channelId)); } } }
void ChannelServer::send_big_data_test() { currentTest = BIG_DATA_TEST_ID; iviLink::Error error = iviLink::Channel::allocateChannel(gBigData, this, cid); if (!error.isNoError() || cid == 0) { LOG4CPLUS_ERROR(logger, "send_big_data_test allocation failed"); return; } else { LOG4CPLUS_ERROR(logger, "send_big_data_test allocation success, signaling to client to proceed"); } mCliSyncSem.signal(); mSrvSyncSem.wait(); }
void Logging::Error(const string& msg) { if("" == logger_name_) { fprintf(stderr, "has not set logger\n"); return; } LOG4CPLUS_ERROR(logger_, msg); }
void ChannelServer::smoke_test() { currentTest = SMOKE_TEST_ID; iviLink::Error error = iviLink::Channel::allocateChannel(gSmokeTest, this, cid); if (!error.isNoError() || cid == 0) { LOG4CPLUS_ERROR(logger, "smoke test allocation failed"); return; } else { LOG4CPLUS_ERROR(logger, "smoke test allocation success, signaling to client"); } mCliSyncSem.signal(); mSrvSyncSem.wait(); }
void PmpSessionProtocol::onReceivedServicesList(PMPFrame * frame) { LOG4CPLUS_TRACE_METHOD(mLogger, __PRETTY_FUNCTION__ ); assert(mEventFactory); if (!frame) { LOG4CPLUS_ERROR(mLogger, "No frame"); return; } UInt32 count; memcpy(&count,frame->data,sizeof(count)); count = ByteOrder::ntoh32(count); int pos = sizeof(count); LOG4CPLUS_INFO(mLogger, "RES COUNT : " + convertIntegerToString(count)); std::list<Service::Uid> services; for (UInt32 i = 0; i<count; ++i) { std::string str = bufferToString(frame->data+pos,true); services.push_back(Service::Uid(str)); pos += stringInBufSize(str); } mEventFactory->receiveRemoteWaitingServiceList(services); }
CError CPmpCoreProtocol::getAvailableProfileComplements(std::list<Profile::Uid> & complements) { LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__ ); PMPFrame * pReq = new PMPFrame; pReq->size = sizeof(PMPFrame); pReq->reqType = PMP_REQ_CORE_GET_COMPLEMENTS; PMPFrame * pResp = mpPmpProtocol->makeCoreRequest(*pReq); delete pReq; if (!pResp) { LOG4CPLUS_ERROR(msLogger, "Network error"); return CPmpError(CPmpError::ERROR_NETWORK); } UInt32 count; memcpy(&count,pResp->data,4); count = ByteOrder::ntoh32(count); int pos = 4; LOG4CPLUS_INFO(msLogger, "RES COUNT : " + convertIntegerToString(count)); for (UInt32 i = 0; i<count; ++i) { std::string str = bufferToString(pResp->data+pos,true); complements.push_back(Profile::Uid(str)); pos += stringInBufSize(str); } delete[] pResp; return CPmpError::NoPmpError(); }
bool TestManager::RunRemoveCartridge(TestParameters* testParameters) const { Logger logger = Logger::getInstance(TESTER_LOGGER_NAME); char* pcEnd; string sCartridgeNum = GetValue("CartridgeNum", testParameters); unsigned char ucCartridgeNum = (unsigned char)strtol(sCartridgeNum.c_str(), &pcEnd, 10); if (*pcEnd != 0) { LOG4CPLUS_ERROR(logger, "Invalid cartridge num (" << sCartridgeNum << ")."); return false; } testParameters->Result = materialMonitor->RemoveCartridge(ucCartridgeNum); if (testParameters->Result == IDTLIB_SUCCESS) { if (ucCartridgeNum < IDT_COUNT && m_materialInfo[ucCartridgeNum] != NULL) { delete[] m_materialInfo[ucCartridgeNum]; m_materialInfo[ucCartridgeNum] = NULL; } } return testParameters->Result == testParameters->ExpectedResult; }
virtual void go() { LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__); pthread_barrier_t bar; if (int err = pthread_barrier_init(&bar, NULL, count)) { LOG4CPLUS_ERROR(msLogger, "pthread_barrier_init err = " + convertIntegerToString(err) + strerror(err)); assert(false && "pthread_barrier_init err"); } mpPool = new CThreadPool(count); CSignalSemaphore sem; for (UInt32 i = 0; i < count; ++i) { JobBarrierData* jbd = new JobBarrierData; jbd->pBar = &bar; jbd->pSem = &sem; CThreadPoolJob job(MultipleOpenCloseMultithreadTest::job, jbd); mpPool->addJob(job); } LOG4CPLUS_INFO(msLogger, "sem wait"); sem.wait(); LOG4CPLUS_INFO(msLogger, "sem wait done"); delete mpPool; }
//from CChannelHandler void CMediaSourceServerProfile::onBufferReceived(const iviLink::Channel::tChannelId channel, iviLink::Buffer const& buffer) { LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__ ); if (mChannelID != channel) { LOG4CPLUS_ERROR(msLogger, "mChannelID != channel_id"); return; } else { LOG4CPLUS_INFO(msLogger, "mChannelID == channel_id"); } UInt8 *incomingData = buffer.getBuffer(); int read_size = buffer.getSize(); LOG4CPLUS_INFO(msLogger, "Procedure ID = " + convertIntegerToString(incomingData[0])); if(incomingData[0] == REQUESTTRACKLIST) { LOG4CPLUS_INFO(msLogger, "case REQUESTTRACKLIST"); mpAppCallbacks->onRequestTrackList(true); } else { LOG4CPLUS_INFO(msLogger, "unknown procedure ID"); } }
bool TestManager::RunAuthenticateCartridge(TestParameters* testParameters) const { Logger logger = Logger::getInstance(TESTER_LOGGER_NAME); char* pcEnd; string sCartridgeNum = GetValue("CartridgeNum", testParameters); unsigned char ucCartridgeNum = (unsigned char)strtol(sCartridgeNum.c_str(), &pcEnd, 10); if (*pcEnd != 0) { LOG4CPLUS_ERROR(logger, "Invalid cartridge num (" << sCartridgeNum << ")."); return false; } unsigned char* pucPubKS; unsigned char aucPubKS[PUBLIC_KEY_SIZE]; string sPubKS = GetValue("PubKS", testParameters); if (sPubKS.empty()) { pucPubKS = NULL; } else { size_t keySize = sizeof(aucPubKS); ReadFileContent(m_testsFolder, sPubKS, aucPubKS, &keySize); pucPubKS = aucPubKS; } unsigned char cert[CERTIFICATE_SIZE]; unsigned short certLength; memset(cert, 0, CERTIFICATE_SIZE); testParameters->Result = materialMonitor->AuthenticateCartridge(ucCartridgeNum, pucPubKS, cert, &certLength, &m_volumes[ucCartridgeNum]); return testParameters->Result == testParameters->ExpectedResult; }
void CStateUpdater::initDone(iviLink::ELaunchInfo launcher) { if (iviLink::LAUNCHED_BY_USER == launcher) { LOG4CPLUS_INFO(mLogger, "started by user"); std::string msg = std::string("trying to load service ")+std::string(SERVICE_NAME); LOG4CPLUS_INFO(mLogger, msg); if (loadService(iviLink::Service::Uid(SERVICE_NAME))) { isInitDone = true; LOG4CPLUS_INFO(mLogger, "service started"); } else { LOG4CPLUS_ERROR(mLogger, "service NOT started"); return; } } else { isInitDone = true; LOG4CPLUS_INFO(mLogger, "started by iviLink"); } CSeatClientProxy * clientProxy = new CSeatClientProxy(iviLink::Service::Uid(SERVICE_NAME)); mpRequestProcessor->setProxy(clientProxy); if(isQmlReady) { LOG4CPLUS_INFO(mLogger, "GUI is ready, sending init request"); mpRequestProcessor->initRequest(); //otherwise the request will be called when it is } }