//============================================================================= // METHOD: SPELLserverCif::login //============================================================================= SPELLipcMessage* SPELLserverCif::login() { DEBUG("[CIF] Sending login message"); // Create the login message SPELLipcMessage loginmsg( ExecutorMessages::REQ_NOTIF_EXEC_OPEN); loginmsg.setType(MSG_TYPE_REQUEST); loginmsg.setSender(getProcId()); loginmsg.setReceiver("CTX"); loginmsg.set( MessageField::FIELD_PROC_ID, getProcId()); loginmsg.set( MessageField::FIELD_CSP, getProcId()); // status loaded is not correct if the procedure did not compile, but the error will be // notified afterwards anyhow. loginmsg.set( MessageField::FIELD_EXEC_STATUS, StatusToString(STATUS_LOADED)); loginmsg.set( MessageField::FIELD_ASRUN_NAME, getAsRunName() ); loginmsg.set( MessageField::FIELD_LOG_NAME, SPELLlog::instance().getLogFile() ); loginmsg.set( MessageField::FIELD_EXEC_PORT, "0" ); /** \todo Remove this, is deprecated */ LOG_INFO("Login information:") LOG_INFO("Proc : " + getProcId() ) LOG_INFO("Status: LOADED") LOG_INFO("AsRun : " + getAsRunName() ) LOG_INFO("Log : " + SPELLlog::instance().getLogFile() ) // Send the login message. // ERRORS: if there is a timeout in this request, an SPELLipcError exception will // be thrown and will make the executor die SPELLipcMessage* response = m_ifc->sendRequest(&loginmsg, SPELL_CIF_LOGIN_TIMEOUT_SEC); DEBUG("[CIF] Login done"); return response; }
//============================================================================= // METHOD: SPELLserverCif::setup //============================================================================= void SPELLserverCif::setup( const std::string& procId, const std::string& ctxName, int ctxPort, const std::string& timeId) { SPELLcif::setup(procId, ctxName, ctxPort, timeId); m_wrMessage.set( MessageField::FIELD_PROC_ID, getProcId() ); m_stMessage.set( MessageField::FIELD_PROC_ID, getProcId() ); m_lnMessage.set( MessageField::FIELD_PROC_ID, getProcId() ); m_ntMessage.set( MessageField::FIELD_PROC_ID, getProcId() ); DEBUG("[CIF] Setup server CIF"); m_ifc = new SPELLipcClientInterface( "CIF", "0.0.0.0", ctxPort ); m_buffer = new SPELLdisplayBuffer( procId, *this ); m_buffer->start(); // Initialize message sequencer m_sequence = 0; m_sequenceStack = 0; m_ifc->initialize( this ); DEBUG("[CIF] Connecting to context"); m_ifc->connectIfc(); // Perform login SPELLipcMessage* response = login(); processLogin(response); m_ready = true; m_useGUI = true; DEBUG("[CIF] Ready to go"); }
inline void receiveStackTrace(MPI_Comm localComm, MPI_Comm globalComm) { int source0 = getProcId(localComm); receiveString(source0, localComm, globalComm); int source1 = getProcId(localComm) + getProcSize(localComm); receiveString(source1, localComm, globalComm); }
//============================================================================= // METHOD: SPELLserverCif::logout //============================================================================= void SPELLserverCif::logout() { DEBUG("[CIF] Sending logout message"); SPELLipcMessage logoutmsg( ExecutorMessages::MSG_NOTIF_EXEC_CLOSE); logoutmsg.setType(MSG_TYPE_ONEWAY); logoutmsg.setSender(getProcId()); logoutmsg.setReceiver("CTX"); logoutmsg.set( MessageField::FIELD_PROC_ID, getProcId()); logoutmsg.set( MessageField::FIELD_EXEC_PORT, "0"); // DEPRECATED m_ifc->sendMessage(&logoutmsg); }
//============================================================================= // METHOD: SPELLserverCif::notifyError //============================================================================= void SPELLserverCif::notifyError( const std::string& error, const std::string& reason, bool fatal ) { DEBUG("[CIF] Error notification: " + error + " (" + reason + ")"); SPELLipcMessage errorMsg( MessageId::MSG_ID_ERROR); errorMsg.setType(MSG_TYPE_ERROR); errorMsg.set( MessageField::FIELD_PROC_ID, getProcId() ); errorMsg.set( MessageField::FIELD_DATA_TYPE, MessageValue::DATA_TYPE_STATUS ); errorMsg.set( MessageField::FIELD_EXEC_STATUS, StatusToString(STATUS_ERROR) ); errorMsg.set( MessageField::FIELD_ERROR, error ); errorMsg.set( MessageField::FIELD_REASON, reason ); if (fatal) { errorMsg.set( MessageField::FIELD_FATAL, PythonConstants::True ); } else { errorMsg.set( MessageField::FIELD_FATAL, PythonConstants::False ); } completeMessage( &errorMsg ); m_asRun->writeErrorInfo( error, reason ); sendGUIMessage(&errorMsg); }
//============================================================================= // METHOD: SPELLserverCif::notifyVariableChange() //============================================================================= void SPELLserverCif::notifyVariableChange( const std::vector<SPELLvarInfo>& changed ) { SPELLipcMessage notifyMsg(ExecutorMessages::MSG_VARIABLE_CHANGE); notifyMsg.setType(MSG_TYPE_ONEWAY); std::string names = ""; std::string types = ""; std::string values = ""; std::string globals = ""; for( unsigned int index = 0; index<changed.size(); index++) { if (names != "") { names += ",,"; types += ",,"; values += ",,"; globals += ",,"; } names += changed[index].varName; types += changed[index].varType; values += changed[index].varValue; globals += changed[index].isGlobal ? "True" : "False"; } notifyMsg.set( MessageField::FIELD_PROC_ID, getProcId() ); notifyMsg.set(MessageField::FIELD_VARIABLE_NAME, names); notifyMsg.set(MessageField::FIELD_VARIABLE_TYPE, types); notifyMsg.set(MessageField::FIELD_VARIABLE_VALUE, values); notifyMsg.set(MessageField::FIELD_VARIABLE_GLOBAL, globals); sendGUIMessage(¬ifyMsg); }
//============================================================================= // METHOD: SPELLserverCif::notifyUserActionUnset //============================================================================= void SPELLserverCif::notifyUserActionUnset() { SPELLipcMessage actionMessage(ExecutorMessages::MSG_ID_DISMISS_UACTION); actionMessage.setType(MSG_TYPE_ONEWAY); actionMessage.set( MessageField::FIELD_PROC_ID, getProcId() ); sendGUIMessage(&actionMessage); }
inline int getDestinationProc(MPI_Comm globalComm) { int numLocalProcs = getProcSize(globalComm) / 3; int myLocalProcId = getProcId(globalComm) % numLocalProcs; int destinationGlobalProcId = myLocalProcId + 2*numLocalProcs; return destinationGlobalProcId; }
inline MPI_Comm splitComm(int color, MPI_Comm globalComm) { int myGlobalId = getProcId(globalComm); MPI_Comm localComm; MPI_Comm_split(MPI_COMM_WORLD, color, myGlobalId, &localComm); return localComm; }
inline std::pair<int,int> getSourceProcs(MPI_Comm globalComm) { int numLocalProcs = getProcSize(globalComm) / 3; int myLocalProcId = getProcId(globalComm) % numLocalProcs; int sourceGlobalIdProc1 = myLocalProcId; int sourceGlobalIdProc2 = myLocalProcId+numLocalProcs; return std::make_pair(sourceGlobalIdProc1, sourceGlobalIdProc2); }
//============================================================================= // METHOD: SPELLserverCif::notifyUserActionEnable //============================================================================= void SPELLserverCif::notifyUserActionEnable( bool enable ) { if (enable) { SPELLipcMessage actionMessage(ExecutorMessages::MSG_ID_ENABLE_UACTION); actionMessage.setType(MSG_TYPE_ONEWAY); actionMessage.set( MessageField::FIELD_PROC_ID, getProcId() ); sendGUIMessage(&actionMessage); } else { SPELLipcMessage actionMessage(ExecutorMessages::MSG_ID_DISABLE_UACTION); actionMessage.setType(MSG_TYPE_ONEWAY); actionMessage.set( MessageField::FIELD_PROC_ID, getProcId() ); sendGUIMessage(&actionMessage); } }
//============================================================================= // METHOD: SPELLserverCif::sendCTXMessage //============================================================================= void SPELLserverCif::sendCTXMessage( SPELLipcMessage* msg ) { static std::string procId = getProcId(); if (m_ready) { DEBUG("[CIF] Sending CTX message"); msg->setSender(procId); msg->setReceiver("CTX"); m_ifc->sendMessage(msg); } }
//============================================================================= // METHOD: SPELLserverCif::sendGUIMessage //============================================================================= void SPELLserverCif::sendGUIMessage( SPELLipcMessage* msg ) { static std::string procId = getProcId(); if (m_ready && m_useGUI) { DEBUG("[CIF] Sending GUI message"); msg->setSender(procId); msg->setReceiver("GUI"); m_ifc->sendMessage(msg); } }
//============================================================================= // METHOD: SPELLserverCif::sendCTXRequest //============================================================================= SPELLipcMessage* SPELLserverCif::sendCTXRequest( SPELLipcMessage* msg, unsigned long timeoutSec ) { static std::string procId = getProcId(); if (m_ready) { DEBUG("[CIF] Sending CTX request: " + msg->data()); msg->setSender(procId); msg->setReceiver("CTX"); SPELLipcMessage* response = m_ifc->sendRequest(msg,timeoutSec); DEBUG("[CIF] Got CTX response"); return response; } return NULL; }
//============================================================================= // METHOD: SPELLserverCif::notifyVariableScopeChange() //============================================================================= void SPELLserverCif::notifyVariableScopeChange( const SPELLscopeInfo& info ) { SPELLipcMessage notifyMsg(ExecutorMessages::MSG_SCOPE_CHANGE); notifyMsg.setType(MSG_TYPE_ONEWAY); notifyMsg.set( MessageField::FIELD_PROC_ID, getProcId() ); std::string varNames = ""; std::string varTypes = ""; std::string varValues = ""; std::string varGlobals = ""; for( unsigned int index = 0; index < info.globalRegisteredVariables.size(); index++) { if (varNames != "") { varNames += ",,"; varTypes += ",,"; varValues += ",,"; varGlobals += ",,"; } varNames += info.globalRegisteredVariables[index].varName; varTypes += info.globalRegisteredVariables[index].varType; varValues += info.globalRegisteredVariables[index].varValue; varGlobals += "True"; } for( unsigned int index = 0; index < info.localRegisteredVariables.size(); index++) { if (varNames != "") { varNames += ",,"; varTypes += ",,"; varValues += ",,"; varGlobals += ",,"; } varNames += info.localRegisteredVariables[index].varName; varTypes += info.localRegisteredVariables[index].varType; varValues += info.localRegisteredVariables[index].varValue; varGlobals += "False"; } notifyMsg.set(MessageField::FIELD_VARIABLE_NAME, varNames); notifyMsg.set(MessageField::FIELD_VARIABLE_TYPE, varTypes); notifyMsg.set(MessageField::FIELD_VARIABLE_VALUE, varValues); notifyMsg.set(MessageField::FIELD_VARIABLE_GLOBAL, varGlobals); sendGUIMessage(¬ifyMsg); }
inline void receiveString(int source, MPI_Comm localComm, MPI_Comm globalComm) { MPI_Status status; int lengthOfString = -1; MPI_Recv(&lengthOfString, 1, MPI_INT, source, STRING_SIZE_TAG, globalComm, &status); // EXPECT_EQ(std::string(testStringValue).length(), static_cast<size_t>(lengthOfString-oneForNullTerminator)); char *receiveString = new char[lengthOfString]; MPI_Recv(receiveString, lengthOfString, MPI_CHAR, source, STRING_TAG, globalComm, &status); // EXPECT_EQ(std::string(testStringValue), std::string(receiveString)); if(getProcId(localComm) == 0) { std::cerr << "Stack Trace from proc " << source << ":\n" << receiveString << std::endl; } delete[] receiveString; }
int CwxAppProcessMgr::checkRunCmd(int argc, char** argv) { pid_t pid; char szProcFile[256]; CwxFile::getLastDirName(argv[0], m_strAppName); m_strAppLockFile ="."; m_strAppLockFile += m_strAppName + ".lock"; CwxAppFramework app; int iRet = app.parse(argc, argv); if (0 != iRet) { app.help(); return 0==iRet?0:-1; } sprintf(szProcFile, "%s%s.pid", app.getWordDir(), m_strAppName.c_str()); m_strPorcfile = szProcFile; if (app.isCmdRestart() || app.isCmdStop()) { //get runing process's pid int iRet = getProcId(m_strPorcfile.c_str()); if (-1 == iRet) return -1; pid = iRet; if (app.isCmdRestart()) { kill(pid, SIGQUIT); } else { kill(pid, SIGQUIT); } return -1; } return 0; }
//============================================================================= // METHOD: SPELLserverCif::notifyUserActionSet //============================================================================= void SPELLserverCif::notifyUserActionSet( const std::string& label, const unsigned int severity ) { SPELLipcMessage actionMessage(ExecutorMessages::MSG_ID_SET_UACTION); actionMessage.setType(MSG_TYPE_ONEWAY); actionMessage.set( MessageField::FIELD_PROC_ID, getProcId() ); actionMessage.set( MessageField::FIELD_ACTION_LABEL, label ); switch(severity) { case LanguageConstants::INFORMATION: actionMessage.set( MessageField::FIELD_ACTION_SEVERITY, MessageValue::DATA_SEVERITY_INFO ); break; case LanguageConstants::WARNING: actionMessage.set( MessageField::FIELD_ACTION_SEVERITY, MessageValue::DATA_SEVERITY_WARN ); break; case LanguageConstants::ERROR: actionMessage.set( MessageField::FIELD_ACTION_SEVERITY, MessageValue::DATA_SEVERITY_ERROR ); break; default: actionMessage.set( MessageField::FIELD_ACTION_SEVERITY, MessageValue::DATA_SEVERITY_INFO ); break; } sendGUIMessage(&actionMessage); }
//============================================================================= // METHOD: SPELLserverCif::sendGUIRequest //============================================================================= SPELLipcMessage* SPELLserverCif::sendGUIRequest( SPELLipcMessage* msg, unsigned long timeoutSec ) { static std::string procId = getProcId(); if (m_ready && m_useGUI) { DEBUG("[CIF] Sending GUI request: " + msg->data()); msg->setSender(procId); msg->setReceiver("GUI"); SPELLipcMessage* response = NULL; try { SPELLsafeThreadOperations ops; response = m_ifc->sendRequest(msg, timeoutSec); } catch(SPELLipcError& ex) { throw SPELLcoreException("Unable to communicate with GUI", STR(ex.what())); } DEBUG("[CIF] Got GUI response"); return response; } return NULL; }
int CwxAppProcessMgr::start(int argc, char** argv, CWX_UINT16 unMaxHeartbeatInternal, CWX_UINT16 unDelaySec) { //chech the your command int ret = checkRunCmd(argc, argv); if (0 != ret) return 0; pid_t pid1, pid2; char szCmd[512]; if ( (pid1 = fork()) < 0) { printf("fork error"); exit(0); } else if (pid1 == 0) { /* first child */ if ( (pid2 = fork()) < 0) { printf("fork error"); exit(0); } else if (pid2 == 0) { /* second child*/ if (0 != regSigHandle()) return -1; //output process pid if (CwxFile::isFile(m_strPorcfile.c_str())) { int iRet = getProcId(m_strPorcfile.c_str()); if (-1 == iRet) exit(0); iRet = isExistProc(m_strAppName.c_str(), iRet); if (-1 == iRet) exit(0); if (iRet) { printf("process is start, if not, delete file:%s\n", m_strPorcfile.c_str()); exit(0); } } sprintf(szCmd, "echo %d > %s", getpid(), m_strPorcfile.c_str()); system(szCmd); while(!m_bExit) { if (CwxAppProcessInfo::PROC_STATE_STOPPED == m_pProcess->m_unState) { FILE* fd=lock();//let child wait parent if (!fd) { exit(0); } startProcess(argc, argv, unDelaySec); sleep(1); unlock(fd);//child can run now. sleep(1); continue; } if (time(NULL) - m_pProcess->m_ttLastChildHeat > unMaxHeartbeatInternal) {//restart child kill(m_pProcess->m_pid, SIGKILL); } sleep(1); } int status; waitpid(m_pProcess->m_pid, &status, 1); //delete pid file CwxFile::rmFile(m_strPorcfile.c_str()); exit(0); } printf("child-1 exist."); exit(0);//it's wait by parent } //first parent. waitpid(pid1, NULL, 0); exit(0); }
//============================================================================= // METHOD: SPELLserverCif::prompt //============================================================================= std::string SPELLserverCif::prompt( const std::string& message, PromptOptions options, unsigned int ptype, unsigned int scope ) { DEBUG("[CIF] Prompt message"); std::string timeStr = getTimestampUsec(); SPELLipcMessage promptMessage(MessageId::MSG_ID_PROMPT); completeMessage( &promptMessage ); promptMessage.setType(MSG_TYPE_PROMPT); promptMessage.set(MessageField::FIELD_PROC_ID, getProcId() ); promptMessage.set(MessageField::FIELD_TEXT, message); promptMessage.set(MessageField::FIELD_DATA_TYPE, ISTR(ptype)); promptMessage.set(MessageField::FIELD_TIME, timeStr); promptMessage.set(MessageField::FIELD_SCOPE, ISTR(scope)); // Used for the prompt display message PromptOptions optionsToShow; DEBUG("[CIF] Prompt typecode " + ISTR(ptype)); if (ptype == LanguageConstants::PROMPT_NUM || ptype == LanguageConstants::PROMPT_ALPHA || ptype == LanguageConstants::PROMPT_DATE ) { DEBUG("[CIF] Prompt is simple"); promptMessage.set(MessageField::FIELD_EXPECTED, ""); } else if ( ptype & LanguageConstants::PROMPT_LIST ) { DEBUG("[CIF] Prompt is list"); PromptOptions::iterator it; int keyCount = 1; std::string optionStr = ""; std::string expectedStr = ""; // Iterate over the option list and build the option and expected values strings for( it = options.begin(); it != options.end(); it++) { std::string key; std::string value; std::string opt = (*it); DEBUG("[CIF] Option: " + opt); if (optionStr.size()>0) optionStr += IPCinternals::OPT_SEPARATOR; if (expectedStr.size()>0) expectedStr += IPCinternals::OPT_SEPARATOR; if ( opt.find(IPCinternals::KEY_SEPARATOR) == std::string::npos ) { // Put an internal key in this case key = ISTR(keyCount); value = opt; // Trim the value trim(value); } else { int idx = opt.find(IPCinternals::KEY_SEPARATOR); key = opt.substr(0, idx); // Trim the key trim(key); value = opt.substr(idx+1, opt.size()-idx); // Trim the value trim(value); } DEBUG("[CIF] Option key: '" + key + "'"); DEBUG("[CIF] Option value: '" + value + "'"); optionStr += key + IPCinternals::KEY_SEPARATOR + value; optionsToShow.push_back(key + ": " + value); if (ptype & LanguageConstants::PROMPT_ALPHA) { expectedStr += value; DEBUG("[CIF] Expected: " + value); } else { expectedStr += key; DEBUG("[CIF] Expected: " + key); } keyCount++; } promptMessage.set(MessageField::FIELD_EXPECTED, expectedStr); promptMessage.set(MessageField::FIELD_OPTIONS, optionStr); } else if (ptype == LanguageConstants::PROMPT_OK) { promptMessage.set(MessageField::FIELD_EXPECTED, "O"); promptMessage.set(MessageField::FIELD_OPTIONS, "O" + IPCinternals::KEY_SEPARATOR + " Ok"); optionsToShow.push_back("O: Ok"); } else if (ptype == LanguageConstants::PROMPT_CANCEL) { promptMessage.set(MessageField::FIELD_EXPECTED, "C"); promptMessage.set(MessageField::FIELD_OPTIONS, "C" + IPCinternals::KEY_SEPARATOR + " Cancel"); optionsToShow.push_back("C: Cancel"); } else if (ptype == LanguageConstants::PROMPT_YES) { promptMessage.set(MessageField::FIELD_EXPECTED, "Y"); promptMessage.set(MessageField::FIELD_OPTIONS, "Y" + IPCinternals::KEY_SEPARATOR + " Yes"); optionsToShow.push_back("Y: Yes"); } else if (ptype == LanguageConstants::PROMPT_NO) { promptMessage.set(MessageField::FIELD_EXPECTED, "N"); promptMessage.set(MessageField::FIELD_OPTIONS, "N" + IPCinternals::KEY_SEPARATOR + " No"); optionsToShow.push_back("N: No"); } else if (ptype == LanguageConstants::PROMPT_YES_NO) { promptMessage.set(MessageField::FIELD_EXPECTED, "Y|N"); promptMessage.set(MessageField::FIELD_OPTIONS, "Y" + IPCinternals::KEY_SEPARATOR + " Yes|N" + IPCinternals::KEY_SEPARATOR + " No"); optionsToShow.push_back("Y: Yes"); optionsToShow.push_back("N: No"); } else if (ptype == LanguageConstants::PROMPT_OK_CANCEL) { promptMessage.set(MessageField::FIELD_EXPECTED, "O|C"); promptMessage.set(MessageField::FIELD_OPTIONS, "O" + IPCinternals::KEY_SEPARATOR + " Ok|C" + IPCinternals::KEY_SEPARATOR + " Cancel"); optionsToShow.push_back("O: Ok"); optionsToShow.push_back("C: Cancel"); } DEBUG("[CIF] Option string: " + promptMessage.get(MessageField::FIELD_OPTIONS)); DEBUG("[CIF] Expected string: " + promptMessage.get(MessageField::FIELD_EXPECTED)); // Write the prompt display std::string msgToShow = message; if (optionsToShow.size()>0) { msgToShow += "\nAvailable options:\n"; for(PromptOptions::iterator pit = optionsToShow.begin(); pit != optionsToShow.end(); pit++) { msgToShow += " - " + (*pit) + "\n"; } } // Send the display message via the buffer to ensure synchronization m_buffer->prompt(msgToShow, LanguageConstants::SCOPE_PROMPT); // Ensure buffer is flushed m_buffer->flush(); // Write the prompt in the asrun m_asRun->writePrompt( getStack(), message, scope ); DEBUG("[CIF] Messsage prepared"); // Send request to client SPELLipcMessage* response = sendGUIRequest(&promptMessage, SPELL_CIF_PROMPT_TIMEOUT_SEC); DEBUG("[CIF] Prompt response received"); std::string toProcess = ""; if (response->getId() == MessageId::MSG_ID_CANCEL) { LOG_WARN("Prompt cancelled"); DEBUG("[CIF] Prompt cancelled"); toProcess = PROMPT_CANCELLED; // Abort execution in this case SPELLexecutor::instance().abort("Prompt cancelled",true); } else if (response->getId() == MessageId::MSG_ID_TIMEOUT) { LOG_ERROR("Prompt timed out"); DEBUG("[CIF] Prompt timed out"); toProcess = PROMPT_TIMEOUT; // Abort execution in this case SPELLexecutor::instance().abort("Prompt timed out", true); } else if (response->getType() == MSG_TYPE_ERROR) { std::string errorMsg = response->get( MessageField::FIELD_ERROR ); DEBUG("[CIF] Prompt error: " + errorMsg ); LOG_ERROR("Prompt error: " + errorMsg); toProcess = PROMPT_ERROR; // \todo Should fix this and use an error code if (errorMsg == "No controlling client") { warning("No controlling client to issue prompt!", LanguageConstants::SCOPE_SYS ); SPELLexecutor::instance().pause(); } else { error( "Prompt error: " + errorMsg, LanguageConstants::SCOPE_SYS ); // Abort execution in this case SPELLexecutor::instance().abort("Prompt error",true); } } else { toProcess = response->get(MessageField::FIELD_RVALUE); DEBUG("[CIF] Prompt response: " + toProcess); } // \todo When there is no controlling client we should keep the child procedure in prompt waiting state // Send the display message via the buffer to ensure synchronization m_buffer->write("Answer: '" + toProcess + "'", LanguageConstants::SCOPE_PROMPT); m_buffer->flush(); m_asRun->writeAnswer( getStack(), toProcess, scope ); return toProcess; }
void MThread::process(){ while (true) { if(thread_stop_flag) { cout<<"MThread stop"<<endl; break; } MESSAGE msg; sleep(1); if(mqueue.getMessage(msg)){ cout<<"no message"<<endl; continue; } cout<<"----"<<endl; char* pData = (char*)msg.msg_pointer; cout<<"process(): "<<pData<<endl; //패킷 해더 검출 HUB_PACKET_HEADER hub_packet_header; memset(&hub_packet_header, 0, HUB_PACKET_HEADER_LEN); memcpy(&hub_packet_header, pData, HUB_PACKET_HEADER_LEN); cout<<(int)hub_packet_header.dst_proc_id<<", "<<(int)hub_packet_header.dst_proc_no<<endl; //데이터 메시지 if(hub_packet_header.msg_type == DATA_MESSAGE) { // 자기 패킷인지 확인 if(getProcId() == hub_packet_header.dst_proc_id && getProcNo() == hub_packet_header.dst_proc_no ) { ssize_t nWrite; cout<<"1111"<<endl; nWrite = write(pData, msg.msg_size); if(nWrite <0) { cerr<<"MThread: write error!"<<endl; } cout<<"2222"<<endl; } else { // 클라이언트 리스트 루프 list<pClient*> & tmp_client_list = g_app.getClientList(); list<pClient*>::iterator itr, itrPrev; for(itr = tmp_client_list.begin(); (itrPrev = itr) != tmp_client_list.end();itr++) { pClient* tmp_client = *itr; //목적 클라이언트 찾으면 포스트 해줌 if(tmp_client->getProcId() == hub_packet_header.dst_proc_id && tmp_client->getProcNo() == hub_packet_header.dst_proc_no ) { tmp_client->postMessage(msg.msg_size, (unsigned long)msg.msg_pointer); break; } } } // 등록 패킷 }else if(hub_packet_header.msg_type == REGISTER_MESSAGE) { setProcInfo(hub_packet_header.src_proc_id, hub_packet_header.src_proc_no); } } }