aboutsummaryrefslogtreecommitdiff
path: root/xorg-server
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-09-19 16:44:50 +0000
committermarha <marha@users.sourceforge.net>2010-09-19 16:44:50 +0000
commitf234d2f845843ad7b6c02eb69dae22bd257afeb5 (patch)
tree82ea5c8a0ddd468e2967498c0c2d4db841ddc9a6 /xorg-server
parent8a01c2e9a5abceb706690d1014e51ff9f2fbcf2a (diff)
downloadvcxsrv-f234d2f845843ad7b6c02eb69dae22bd257afeb5.tar.gz
vcxsrv-f234d2f845843ad7b6c02eb69dae22bd257afeb5.tar.bz2
vcxsrv-f234d2f845843ad7b6c02eb69dae22bd257afeb5.zip
Implemented smart schedule timer
Diffstat (limited to 'xorg-server')
-rw-r--r--xorg-server/os/utils.c55
1 files changed, 46 insertions, 9 deletions
diff --git a/xorg-server/os/utils.c b/xorg-server/os/utils.c
index 8858c9f33..11d2ac8fa 100644
--- a/xorg-server/os/utils.c
+++ b/xorg-server/os/utils.c
@@ -201,6 +201,11 @@ Bool PanoramiXExtensionDisabledHack = FALSE;
int auditTrailLevel = 1;
+#ifdef _MSC_VER
+static HANDLE s_hSmartScheduleTimer = NULL;
+static HANDLE s_hSmartScheduleTimerQueue = NULL;
+#endif
+
#if defined(SVR4) || defined(__linux__) || defined(CSRG_BASED)
#define HAS_SAVED_IDS_AND_SETEUID
#endif
@@ -1137,7 +1142,12 @@ XNFstrdup(const char *s)
void
SmartScheduleStopTimer (void)
{
-#ifndef _MSC_VER
+#ifdef _MSC_VER
+ if (SmartScheduleDisable)
+ return;
+ DeleteTimerQueueTimer(s_hSmartScheduleTimerQueue, s_hSmartScheduleTimer, NULL);
+ s_hSmartScheduleTimer=NULL;
+#else
struct itimerval timer;
if (SmartScheduleDisable)
@@ -1150,10 +1160,33 @@ SmartScheduleStopTimer (void)
#endif
}
+#ifdef _MSC_VER
+static VOID CALLBACK SmartScheduleTimer( PVOID lpParameter, BOOLEAN TimerOrWaitFired)
+#else
+static void SmartScheduleTimer (int sig)
+#endif
+{
+ SmartScheduleTime += SmartScheduleInterval;
+}
+
+
void
SmartScheduleStartTimer (void)
{
-#ifndef _MSC_VER
+#ifdef _MSC_VER
+ if (SmartScheduleDisable)
+ return;
+
+ if (!CreateTimerQueueTimer( &s_hSmartScheduleTimer, s_hSmartScheduleTimerQueue, SmartScheduleTimer, NULL
+ , SmartScheduleInterval, SmartScheduleInterval, WT_EXECUTEONLYONCE|WT_EXECUTEINPERSISTENTTHREAD))
+ {
+ DWORD Error=GetLastError();
+ ErrorF("Error starting timer, smart scheduling disabled: 0x%x (%d)\n",Error,Error);
+ CloseHandle(s_hSmartScheduleTimer);
+ SmartScheduleDisable = TRUE;
+ return;
+ }
+#else
struct itimerval timer;
if (SmartScheduleDisable)
@@ -1166,16 +1199,20 @@ SmartScheduleStartTimer (void)
#endif
}
-static void
-SmartScheduleTimer (int sig)
-{
- SmartScheduleTime += SmartScheduleInterval;
-}
-
void
SmartScheduleInit (void)
{
-#ifndef _MSC_VER
+#ifdef _MSC_VER
+ if (SmartScheduleDisable)
+ return;
+ s_hSmartScheduleTimerQueue = CreateTimerQueue();
+ if (!s_hSmartScheduleTimerQueue)
+ {
+ DWORD Error=GetLastError();
+ ErrorF("Error creating timer, smart scheduling disabled: 0x%x (%d)\n",Error,Error);
+ SmartScheduleDisable = TRUE;
+ }
+#else
struct sigaction act;
if (SmartScheduleDisable)