diff options
Diffstat (limited to 'nx-X11')
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/Args.c | 11 | ||||
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/Init.c | 3 | ||||
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/Reconnect.c | 33 | ||||
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/Reconnect.h | 2 | ||||
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/X/NXdispatch.c | 3 |
5 files changed, 51 insertions, 1 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Args.c b/nx-X11/programs/Xserver/hw/nxagent/Args.c index c72b9c4e8..7074a1818 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Args.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Args.c @@ -60,6 +60,7 @@ is" without express or implied warranty. #endif #include "Handlers.h" #include "Error.h" +#include "Reconnect.h" /* * NX includes and definitions. @@ -1090,6 +1091,11 @@ static void nxagentParseOptions(char *name, char *value) return; } + else if (!strcmp(name, "state")) + { + setStatePath(value); + return; + } else if (!strcmp(name, "fullscreen")) { if (nxagentReconnectTrap == True) @@ -1369,6 +1375,11 @@ void nxagentProcessOptionsFile() validateString(nxagentOptionFile)); #endif + /* + * Init statePath + */ + setStatePath(""); + if (nxagentOptionFile == NULL) { return; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Init.c b/nx-X11/programs/Xserver/hw/nxagent/Init.c index 1794f1551..8d4eed2b6 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Init.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Init.c @@ -63,7 +63,7 @@ is" without express or implied warranty. #include "NX.h" #include "NXlib.h" - +#include "Reconnect.h" /* * Set here the required log level. */ @@ -233,6 +233,7 @@ void InitOutput(ScreenInfo *screenInfo, int argc, char *argv[]) fprintf(stderr, "Info: Agent running with pid '%d'.\n", getpid()); fprintf(stderr, "Session: Starting session at '%s'.\n", GetTimeAsString()); + saveAgentState("STARTING"); } /* diff --git a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c index 3c576c6e0..b26fa9cfe 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c @@ -118,6 +118,33 @@ void *reconnectLossyLevel[STEP_NONE]; static enum RECONNECTION_STEP failedStep; +#include <limits.h> + +/* + * Path of state File + */ +char stateFile[PATH_MAX]; + + +void setStatePath(char* path) +{ + strncpy(stateFile, path, PATH_MAX-1); +} + +void saveAgentState(char* state) +{ + FILE* fptr; + if(strlen(stateFile)) + { + fptr=fopen(stateFile, "w"); + if(!fptr) + return; + fprintf(fptr,"%s", state); + fclose(fptr); + } +} + + int nxagentHandleConnectionStates(void) { #ifdef TEST @@ -211,6 +238,7 @@ TODO: This should be reset only when fprintf(stderr, "Session: Display failure detected at '%s'.\n", GetTimeAsString()); fprintf(stderr, "Session: Suspending session at '%s'.\n", GetTimeAsString()); + saveAgentState("SUSPENDING"); } nxagentDisconnectSession(); @@ -265,6 +293,7 @@ TODO: This should be reset only when fprintf(stderr, "Session: Session suspended at '%s'.\n", GetTimeAsString()); #endif } + saveAgentState("SUSPENDED"); nxagentResetDisplayHandlers(); @@ -622,6 +651,7 @@ Bool nxagentReconnectSession(void) #else fprintf(stderr, "Session: Session resumed at '%s'.\n", GetTimeAsString()); #endif + saveAgentState("RUNNING"); nxagentRemoveSplashWindow(NULL); @@ -785,12 +815,14 @@ void nxagentHandleConnectionChanges() if (nxagentSessionState == SESSION_GOING_DOWN) { fprintf(stderr, "Session: Suspending session at '%s'.\n", GetTimeAsString()); + saveAgentState("SUSPENDING"); nxagentDisconnectSession(); } else if (nxagentSessionState == SESSION_GOING_UP) { fprintf(stderr, "Session: Resuming session at '%s'.\n", GetTimeAsString()); + saveAgentState("RESUMING"); if (nxagentReconnectSession()) { @@ -803,6 +835,7 @@ void nxagentHandleConnectionChanges() fprintf(stderr, "Session: Display failure detected at '%s'.\n", GetTimeAsString()); fprintf(stderr, "Session: Suspending session at '%s'.\n", GetTimeAsString()); + saveAgentState("SUSPENDING"); nxagentDisconnectSession(); } diff --git a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.h b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.h index c321bfada..5be2928b8 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.h @@ -34,6 +34,8 @@ void nxagentInitReconnector(void); Bool nxagentReconnectSession(void); int nxagentHandleConnectionStates(void); void nxagentHandleConnectionChanges(void); +void setStatePath(char*); +void saveAgentState(char*); enum SESSION_STATE { diff --git a/nx-X11/programs/Xserver/hw/nxagent/X/NXdispatch.c b/nx-X11/programs/Xserver/hw/nxagent/X/NXdispatch.c index 69ad30d2d..f18c09fe4 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/X/NXdispatch.c +++ b/nx-X11/programs/Xserver/hw/nxagent/X/NXdispatch.c @@ -609,6 +609,7 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio #endif nxagentSessionState = SESSION_UP; + saveAgentState("RUNNING"); } #ifdef BLOCKS @@ -823,6 +824,7 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio */ fprintf(stderr, "Session: Terminating session at '%s'.\n", GetTimeAsString()); + saveAgentState("TERMINATING"); nxagentWaitDisplay(); @@ -833,6 +835,7 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio { NXShadowDestroy(); } + saveAgentState("TERMINATED"); KillAllClients(); DEALLOCATE_LOCAL(clientReady); |