Commit 19ba0747 authored by Ulrich Sibiller's avatar Ulrich Sibiller

Handlers.c: reformat comments

parent 9b1e2993
...@@ -57,47 +57,42 @@ ...@@ -57,47 +57,42 @@
#undef DUMP #undef DUMP
/* /*
* Log begin and end of the important * Log begin and end of the important handlers.
* handlers.
*/ */
#undef BLOCKS #undef BLOCKS
/* /*
* If not defined, flush immediately * If not defined, flush immediately upon entering the block handler.
* upon entering the block handler.
*/ */
#define FLUSH_AFTER_MULTIPLE_READS #define FLUSH_AFTER_MULTIPLE_READS
/* /*
* The soft limit should roughly match * The soft limit should roughly match the size of the Xlib I/O
* the size of the Xlib I/O buffer. * buffer.
*/ */
#define BYTES_BEFORE_SOFT_TOKEN 2048 #define BYTES_BEFORE_SOFT_TOKEN 2048
#define BYTES_BEFORE_HARD_TOKEN 65536 #define BYTES_BEFORE_HARD_TOKEN 65536
/* /*
* Maximum number of synchronization * Maximum number of synchronization requests before waiting for the
* requests before waiting for the
* remote. * remote.
*/ */
#define TOKENS_PENDING_LIMIT 8 #define TOKENS_PENDING_LIMIT 8
/* /*
* Limits are very unobtrusive. We don't * Limits are very unobtrusive. We don't want to interfere with the
* want to interfere with the normal * normal dispatching.
* dispatching.
*/ */
#define BYTES_BEFORE_YIELD 1048576 #define BYTES_BEFORE_YIELD 1048576
#define TIME_BEFORE_YIELD 500 #define TIME_BEFORE_YIELD 500
/* /*
* Dynamically reduce the display buffer * Dynamically reduce the display buffer size after a congestion.
* size after a congestion.
*/ */
#undef DYNAMIC_DISPLAY_BUFFER #undef DYNAMIC_DISPLAY_BUFFER
...@@ -116,16 +111,14 @@ extern void nxagentDumpInputDevicesState(void); ...@@ -116,16 +111,14 @@ extern void nxagentDumpInputDevicesState(void);
#endif #endif
/* /*
* Used in the handling of the X desktop * Used in the handling of the X desktop manager protocol.
* manager protocol.
*/ */
int nxagentXdmcpUp = 0; int nxagentXdmcpUp = 0;
int nxagentXdmcpAlertUp = 0; int nxagentXdmcpAlertUp = 0;
/* /*
* Also used in the block, wakeup and * Also used in the block, wakeup and sync handlers.
* sync handlers.
*/ */
int nxagentBuffer; int nxagentBuffer;
...@@ -136,30 +129,28 @@ double nxagentBytesIn; ...@@ -136,30 +129,28 @@ double nxagentBytesIn;
double nxagentBytesOut; double nxagentBytesOut;
/* /*
* Total number of descriptors ready * Total number of descriptors ready as reported by the wakeup
* as reported by the wakeup handler. * handler.
*/ */
int nxagentReady; int nxagentReady;
/* /*
* Timestamp of the last write to the * Timestamp of the last write to the remote display.
* remote display.
*/ */
int nxagentFlush; int nxagentFlush;
/* /*
* Arbitrate the bandwidth among our * Arbitrate the bandwidth among our clients.
* clients.
*/ */
struct _TokensRec nxagentTokens = { 0, 0, 0 }; struct _TokensRec nxagentTokens = { 0, 0, 0 };
struct _DispatchRec nxagentDispatch = { UNDEFINED, 0, 0, 0 }; struct _DispatchRec nxagentDispatch = { UNDEFINED, 0, 0, 0 };
/* /*
* Called just before blocking, waiting * Called just before blocking, waiting for our clients or the X
* for our clients or the X server. * server.
*/ */
extern int nxagentSkipImage; extern int nxagentSkipImage;
...@@ -179,15 +170,13 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask) ...@@ -179,15 +170,13 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask)
static int now; static int now;
/* /*
* Pending bytes to write to the * Pending bytes to write to the network.
* network.
*/ */
static int flushable; static int flushable;
/* /*
* Set if we need to synchronize * Set if we need to synchronize any drawable.
* any drawable.
*/ */
static int synchronize; static int synchronize;
...@@ -242,8 +231,8 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask) ...@@ -242,8 +231,8 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask)
#endif #endif
/* /*
* Slow down the agent if the session is * Slow down the agent if the session is not connected to a valid
* not connected to a valid display. * display.
*/ */
if (NXDisplayError(nxagentDisplay) == 1 && nxagentShadowCounter == 0 && nxagentOption(SleepTime) > 0) if (NXDisplayError(nxagentDisplay) == 1 && nxagentShadowCounter == 0 && nxagentOption(SleepTime) > 0)
...@@ -263,8 +252,7 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask) ...@@ -263,8 +252,7 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask)
#endif #endif
/* /*
* Update the shadow display. This is * Update the shadow display. This is only for test purposes.
* only for test purposes.
*/ */
#ifdef DUMP #ifdef DUMP
...@@ -276,17 +264,14 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask) ...@@ -276,17 +264,14 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask)
#endif #endif
/* /*
* We need this here because some window * We need this here because some window configuration changes can
* configuration changes can be generated * be generated by the X server outside the control of the DIX.
* by the X server outside the control of
* the DIX.
*/ */
nxagentFlushConfigureWindow(); nxagentFlushConfigureWindow();
/* /*
* Check whether there is any drawable to * Check whether there is any drawable to synchronize.
* synchronize.
*/ */
#ifdef TEST #ifdef TEST
...@@ -300,8 +285,7 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask) ...@@ -300,8 +285,7 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask)
nxagentCorruptedPixmaps > 0); nxagentCorruptedPixmaps > 0);
/* /*
* The synchronization function requires a mask as * The synchronization function requires a mask as parameter:
* parameter:
* *
* EVENT_BREAK Breaks if an user input, like * EVENT_BREAK Breaks if an user input, like
* a key press or a mouse move, * a key press or a mouse move,
...@@ -324,9 +308,8 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask) ...@@ -324,9 +308,8 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask)
if (synchronize == 1) if (synchronize == 1)
{ {
/* /*
* We should not enter the synchronization * We should not enter the synchronization loop if there is any
* loop if there is any user input pending, * user input pending, i.e. if we are in the middle of a scroll
* i.e. if we are in the middle of a scroll
* operation. * operation.
*/ */
...@@ -361,9 +344,8 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask) ...@@ -361,9 +344,8 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask)
#endif #endif
/* /*
* Check if we have more corrupted resources * Check if we have more corrupted resources and whether the
* and whether the conditions are satisfied * conditions are satisfied to continue with the synchronization.
* to continue with the synchronization.
*/ */
synchronize = (nxagentCongestion <= 4 && synchronize = (nxagentCongestion <= 4 &&
...@@ -405,9 +387,9 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask) ...@@ -405,9 +387,9 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask)
} }
/* /*
* If the remote X server is blocking, reduce the * If the remote X server is blocking, reduce the amount of data
* amount of data sent in a single display update * sent in a single display update by reducing the size of the
* by reducing the size of the display buffer. * display buffer.
*/ */
#ifdef DYNAMIC_DISPLAY_BUFFER #ifdef DYNAMIC_DISPLAY_BUFFER
...@@ -445,8 +427,8 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask) ...@@ -445,8 +427,8 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask)
#endif /* #ifdef DYNAMIC_DISPLAY_BUFFER */ #endif /* #ifdef DYNAMIC_DISPLAY_BUFFER */
/* /*
* Dispatch to the clients the events that * Dispatch to the clients the events that may have become
* may have become available. * available.
*/ */
if (nxagentPendingEvents(nxagentDisplay) > 0) if (nxagentPendingEvents(nxagentDisplay) > 0)
...@@ -459,9 +441,8 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask) ...@@ -459,9 +441,8 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask)
} }
/* /*
* Check if there is any data remaining, * Check if there is any data remaining, either in the display
* either in the display buffer or in * buffer or in the NX transport.
* the NX transport.
*/ */
flushable = NXDisplayFlushable(nxagentDisplay); flushable = NXDisplayFlushable(nxagentDisplay);
...@@ -471,9 +452,8 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask) ...@@ -471,9 +452,8 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask)
#ifdef FLUSH_AFTER_MULTIPLE_READS #ifdef FLUSH_AFTER_MULTIPLE_READS
/* /*
* Flush all the outstanding data if * Flush all the outstanding data if the wakeup handler didn't
* the wakeup handler didn't detect * detect any activity.
* any activity.
*/ */
if (nxagentReady == 0 || now - nxagentFlush >= if (nxagentReady == 0 || now - nxagentFlush >=
...@@ -487,8 +467,7 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask) ...@@ -487,8 +467,7 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask)
NXFlushDisplay(nxagentDisplay, NXFlushLink); NXFlushDisplay(nxagentDisplay, NXFlushLink);
/* /*
* New events may have become available * New events may have become available after the flush.
* after the flush.
*/ */
if (nxagentPendingEvents(nxagentDisplay) > 0) if (nxagentPendingEvents(nxagentDisplay) > 0)
...@@ -516,9 +495,8 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask) ...@@ -516,9 +495,8 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask)
#else /* #ifdef FLUSH_AFTER_MULTIPLE_READS */ #else /* #ifdef FLUSH_AFTER_MULTIPLE_READS */
/* /*
* We are entering the select. Tell the NX * We are entering the select. Tell the NX transport to write any
* transport to write any produced data to * produced data to the remote end.
* the remote end.
*/ */
NXFlushDisplay(nxagentDisplay, NXFlushLink); NXFlushDisplay(nxagentDisplay, NXFlushLink);
...@@ -556,12 +534,11 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask) ...@@ -556,12 +534,11 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask)
} }
/* /*
* WaitForSomething() sets a zero timeout if there * WaitForSomething() sets a zero timeout if there are clients with
* are clients with input, but doesn't stop the * input, but doesn't stop the timer. The select is then interrupted
* timer. The select is then interrupted to update * to update the schedule time even if, what the dispatcher cares,
* the schedule time even if, what the dispatcher * is only the number of ticks at the time the client is scheduled
* cares, is only the number of ticks at the time * in.
* the client is scheduled in.
*/ */
#ifdef DEBUG #ifdef DEBUG
...@@ -641,8 +618,7 @@ void nxagentWakeupHandler(void * data, int count, void * mask) ...@@ -641,8 +618,7 @@ void nxagentWakeupHandler(void * data, int count, void * mask)
else if (nxagentQueuedEvents(nxagentDisplay) == 1) else if (nxagentQueuedEvents(nxagentDisplay) == 1)
{ {
/* /*
* We may have left some events in * We may have left some events in the queue.
* the queue.
*/ */
#ifdef TEST #ifdef TEST
...@@ -674,9 +650,8 @@ void nxagentWakeupHandler(void * data, int count, void * mask) ...@@ -674,9 +650,8 @@ void nxagentWakeupHandler(void * data, int count, void * mask)
#endif #endif
/* /*
* If the XDM connection can't be established * If the XDM connection can't be established we'll need to create a
* we'll need to create a dialog to notify the * dialog to notify the user and give him/her a chance to terminate
* user and give him/her a chance to terminate
* the session. * the session.
*/ */
...@@ -813,14 +788,12 @@ void nxagentShadowBlockHandler(void * data, struct timeval **timeout, void * mas ...@@ -813,14 +788,12 @@ void nxagentShadowBlockHandler(void * data, struct timeval **timeout, void * mas
} }
/* /*
* We are entering the select. Tell the NX * We are entering the select. Tell the NX transport to write any
* transport to write any produced data to * produced data to the remote end.
* the remote end.
*/ */
/* /*
FIXME: Must queue multiple writes and handle FIXME: Must queue multiple writes and handle the events by resembling
the events by resembling the ordinary the ordinary block handler.
block handler.
*/ */
NXFlushDisplay(nxagentDisplay, NXFlushLink); NXFlushDisplay(nxagentDisplay, NXFlushLink);
...@@ -929,8 +902,7 @@ void nxagentShadowWakeupHandler(void * data, int count, void * mask) ...@@ -929,8 +902,7 @@ void nxagentShadowWakeupHandler(void * data, int count, void * mask)
else if (nxagentQueuedEvents(nxagentDisplay) == 1) else if (nxagentQueuedEvents(nxagentDisplay) == 1)
{ {
/* /*
* We may have left some events in * We may have left some events in the queue.
* the queue.
*/ */
#ifdef TEST #ifdef TEST
...@@ -1022,13 +994,11 @@ Bool nxagentCollectInputFocusPredicate(Display *display, XEvent *X, XPointer ptr ...@@ -1022,13 +994,11 @@ Bool nxagentCollectInputFocusPredicate(Display *display, XEvent *X, XPointer ptr
void nxagentDispatchHandler(ClientPtr client, int in, int out) void nxagentDispatchHandler(ClientPtr client, int in, int out)
{ {
/* /*
* This function is called by the dispatcher (with 0 * This function is called by the dispatcher (with 0 bytes out)
* bytes out) after a new request has been processed. * after a new request has been processed. It is also called by the
* It is also called by the write handler (with 0 * write handler (with 0 bytes in) after more data has been written
* bytes in) after more data has been written to the * to the display. It may be optionally called in the block and
* display. It may be optionally called in the block * wakeup handlers. In this case both in and out must be 0.
* and wakeup handlers. In this case both in and out
* must be 0.
*/ */
if (out > 0) if (out > 0)
...@@ -1050,14 +1020,12 @@ void nxagentDispatchHandler(ClientPtr client, int in, int out) ...@@ -1050,14 +1020,12 @@ void nxagentDispatchHandler(ClientPtr client, int in, int out)
#endif #endif
/* /*
* Don't take care of the synchronization if * Don't take care of the synchronization if the NX transport is
* the NX transport is running. The NX trans- * running. The NX transport has its own token-based control flow.
* port has its own token-based control flow.
* *
* We can't produce more output here because * We can't produce more output here because we are in the middle
* we are in the middle of the flush. We will * of the flush. We will take care of the sync requests when
* take care of the sync requests when called * called by the dispatcher.
* by the dispatcher.
*/ */
if (nxagentOption(LinkType) == LINK_TYPE_NONE) if (nxagentOption(LinkType) == LINK_TYPE_NONE)
...@@ -1079,8 +1047,8 @@ void nxagentDispatchHandler(ClientPtr client, int in, int out) ...@@ -1079,8 +1047,8 @@ void nxagentDispatchHandler(ClientPtr client, int in, int out)
{ {
/* /*
* Pay attention to the next client if this * Pay attention to the next client if this client produced
* client produced enough output. * enough output.
*/ */
if (nxagentBytesOut - nxagentDispatch.out > BYTES_BEFORE_YIELD) if (nxagentBytesOut - nxagentDispatch.out > BYTES_BEFORE_YIELD)
...@@ -1142,12 +1110,11 @@ void nxagentDispatchHandler(ClientPtr client, int in, int out) ...@@ -1142,12 +1110,11 @@ void nxagentDispatchHandler(ClientPtr client, int in, int out)
#endif #endif
/* /*
* When using the dumb scheduler, before reading from * When using the dumb scheduler, before reading from another
* another client, the dispatcher tries to drain all * client, the dispatcher tries to drain all the input from the
* the input from the client being processed. This * client being processed. This means that, if isItTimeToYield is
* means that, if isItTimeToYield is never set and the * never set and the client never produces any output, we'll stick
* client never produces any output, we'll stick into * into the inner dispatch loop forever.
* the inner dispatch loop forever.
*/ */
if (!SmartScheduleSignalEnable) if (!SmartScheduleSignalEnable)
...@@ -1228,10 +1195,9 @@ void nxagentDispatchHandler(ClientPtr client, int in, int out) ...@@ -1228,10 +1195,9 @@ void nxagentDispatchHandler(ClientPtr client, int in, int out)
else if (nxagentTokens.soft > BYTES_BEFORE_SOFT_TOKEN) else if (nxagentTokens.soft > BYTES_BEFORE_SOFT_TOKEN)
{ {
/* /*
* Alternatively, the amounts of bytes * Alternatively, the amounts of bytes accounted for each sync
* accounted for each sync request may * request may be decreased according to the number of pending
* be decreased according to the number * replies already awaited.
* of pending replies already awaited.
* *
* else if (nxagentTokens.soft > (BYTES_BEFORE_SOFT_TOKEN / (nxagentTokens.pending + 1))) * else if (nxagentTokens.soft > (BYTES_BEFORE_SOFT_TOKEN / (nxagentTokens.pending + 1)))
*/ */
...@@ -1239,9 +1205,8 @@ void nxagentDispatchHandler(ClientPtr client, int in, int out) ...@@ -1239,9 +1205,8 @@ void nxagentDispatchHandler(ClientPtr client, int in, int out)
int resource; int resource;
/* /*
* Wait eventually for the number of * Wait eventually for the number of synchronization requests to
* synchronization requests to return * return below the limit.
* below the limit.
*/ */
#ifdef TEST #ifdef TEST
......
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