Unverified Commit a3d493a6 authored by Mike Gabriel's avatar Mike Gabriel

Merge branch 'uli42-pr/clarify_sleep' into 3.6.x

parents 4213bf46 ede842c2
...@@ -1365,7 +1365,7 @@ static void nxagentParseSingleOption(char *name, char *value) ...@@ -1365,7 +1365,7 @@ static void nxagentParseSingleOption(char *name, char *value)
validateString(value), validateString(name), sleep_parse); validateString(value), validateString(name), sleep_parse);
} }
nxagentChangeOption(SleepTime, sleep_parse); nxagentChangeOption(SleepTimeMillis, sleep_parse);
return; return;
} }
else if (!strcmp(name, "tolerancechecks")) else if (!strcmp(name, "tolerancechecks"))
......
...@@ -235,18 +235,18 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask) ...@@ -235,18 +235,18 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask)
* display. * display.
*/ */
if (NXDisplayError(nxagentDisplay) == 1 && nxagentShadowCounter == 0 && nxagentOption(SleepTime) > 0) if (NXDisplayError(nxagentDisplay) == 1 && nxagentShadowCounter == 0 && nxagentOption(SleepTimeMillis) > 0)
{ {
#ifdef TEST #ifdef TEST
fprintf(stderr, "nxagentBlockHandler: sleeping for %d milliseconds for slowdown.\n", fprintf(stderr, "nxagentBlockHandler: sleeping for %d milliseconds for slowdown.\n",
nxagentOption(SleepTime)); nxagentOption(SleepTimeMillis));
#endif #endif
usleep(nxagentOption(SleepTime) * 1000); usleep(nxagentOption(SleepTimeMillis) * 1000);
now = GetTimeInMillis(); now = GetTimeInMillis();
} }
#ifdef TEST #ifdef TEST
else if (0 == nxagentOption(SleepTime)) { else if (0 == nxagentOption(SleepTimeMillis)) {
fprintf(stderr, "nxagentBlockHandler: not sleeping for slowdown.\n"); fprintf(stderr, "nxagentBlockHandler: not sleeping for slowdown.\n");
} }
#endif #endif
...@@ -708,16 +708,16 @@ void nxagentShadowBlockHandler(void * data, struct timeval **timeout, void * mas ...@@ -708,16 +708,16 @@ void nxagentShadowBlockHandler(void * data, struct timeval **timeout, void * mas
nxagentHandleConnectionChanges(); nxagentHandleConnectionChanges();
} }
if (nxagentSessionState == SESSION_DOWN && nxagentOption(SleepTime) > 0) if (nxagentSessionState == SESSION_DOWN && nxagentOption(SleepTimeMillis) > 0)
{ {
#ifdef TEST #ifdef TEST
fprintf(stderr, "nxagentShadowBlockHandler: sleeping for %d milliseconds for slowdown.\n", fprintf(stderr, "nxagentShadowBlockHandler: sleeping for %d milliseconds for slowdown.\n",
nxagentOption(SleepTime)); nxagentOption(SleepTimeMillis));
#endif #endif
usleep(nxagentOption(SleepTime) * 1000); usleep(nxagentOption(SleepTimeMillis) * 1000);
} }
#ifdef TEST #ifdef TEST
else if (0 == nxagentOption(SleepTime)) { else if (0 == nxagentOption(SleepTimeMillis)) {
fprintf(stderr, "nxagentShadowBlockHandler: not sleeping for slowdown.\n"); fprintf(stderr, "nxagentShadowBlockHandler: not sleeping for slowdown.\n");
} }
#endif #endif
......
...@@ -492,9 +492,19 @@ void nxagentPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, ...@@ -492,9 +492,19 @@ void nxagentPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
if (nxagentShadowCounter == 0 && if (nxagentShadowCounter == 0 &&
NXDisplayError(nxagentDisplay) == 1 && NXDisplayError(nxagentDisplay) == 1 &&
nxagentOption(SleepTime) > 0) nxagentOption(SleepTimeMillis) > 0)
{ {
int us = nxagentOption(SleepTime) * 4 * (length / 1024); /*
* The original NX code had 250us (microseconds) * length/1024
* here and 50ms (milliseconds) elsewhere. Later ONE combined
* configurable sleep parameter was introduced, having a default
* of 50ms (that's milliseconds, not microseconds!), which is
* factor 200. For unknown reasons the factor was changed to 250
* at the same time. Ensure the value is somewhere between 10ms
* and 1s.
*/
int us = nxagentOption(SleepTimeMillis) * 1000 * (length / 1024) / 250;
us = (us < 10000 ? 10000 : (us > 1000000 ? 1000000 : us)); us = (us < 10000 ? 10000 : (us > 1000000 ? 1000000 : us));
......
...@@ -157,7 +157,7 @@ void nxagentInitOptions(void) ...@@ -157,7 +157,7 @@ void nxagentInitOptions(void)
nxagentOptions.Xinerama = 1; nxagentOptions.Xinerama = 1;
nxagentOptions.SleepTime = DEFAULT_SLEEP_TIME; nxagentOptions.SleepTimeMillis = DEFAULT_SLEEP_TIME_MILLIS;
nxagentOptions.ReconnectTolerance = DEFAULT_TOLERANCE; nxagentOptions.ReconnectTolerance = DEFAULT_TOLERANCE;
......
...@@ -36,7 +36,9 @@ ...@@ -36,7 +36,9 @@
#define UNDEFINED -1 #define UNDEFINED -1
#define COPY_UNLIMITED -1 #define COPY_UNLIMITED -1
#define DEFAULT_SLEEP_TIME 50
/* in milliseconds */
#define DEFAULT_SLEEP_TIME_MILLIS 50
extern unsigned int nxagentPrintGeometryFlags; extern unsigned int nxagentPrintGeometryFlags;
...@@ -366,9 +368,9 @@ typedef struct _AgentOptions ...@@ -366,9 +368,9 @@ typedef struct _AgentOptions
int Xinerama; int Xinerama;
/* /*
* Sleep delay in microseconds. * Sleep delay in milliseconds.
*/ */
unsigned int SleepTime; unsigned int SleepTimeMillis;
/* /*
* Tolerance - tightens or loosens reconnect checks. * Tolerance - tightens or loosens reconnect checks.
......
...@@ -788,9 +788,11 @@ enable/disable deriving session DPI automatically from real server ...@@ -788,9 +788,11 @@ enable/disable deriving session DPI automatically from real server
ignored when reconnecting to a suspended session ignored when reconnecting to a suspended session
.TP 8 .TP 8
.B sleep=<int> .B sleep=<int>
delay X server operations when suspended (provided in msec), set to delay X server operations when suspended (provided in milliseconds),
\fI0\fR to keep \fBnxagent\fR session fully functional when suspended set to \fI0\fR to keep \fBnxagent\fR session fully functional when
(e.g. useful when mirroring an \fBnxagent\fR session via VNC) suspended (e.g. useful when mirroring an \fBnxagent\fR session via
VNC). Graphic intensive applications will be affected by this more
than others. The default is 50ms.
.TP 8 .TP 8
.B tolerancechecks=<string> .B tolerancechecks=<string>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment