- client: fixed bug that broke idle detection on Unix.

The problem: the various checks were surrounded by things like
    #ifdef HAVE__DEV_MOUSE
    If the host on which the client is built doesn't have a mouse
    (as is the case with our build machine)
    then the resulting executable doesn't check /dev/mouse,
    even if it exists on the target host.
- removed configure checks for /dev/mouse, /dev/kbd, and /dev/tty1

svn path=/trunk/boinc/; revision=13947
This commit is contained in:
David Anderson 2007-10-24 18:58:23 +00:00
parent d4cd3ac853
commit 625b129abc
4 changed files with 52 additions and 44 deletions

View File

@ -9847,3 +9847,19 @@ David 24 Oct 2007
host.inc
user/
hosts_user.php
David 24 Oct 2007
- client: fixed bug that broke idle detection on Unix.
The problem: the various checks were surrounded by things like
#ifdef HAVE__DEV_MOUSE
If the host on which the client is built doesn't have a mouse
(as is the case with our build machine)
then the resulting executable doesn't check /dev/mouse,
even if it exists on the target host.
- removed configure checks for /dev/mouse, /dev/kbd, and /dev/tty1
configure.ac
client/
hostinfo_unix.C
html/user/
create_profile.php

View File

@ -895,8 +895,11 @@ static double GetOSXIdleTime(void) {
if (tryNewAPI) {
if (bundleRef == NULL) {
frameworkURL = CFURLCreateWithFileSystemPath (kCFAllocatorSystemDefault,
CFSTR("/System/Library/Frameworks/ApplicationServices.framework"), kCFURLPOSIXPathStyle, true);
frameworkURL = CFURLCreateWithFileSystemPath(
kCFAllocatorSystemDefault,
CFSTR("/System/Library/Frameworks/ApplicationServices.framework"),
kCFURLPOSIXPathStyle, true
);
if (frameworkURL) {
bundleRef = CFBundleCreate(kCFAllocatorSystemDefault, frameworkURL);
CFRelease( frameworkURL );
@ -904,22 +907,27 @@ static double GetOSXIdleTime(void) {
}
if (bundleRef) {
if ( (GetSysIdleTime == NULL) ||
( ! CFBundleIsExecutableLoaded( bundleRef ) ) ) // Is this test necessary ?
GetSysIdleTime = (GetIdleTimeProc)
CFBundleGetFunctionPointerForName( bundleRef, CFSTR("CGEventSourceSecondsSinceLastEventType") );
if ((GetSysIdleTime == NULL) || !CFBundleIsExecutableLoaded(bundleRef)
) {
// Is this test necessary ?
GetSysIdleTime = (GetIdleTimeProc) CFBundleGetFunctionPointerForName(
bundleRef, CFSTR("CGEventSourceSecondsSinceLastEventType")
);
}
}
if (GetSysIdleTime)
if (GetSysIdleTime) {
idleTime = (double)GetSysIdleTime (kCGEventSourceStateCombinedSessionState, kCGAnyInputEventType);
else {
} else {
CFRelease( bundleRef );
bundleRef = NULL;
tryNewAPI = false; // CGEventSourceSecondsSinceLastEventType() API is not available on this system
tryNewAPI = false;
// CGEventSourceSecondsSinceLastEventType() API is not available on this system
}
if (GetSysIdleTime)
if (GetSysIdleTime) {
return idleTime;
}
} // if (tryNewAPI)
// On 10.3 use this SPI
@ -927,6 +935,7 @@ static double GetOSXIdleTime(void) {
// On MDD Powermacs, the above function will return a large value when the machine
// is active (-1?). 18446744073.0 is the lowest I've seen on my MDD -ai
// Here we check for that value and correctly return a 0 idle time.
//
idleTime = CGSSecondsSinceLastInputEvent (-1);
if (idleTime >= 18446744000.0) idleTime = 0.0;
return idleTime;
@ -948,25 +957,19 @@ bool HOST_INFO::users_idle(
#else // ! __APPLE__
bool HOST_INFO::users_idle(bool check_all_logins, double idle_time_to_run) {
#ifdef HAVE__DEV_TTY1
char device_tty[] = "/dev/tty1";
#endif
time_t idle_time = time(NULL) - (long) (60 * idle_time_to_run);
return true
#ifdef HAVE_UTMP_H
&& (!check_all_logins || all_logins_idle(idle_time))
#endif
#ifdef HAVE__DEV_MOUSE
&& device_idle(idle_time, "/dev/mouse") // solaris, linux
#endif
#ifdef HAVE__DEV_KBD
&& device_idle(idle_time, "/dev/kbd") // solaris
#endif
#ifdef HAVE__DEV_TTY1
&& (check_all_logins || all_tty_idle(idle_time, device_tty, '1', 7))
#endif
time_t idle_time = time(0) - (long) (60 * idle_time_to_run);
;
if (check_all_logins) {
#ifdef HAVE_UTMP_H
if (!all_logins_idle(idle_time)) return false;
#endif
if (!all_tty_idle(idle_time, "/dev/tty1", '1', 7)) return false;
}
if (!device_idle(idle_time, "/dev/mouse")) return false;
// solaris, linux
if (!device_idle(idle_time, "/dev/kbd")) return false;
// solaris
return true;
}
#endif // ! __APPLE__

View File

@ -461,17 +461,6 @@ if test -n "$utmp_file"; then
AC_DEFINE_UNQUOTED(UTMP_LOCATION, "$utmp_file", utmp file location)
fi
dnl Checks for device files
if test -e "/dev/mouse"; then
AC_DEFINE(HAVE__DEV_MOUSE, 1, [Define to 1 if /dev/mouse exists])
fi
if test -e "/dev/kbd"; then
AC_DEFINE(HAVE__DEV_KBD, 1, [Define to 1 if /dev/kbd exists])
fi
if test -e "/dev/tty1"; then
AC_DEFINE(HAVE__DEV_TTY1, 1, [Define to 1 if /dev/tty1 exists])
fi
dnl Check for /proc/self/psinfo (Solaris)
if test -e "/proc/self/psinfo"; then
AC_DEFINE(HAVE__PROC_SELF_PSINFO, 1, [Define to 1 if /proc/self/psinfo exists])

View File

@ -6,13 +6,13 @@ db_init();
$user = get_logged_in_user(true);
if ($user->total_credit > 0) {
show_profile_creation_page($user);
show_profile_creation_page($user);
} else {
page_head("Not available");
echo "You must have returned results and received credit
page_head("Not available");
echo "You must have returned results and received credit
before you can create a profile.
";
page_tail();
";
page_tail();
}
?>