os: Reduce smart scheduler setup calls

We can return from WaitForSomething with no clients ready for any number
of reasons.  There's no reason to set up the scheduler timer when this
happens.

Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
This commit is contained in:
Adam Jackson 2009-12-14 14:38:10 -05:00
parent d127075da0
commit f953ae7d8a

View File

@ -153,13 +153,17 @@ WaitForSomething(int *pClientsReady)
fd_set clientsWritable; fd_set clientsWritable;
int curclient; int curclient;
int selecterr; int selecterr;
int nready; static int nready;
fd_set devicesReadable; fd_set devicesReadable;
CARD32 now = 0; CARD32 now = 0;
Bool someReady = FALSE; Bool someReady = FALSE;
FD_ZERO(&clientsReadable); FD_ZERO(&clientsReadable);
if (nready)
SmartScheduleStopTimer();
nready = 0;
/* We need a while loop here to handle /* We need a while loop here to handle
crashed connections and the screen saver timeout */ crashed connections and the screen saver timeout */
while (1) while (1)
@ -211,7 +215,6 @@ WaitForSomething(int *pClientsReady)
} }
XFD_COPYSET(&AllSockets, &LastSelectMask); XFD_COPYSET(&AllSockets, &LastSelectMask);
} }
SmartScheduleStopTimer ();
BlockHandler((pointer)&wt, (pointer)&LastSelectMask); BlockHandler((pointer)&wt, (pointer)&LastSelectMask);
if (NewOutputPending) if (NewOutputPending)
@ -230,7 +233,6 @@ WaitForSomething(int *pClientsReady)
} }
selecterr = GetErrno(); selecterr = GetErrno();
WakeupHandler(i, (pointer)&LastSelectMask); WakeupHandler(i, (pointer)&LastSelectMask);
SmartScheduleStartTimer ();
if (i <= 0) /* An error or timeout occurred */ if (i <= 0) /* An error or timeout occurred */
{ {
if (dispatchException) if (dispatchException)
@ -388,6 +390,10 @@ WaitForSomething(int *pClientsReady)
#endif #endif
} }
} }
if (nready)
SmartScheduleStartTimer();
return nready; return nready;
} }