-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 Howdy howdy,
I have a pull request with upstream now: https://github.com/BOINC/boinc/pull/1453 And I've attached a patch against upstream's master as of this morning (HEAD 1ca5f51cc7c993799f27d99bfa871d57567a30e5). I'm not an autotools whiz, so I don't know if the changes I made to configure.ac --mostly pulled from the commit that originally deleted them, but I added a small flag when building the client so that the original commit's checks are actually run-- are ideal, or if the changes made are suitable for an automatic detection of new dependencies. I'm starting to learn about package management a la git-buildpackage, but I've got a ways to go. Cheers, Preston P.S. - It looks like there's another bug from January 2015 that's essentially a dupe of this one. Hopefully both can be closed soon :D On 12/16/2015 01:16 AM, Gianfranco Costamagna wrote: > Hi if you can give me a patch for the source code and submit a pull > request upstream (github), I can find with git log the configure.ac > patches, add the Debian dependencies again and reupload on > unstable. Thanks G. > > Sent from Yahoo Mail on Android > > On Wed, 16 Dec, 2015 at 0:34, Preston > Maness<[email protected]> wrote: -----BEGIN PGP SIGNED > MESSAGE----- Hash: SHA512 > > An update: > > Re-incorporating the XSS idle-detection code works as expected. I > scrapped the DPMS code and only kept the XSS code. Inclusion of > > #include <X11/extensions/scrnsaver.h> > > in "client/hostinfo_unix.cpp" ultimately pulls in a conflicting > definition of "Always" between X-related code and boinc's > "lib/prefs.h", fixed by renaming boinc's declaration. After this, > the boinc-client and boincmgr compile and idle detection works as > expected (keyboard and mouse inputs are appropriately detected, and > computation is suspended). > > Working on cleaning up the changes, hopefully getting upstream to > reinstate the XSS code, and determining how best to get the fix > into the Debian packages. From what I can tell, an additional > dependency on "libxss1" would be necessary. > > Cheers, Preston > > On 12/14/2015 07:28 AM, Preston Maness wrote: >> Whelp, it looks like the X-based idle detection --with the >> XScreenSaver API?-- was removed in this commit: >> >> ================== >> >> bfae1032e5c1ac73f2d8d92f222293d8383a6cee >> >> https://github.com/BOINC/boinc/commit/bfae1032e5c1ac73f2d8d92f222293d 8 > >> 38 >> >> > 3a6cee >> >> ================== >> >> The commit message indicates that /dev/input/* devices are the >> intended way to determine idle time on Linux now. However, it >> seems that X-based inputs don't update the /dev/input/* devices. >> Or at least, anything the X server is doing isn't updating the >> atime on those files, which is what is being utilized to >> determine if the system is idle or not. Working in a terminal >> updates the atime on the relevant files --correctly triggering >> BOINC to suspend computation-- but just typing this email, or >> wiggling the mouse around the desktop area, doesn't. >> >> Granted, this code was present earlier, so I don't know if simply >> re-introducing it will solve anything. But that's my first plan >> of attack. I've also looked into other varying methods of idle >> detection. The XSS API is the most common, but there is a more >> convoluted (asynchronous?) Xsync option that might also be >> possible too. I don't know too much about X, but I'll be giving a >> few different possibilities a go in the coming days. >> >> Cheers, Preston >> >> On 12/11/2015 09:44 AM, Preston Maness wrote: >>> Howdy howdy, >> >>> I think I deserve a slow clap for such a slow >>> response/addresssing of a bug. Indeed my response is so slow >>> that I've since changed email address and GPG keys. >> >>> Needless to say, when running BOINC 7.6.12 from testing, some >>> progress seems to have been made on idle detection. If I open a >>> terminal and begin working in it, *sometimes*, the idle >>> detection kicks in. I can't tell whether it's working as >>> intended or not. Regardless, keeping boinc running non-stop >>> doesn't pose any issues thanks to the scheduling. I can happily >>> use my machine for just about anything and not even notice that >>> BOINC is running. >> >>> I'm presently unemployed, so really, I have nothing but time >>> and no real excuses not to give this bug another go and see if >>> I can just determine once and for all if things are fixed/how >>> to fix them :P >> >>> It looks like the BOINC project has moved from their own git >>> infrastructure onto github: >> >>> https://boinc.berkeley.edu/trac/wiki/SourceCodeGit >> >>> https://github.com/BOINC/boinc >> >>> Looking at the git log for hostinfo_unix.cpp (a la "git log >>> client/hostinfo_unix.cpp" from the project root), it looks like >>> there was a commit that included changes from Gianfranco: >> >>> ================== >> >>> commit 0811886cbb1d282376e2dfd017ab39e34cd7d8ea Author: David >>> Anderson <[email protected]> Date: Mon Feb 3 12:46:43 >>> 2014 -0800 >> >>> client: fix for idle detection on Linux (from Gianfranco) >> >> >>> ================== >> >>> and some later refactoring of the unix HOSTINFO code: >> >>> ================== >> >>> commit cda6bd334bf036349f471a0c4eb7c25de8098262 Author: David >>> Anderson <[email protected]> Date: Tue Nov 25 14:46:58 >>> 2014 -0800 >> >>> client: get static host info items only on startup >> >>> On Android, the way we were getting os_version (Linux version + >>> Android version) didn't work because get_host_info() was >>> getting called before every scheduler RPC, and it overwrote the >>> Android version part. >> >>> Solution: divide host info into dynamic (disk usage, network >>> info) and static (everything else). Computer the static part >>> only at startup. >> >>> Also factor the Unix HOST_INFO code into multiple functions. >> >>> ================== >> >>> As it stands, BOINC's Event Log does show periodic "Suspending >>> computation - computer is in use" messages. Show I'm operating >>> on the assumption that something is working. >> >>> Cheers, Preston Maness >> >> >> > > -----BEGIN PGP SIGNATURE----- > > iQIcBAEBCgAGBQJWcKN0AAoJEFpzcfOOuHp0vY8QAM21NXoSO0S73rsL5Ci5WEZL > D2RbjefCRb+ojSGCFRtRG8fnLVS88P9Kyj5EfwvQPzQhHIsv2aZCfvl3JkPz49A0 > khjaKr7DxgM2DtCxkTbq6HNeYtyr2YQounyZdhEOn/vYp4SmeOVxgC/2j31WYY95 > 3XsMZ6Pe1SpCmhab5jyRBlVUKVTUT2Ekbq7buvMHkEvLSryM3ax32K3PXC8gNbFL > YuVvPYkiQZUlpFrPRqjjoJTBO/MziTYSWw1U9dIXurD0jB8sBitWH7JLkSAmyAjh > dusx6rKFSR1XmPv0P+4D9qaKsy4lES4erxp2FUcPaX5L+D5fw7qAkTrgH+Vmbz+E > fCtgTiZz91KqpImlYyMjuzKPqpfMl2+O4qBoHTrXoasvFR0z8toP/gLIMibEb+OA > aD4MZO5IOQ+Orc1qPO+G9p6agDVmQePGk6S7jED3u/iklUI+865xYjbkAyiq4iwp > xVplNgaufJHD0dzRghB3IqSGI1EqEBXKQsBuJeShf2b8FdreVBwmgEWhL2uekhMv > 187UBr6j9ERgjWSbY6QLbXb6y4+qjpINmMfAMkMjplDyB8ozUiYf6QvRjMZdBqUG > dYDq8Bt26M4u1MlMUbYQbZB1A9jn1pHC0CF13l2up8GmeRQzj+1emPKpK18H/5bl > BfkujLktRP+FinR3iDV8 =AW/A -----END PGP SIGNATURE----- > -----BEGIN PGP SIGNATURE----- iQIcBAEBCgAGBQJWcaHhAAoJEFpzcfOOuHp0oa0P/jRjDvtMDXgugKRv6MQobhGh WgYERXamT/wW+mfFQeAIkvVHccEA/9Uy/YvspbhV/lIMDZ5i80CqzpfP8tchA6Lu LwcuL59FWmotKP5AwyCW0nfH6zQnP11LrNZBmaRnghfLIcG2/Wh8i6PzKgf06K5K GlsRcTVCKpeZHWqoiKVKdS3g0sUn3J3y7wQ0u+KHIBauTk+mO3/NHElONMb6G7WV R9VNvS8I+ggKuXBILucWHyKHJ4n3bybG0JtvZiSilHZuV6rw3RQ5CyDE/AsxQWum WhYsxAY0xMF5DR2oHLhc7Vr+qU78sLMlWk4zL0IW6LAjEh9u9hsl6YIvLjU/tw0b quUiDjdH41NwUdrV41qwFJPE7R775NMlvy5XalcJV30Ha6dllK0xJs0cMArmjFE2 gmSCNd+zjOZhaiHOcW1c0mYap1wvQWotBX/5qUfHMYnNMOPdtQwyoruQx65R03sb WHRQmzR843Lw01A/agwTmuNT3+ydlYr83XR5LcUz+qhvu61GhTV47XykRyQ03VxF zaf0ODMdqTrj2uhQZQSKLNjpDgy7IRaXdRhZCTuET5jQjkfMcaNaK2rzv75uUeeG JWieNa11TIYJEVWG4zCRUKclPivTSUK+6CNY0fPaE0qxH9+gyaCG+2A2lTEzrpOj LH3yZUaNsC7LY4WZX3eV =57gn -----END PGP SIGNATURE-----
>From 156b0be9f13b3427973f1d83a004947225b2d8b6 Mon Sep 17 00:00:00 2001 From: Preston Maness <[email protected]> Date: Wed, 16 Dec 2015 10:45:57 -0600 Subject: [PATCH] client (Linux): Reinstate XScreenSaver API-based idle detection on GNU/Linux. --- client/hostinfo_unix.cpp | 68 +++++++++++++++++++++++++++++++++++++++++++++++- configure.ac | 20 ++++++++++++++ lib/prefs.cpp | 2 +- lib/prefs.h | 6 ++++- 4 files changed, 93 insertions(+), 3 deletions(-) diff --git a/client/hostinfo_unix.cpp b/client/hostinfo_unix.cpp index 617f824..c059895 100644 --- a/client/hostinfo_unix.cpp +++ b/client/hostinfo_unix.cpp @@ -41,6 +41,10 @@ #include <cstring> #endif +#if HAVE_XSS +#include <X11/extensions/scrnsaver.h> //X-based idle detection +#endif + #include <cstdio> #include <cstdlib> #include <cstring> @@ -1947,6 +1951,62 @@ bool interrupts_idle(time_t t) { } return last_irq < t; } + +#if HAVE_XSS +// Ask the X server for user idle time (using XScreenSaver API) +// Return true if the idle time exceeds idle_threshold. +// +bool xss_idle(long idle_threshold) { + static XScreenSaverInfo* xssInfo = NULL; + static Display* disp = NULL; + static bool error = false; + // some X call failed - always return not idle + + if (error) return false; + + long idle_time = 0; + + if (disp == NULL) { + disp = XOpenDisplay(NULL); + // XOpenDisplay may return NULL if there is no running X + // or DISPLAY points to wrong/invalid display + // + if (disp == NULL) { + error = true; + //msg_printf(NULL, MSG_INFO, "XDisplay not found."); + return false; + } + int event_base_return, error_base_return; + xssInfo = XScreenSaverAllocInfo(); + if (!XScreenSaverQueryExtension( + disp, &event_base_return, &error_base_return + )){ + error = true; + //msg_printf(NULL, MSG_INFO, "XScreenSaverQueryExtension() failed."); + return false; + } + } + + XScreenSaverQueryInfo(disp, DefaultRootWindow(disp), xssInfo); + idle_time = xssInfo->idle; + + // convert from milliseconds to seconds + // + idle_time = idle_time / 1000; + + //msg_printf(NULL, MSG_INFO, "XSS idle detection succeeded."); + //msg_printf(NULL, MSG_INFO, "idle threshold: %ld", idle_threshold); + //msg_printf(NULL, MSG_INFO, "idle_time: %ld", idle_time); + + if ( idle_threshold < idle_time ) { + //msg_printf(NULL, MSG_INFO, "System is idle according to X."); + } else { + //msg_printf(NULL, MSG_INFO, "System is active according to X."); + } + return idle_threshold < idle_time; +} +#endif // HAVE_XSS + #endif // LINUX_LIKE_SYSTEM bool HOST_INFO::users_idle(bool check_all_logins, double idle_time_to_run) { @@ -1972,6 +2032,12 @@ bool HOST_INFO::users_idle(bool check_all_logins, double idle_time_to_run) { return false; } +#if HAVE_XSS + if (!xss_idle((long)(idle_time_to_run * 60))) { + return false; + } +#endif // HAVE_XSS + // Lets at least check the dev entries which should be correct for // USB keyboards and mice. If the linux kernel doc is correct it should // also work for bluetooth input devices as well. @@ -1990,7 +2056,7 @@ bool HOST_INFO::users_idle(bool check_all_logins, double idle_time_to_run) { if (!device_idle(idle_time, "/dev/input/mice")) return false; if (!device_idle(idle_time, "/dev/kbd")) return false; // solaris -#endif +#endif // LINUX_LIKE_SYSTEM return true; } diff --git a/configure.ac b/configure.ac index 792c6fb..919fd46 100644 --- a/configure.ac +++ b/configure.ac @@ -200,6 +200,7 @@ configured_to_build= if test x$enable_client = xyes ; then configured_to_build="client" + enable_xss="yes" fi if test x$enable_manager = xyes ; then configured_to_build="${configured_to_build} manager" @@ -628,6 +629,15 @@ fi AM_CONDITIONAL(BUILD_GRAPHICS_API, [ test "$have_glut" = yes -a "$have_jpeg" = 1]) +dnl check for X screen saver lib (X-based idle detection on Linux) +if test "$enable_xss" == yes; then + AC_CHECK_LIB([Xss], [XScreenSaverAllocInfo], [have_Xss="yes"], [have_Xss="no"]) + AC_CHECK_HEADER([X11/extensions/scrnsaver.h], [have_Xss="yes"], [have_Xss="no"]) + if test "$have_Xss" == no; then + AC_MSG_WARN([libxss missing, disabling X ScreenSaver user idle detection]) + fi +fi + dnl -------------------------------------------------------------------------------- dnl put double-inclusion protection into config.h AH_TOP([ @@ -1194,6 +1204,16 @@ if test "${ac_cv_func_res_init}" != "yes" ; then fi LIBS=$svlibs +if (test "$enable_xss" == yes) && (test "$have_Xss" == yes); then + SAH_CHECK_LIB([Xss],[XScreenSaverAllocInfo],[ + AC_DEFINE([HAVE_XSS],[1],[Define to 1 if you have xss library]) + CLIENTLIBS="${sah_lib_last} ${CLIENTLIBS}"]) + SAH_CHECK_LIB([X11],[XOpenDisplay],[ + AC_DEFINE([HAVE_X11],[1],[Define to 1 if you have X11 library]) + CLIENTLIBS="${sah_lib_last} ${CLIENTLIBS}"]) + echo DEBUG: CLIENTLIBS=${CLIENTLIBS} >&5 +fi + SAH_CHECK_LIB([resolv],[res_query],[ AC_DEFINE([HAVE_RESOLV],[1],[Define to 1 if you have the resolv library]) CLIENTLIBS="${sah_lib_last} ${CLIENTLIBS}"]) diff --git a/lib/prefs.cpp b/lib/prefs.cpp index 3a8267e..9bd4160 100644 --- a/lib/prefs.cpp +++ b/lib/prefs.cpp @@ -149,7 +149,7 @@ bool TIME_SPAN::suspended(double hour) const { TIME_SPAN::TimeMode TIME_SPAN::mode() const { if (end_hour == start_hour || (start_hour == 0 && end_hour == 24)) { - return Always; + return Always2; } else if (start_hour == 24 && end_hour == 0) { return Never; } diff --git a/lib/prefs.h b/lib/prefs.h index ebbe3cc..da81ea7 100644 --- a/lib/prefs.h +++ b/lib/prefs.h @@ -89,7 +89,11 @@ struct TIME_SPAN { double end_hour; enum TimeMode { - Always = 7000, + // "Always" is defined by X.h, which itself is (indirectly) included + // from client/hostinfo_unix.cpp when including the XSS API + // (<X11/extensions/scrnsaver.h>). Hence, renaming here (and in + // prefs.cpp). + Always2 = 7000, Never, Between }; -- 2.6.2
reinstate_xss_idle_detection_linux.patch.sig
Description: PGP signature

