|
|
@@ -86,8 +86,11 @@ int g_startDay = 0;
|
|
|
//HANDLE g_logHandle;
|
|
|
char g_allMsg[1024];
|
|
|
#ifdef linux
|
|
|
-void* DoWorkLinux(void* arg);
|
|
|
-void* DoNetControlLinux(void* arg);
|
|
|
+extern "C"
|
|
|
+{
|
|
|
+ void* DoWorkLinux(void* arg);
|
|
|
+ void* DoNetControlLinux(void* arg);
|
|
|
+}
|
|
|
#define FUNCTION_STDCALL
|
|
|
typedef unsigned short WORD;
|
|
|
typedef struct _SYSTEMTIME {
|
|
|
@@ -155,7 +158,7 @@ int BeginThreadRVC(void* (*pFuncLinux)(void*), unsigned int(FUNCTION_STDCALL* pF
|
|
|
//printf("create error!\n");
|
|
|
return 1;
|
|
|
}
|
|
|
- cout << "return of linux thread" << endl;
|
|
|
+ cout << "after pthread_create of linux thread" << endl;
|
|
|
return 0;
|
|
|
#else
|
|
|
_beginthreadex(NULL, 0, pFuncWin, NULL, 0, NULL);
|
|
|
@@ -176,7 +179,7 @@ void StartDoNetControlRVC()
|
|
|
{
|
|
|
#ifdef linux
|
|
|
BeginThreadRVC(DoNetControlLinux, NULL);
|
|
|
- cout << "quit StartDoNetRVC linux begin" << endl;
|
|
|
+ cout << "after DoNetControlLinux thread created." << endl;
|
|
|
#else
|
|
|
BeginThreadRVC(NULL, DoNetControl);
|
|
|
#endif //linux
|
|
|
@@ -193,10 +196,12 @@ void StartDoWorkRVC()
|
|
|
void ServerReportEvent(const char* szFunction,const char* szName="guardian")
|
|
|
{
|
|
|
#ifdef linux
|
|
|
+ return;//oiltest
|
|
|
cout << "oiltest(SPE):" << szFunction << endl;
|
|
|
openlog("guardian", LOG_CONS | LOG_PID, LOG_LOCAL0);
|
|
|
syslog(LOG_ERR, szFunction);
|
|
|
closelog();
|
|
|
+
|
|
|
#else
|
|
|
//LogToFile(false,false,false,szFunction);
|
|
|
HANDLE hEventSource;
|
|
|
@@ -315,12 +320,20 @@ bool VersionRollback()
|
|
|
}
|
|
|
int FrameworkShutdown(bool bUpgrade=false,bool bRestart = true)
|
|
|
{
|
|
|
+ cout << "in FrameworkShutdown,bUpgrade:" << bUpgrade << ",bRestart:" << bRestart << endl;
|
|
|
if (!bUpgrade)
|
|
|
g_dwTimeBegin = GetTickCountRVC();
|
|
|
NetControl();
|
|
|
#ifdef linux
|
|
|
//todo oiltestlinux
|
|
|
+ LogSingleMsg("to kill spshell");
|
|
|
ServerReportEvent("FrameworkShutdown linux");
|
|
|
+ system("killall -9 spshell");
|
|
|
+ system("killall -9 sphost");
|
|
|
+ sleep(2);
|
|
|
+ system("/opt/run/version/spexplorer.sh");
|
|
|
+ LogSingleMsg("after kill spshell");
|
|
|
+ return 0;
|
|
|
#else
|
|
|
STARTUPINFO si;
|
|
|
PROCESS_INFORMATION pi;
|
|
|
@@ -380,7 +393,7 @@ bool ReadRuninfoContent(string &strData)
|
|
|
runinfo.open(strGdRuninfoPath,std::fstream::in|std::fstream::out|std::fstream::binary);
|
|
|
if (!runinfo.is_open())
|
|
|
{
|
|
|
- LogToFile(false, false,false, "open gdruninfo(read) failed.");
|
|
|
+ LogToFile(true, true,false, "open gdruninfo(read) failed.",strerror(errno), errno);
|
|
|
return false;
|
|
|
}
|
|
|
runinfo.seekg(0,ios::end);
|
|
|
@@ -439,9 +452,10 @@ bool IsStartTimeFileExist()
|
|
|
#ifdef linux
|
|
|
void CheckDoWork(int sig)
|
|
|
{
|
|
|
+ cout << "CheckDoWork" << endl;
|
|
|
if (SIGALRM == sig)
|
|
|
{
|
|
|
- LogSingleMsg("to check value");
|
|
|
+ LogSingleMsg("to check value(linux)");
|
|
|
EnterCriticalSectionRVC(g_cs);
|
|
|
|
|
|
if (!g_bFrameQuit)
|
|
|
@@ -455,7 +469,8 @@ void CheckDoWork(int sig)
|
|
|
if ((g_bInUpgrade && ((dwTimeEnd - dwUpgradeTmpBegin) < MAX_WAIT_TIME_TO_RESTART))
|
|
|
&& (!g_bAuthSuc && ((dwTimeEnd - dwTmpBegin) > MAX_WAIT_TIME_TO_RESTART_UPGRADE)))
|
|
|
{
|
|
|
- LogSingleMsg("**in upgrade restart**,to restart framework.");
|
|
|
+ LogSingleMsg("**in upgrade restart**,to restart framework(linux).");
|
|
|
+ cout << "oiltest 0127" << endl;
|
|
|
FrameworkShutdown(true, true);
|
|
|
}
|
|
|
if ((dwTimeEnd - dwTmpBegin) > MAX_WAIT_TIME_TO_RESTART)
|
|
|
@@ -497,15 +512,18 @@ void CheckDoWork(int sig)
|
|
|
}
|
|
|
void* DoWorkLinux(void* arg)
|
|
|
{
|
|
|
- LogSingleMsg("to wait.");
|
|
|
+ //LogSingleMsg("to wait.");
|
|
|
+ cout << "DoWorkLinux" << endl;
|
|
|
signal(SIGALRM, CheckDoWork); //relate the signal and function
|
|
|
alarm(2 * 60); //trigger the timer
|
|
|
- //EndThreadRVC();
|
|
|
+ EndThreadRVC();
|
|
|
//return 0;
|
|
|
}
|
|
|
void* DoNetControlLinux(void* arg)
|
|
|
{
|
|
|
-
|
|
|
+ cout << "to end DoNetControlLinux" << endl;
|
|
|
+ EndThreadRVC();
|
|
|
+ cout << "after end DoNetControlLinux" << endl;
|
|
|
}
|
|
|
void DataProcessLinux(int socket,const char*data)
|
|
|
{
|
|
|
@@ -610,8 +628,6 @@ void DataProcessLinux(int socket,const char*data)
|
|
|
g_bInUpgrade = true;
|
|
|
WriteRunInfoContent("111");
|
|
|
g_dwUpgradeRestartTimeBegin = GetTickCountRVC();
|
|
|
- //Sleep(5000);
|
|
|
- //FrameworkShutdown();
|
|
|
}
|
|
|
else if (pInfo->dwParam1 == 2)//need rollback after upgrade
|
|
|
{
|
|
|
@@ -753,8 +769,6 @@ void DataProcess(LPPER_HANDLE_DATA pPerHandleData,LPPER_IO_OPERATION_DATA pPerIo
|
|
|
g_bInUpgrade = true;
|
|
|
WriteRunInfoContent("111");
|
|
|
g_dwUpgradeRestartTimeBegin = GetTickCountRVC();
|
|
|
- //Sleep(5000);
|
|
|
- //FrameworkShutdown();
|
|
|
}
|
|
|
else if (pInfo->dwParam1 == 2)//need rollback after upgrade
|
|
|
{
|
|
|
@@ -988,6 +1002,7 @@ unsigned int InitListenSocketRVC()
|
|
|
serveraddr.sin_port = htons(default_port);
|
|
|
bind(g_sListen, (sockaddr*)& serveraddr, sizeof(serveraddr));
|
|
|
listen(g_sListen, LISTENQ);
|
|
|
+ cout << "listen on:" << g_sListen << endl;
|
|
|
return g_sListen;
|
|
|
#else
|
|
|
WSADATA wsaData;
|
|
|
@@ -1063,10 +1078,11 @@ void AcceptReqRVC()
|
|
|
{
|
|
|
#ifdef linux
|
|
|
StartDoWorkRVC();
|
|
|
+ cout << "AcceptReqRVC:after StartDoWorkRVC" << endl;
|
|
|
int maxi, connfd, sockfd, nfds;
|
|
|
struct epoll_event events[20];
|
|
|
struct sockaddr_in clientaddr;
|
|
|
- socklen_t clilen;
|
|
|
+ socklen_t clilen = sizeof(struct sockaddr);
|
|
|
ssize_t n;
|
|
|
maxi = 0;
|
|
|
char line[MAXLINE];
|