[boinc] 02/05: Cherry-pick the last two fixes from the upstream PR
Gianfranco Costamagna
locutusofborg-guest at moszumanska.debian.org
Sun Jan 3 15:37:40 UTC 2016
This is an automated email from the git hooks/post-receive script.
locutusofborg-guest pushed a commit to branch master
in repository boinc.
commit de8ba3b15793f7c23608a2bc324aa6ce57818fe5
Author: Gianfranco Costamagna <costamagnagianfranco at yahoo.it>
Date: Sun Jan 3 16:07:45 2016 +0100
Cherry-pick the last two fixes from the upstream PR
---
debian/changelog | 4 +-
.../69abe830e6069ec2139783392e8d3a73fb7e6baf.patch | 220 ++++++++++++++++++
.../fc4446f6027cc0d0e75e634f572b50b88588b57d.patch | 253 +++++++++++++++++++++
debian/patches/series | 2 +
4 files changed, 478 insertions(+), 1 deletion(-)
diff --git a/debian/changelog b/debian/changelog
index 259eb75..ffa7c9c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,7 +1,9 @@
-boinc (7.6.22+dfsg-1exp2) UNRELEASED; urgency=medium
+boinc (7.6.22+dfsg-1exp2) experimental; urgency=medium
[ Preston Maness ]
* Fix xhost problem in the right way(TM)
+ - d/p/69abe830e6069ec2139783392e8d3a73fb7e6baf.patch
+ - d/p/fc4446f6027cc0d0e75e634f572b50b88588b57d.patch
-- Gianfranco Costamagna <locutusofborg at debian.org> Sun, 03 Jan 2016 16:00:45 +0100
diff --git a/debian/patches/69abe830e6069ec2139783392e8d3a73fb7e6baf.patch b/debian/patches/69abe830e6069ec2139783392e8d3a73fb7e6baf.patch
new file mode 100644
index 0000000..1e854ec
--- /dev/null
+++ b/debian/patches/69abe830e6069ec2139783392e8d3a73fb7e6baf.patch
@@ -0,0 +1,220 @@
+## Description: add some description
+## Origin/Author: add some origin or author
+## Bug: bug URL
+From 69abe830e6069ec2139783392e8d3a73fb7e6baf Mon Sep 17 00:00:00 2001
+From: Preston Maness <aggroskater at gmail.com>
+Date: Tue, 29 Dec 2015 20:59:23 -0600
+Subject: [PATCH] Revamped the idle detection after pouring over documentation.
+ This new code should be able to handle all local Xservers as they come and
+ go. Issue with permitting access to Xservers from boinc user resolved (see
+ comments; package managers may include appropriate file in
+ /etc/X11/Xsession.d/, otherwise boinc ignores inaccessible DISPLAYs). Pushing
+ for CI checks. Not finished though. This commit has generic debug output that
+ would clutter the event log. I want to add a debug flag and only dump this
+ (noisy, once-per-second) output if the user explicitly asks for it via
+ configuration file.
+
+---
+ client/hostinfo_unix.cpp | 164 +++++++++++++++++++++++++++++++++++++----------
+ 1 file changed, 129 insertions(+), 35 deletions(-)
+
+diff --git a/client/hostinfo_unix.cpp b/client/hostinfo_unix.cpp
+index 5adc50e..1e20ad6 100644
+--- a/client/hostinfo_unix.cpp
++++ b/client/hostinfo_unix.cpp
+@@ -46,6 +46,8 @@
+ // prevents naming collision between X.h define of Always and boinc's
+ // lib/prefs.h definition in an enum.
+ #undef Always
++#include <dirent.h> //for opening /tmp/.X11-unix/
++// (There is a DirScanner class in BOINC, but it doesn't do what we want)
+ #endif
+
+ #include <cstdio>
+@@ -1956,59 +1958,151 @@ bool interrupts_idle(time_t t) {
+ }
+
+ #if HAVE_XSS
+-// Ask the X server for user idle time (using XScreenSaver API)
+-// Return true if the idle time exceeds idle_threshold.
++
++// Initializer for const vector<string> in xss_idle
+ //
++const vector<string> X_display_values_initialize() {
++
++ /* According to "man Xserver", each local Xserver will have a socket file
++ * at /tmp/.X11-unix/Xn, where "n" is the display number (0, 1, 2, etc).
++ * We will parse this directory for currently open Xservers and attempt
++ * to ultimately query them for their idle time. If we can't open this
++ * directory, or the display_values vector is otherwise empty, then a
++ * static list of guesses for open display servers is utilized instead
++ * (DISPLAY values ":{0..6}") that will attempt connections to the first
++ * seven open Xservers.
++ *
++ * If we were unable to open _any_ Xserver, then we will log this and
++ * xss_idle returns true, effectively leaving idle detection up to other
++ * methods.
++ */
++ static const string dir = "/tmp/.X11-unix/";
++ vector<string> display_values;
++ vector<string>::iterator it;
++
++ DIR *dp;
++ struct dirent *dirp;
++ if((dp = opendir(dir.c_str())) == NULL) {
++ msg_printf(NULL, MSG_INFO, "Error (%d) opening %s.", errno, dir.c_str());
++ }
++
++ while ((dirp = readdir(dp)) != NULL) {
++ display_values.push_back(string(dirp->d_name));
++ }
++ closedir(dp);
++
++ // Get rid of non-matching elements and format the matching ones.
++ for ( it = display_values.begin() ; it != display_values.end() ; ) {
++ if ( it->c_str()[0] != 'X' ) {
++ it = display_values.erase(it);
++ }
++ else {
++ replace(it->begin(), it->end(), 'X', ':');
++ it++;
++ }
++
++ }
++
++ // if the display_values vector is empty, assume something went wrong
++ // (couldn't open directory, no apparent Xn files). Test a static list of
++ // DISPLAY values instead that is likely to catch most common use cases.
++ // (I don't know of many environments where there will simultaneously be
++ // more than seven active, local Xservers. I'm sure they exist... somewhere.
++ // But seven was the magic number for me).
++ if ( display_values.size() == 0 ) {
++ display_values.push_back(":0");
++ display_values.push_back(":1");
++ display_values.push_back(":2");
++ display_values.push_back(":3");
++ display_values.push_back(":4");
++ display_values.push_back(":5");
++ display_values.push_back(":6");
++ return display_values;
++ }
++ else {
++ return display_values;
++ }
++}
++
++/* Ask the X server for user idle time (using XScreenSaver API)
++ * Return true if the idle time exceeds idle_threshold for all accessible
++ * Xservers. However, if even one Xserver reports busy/non-idle, then
++ * return false. This function assumes that the boinc user has been
++ * granted access to the Xservers a la "xhost +SI:localuser:boinc". If
++ * access isn't available for an Xserver, then that Xserver is skipped.
++ * One may drop a file in /etc/X11/Xsession.d/ that runs the xhost command
++ * for all Xservers on a machine when the Xservers start up.
++ */
+ bool xss_idle(long idle_threshold) {
+- static XScreenSaverInfo* xssInfo = NULL;
+- static Display* disp = NULL;
+- // if an X-related error occurs, set this to true and always
+- // report that we are idle (have xss_idle return true). Will report the
+- // failure in Event Log for user visibility.
+- static bool error = false;
+-
+- if (error) return true;
+
++ const vector<string> display_values = X_display_values_initialize();
++ vector<string>::const_iterator it;
++
++ static XScreenSaverInfo* xssInfo = XScreenSaverAllocInfo();
++ // This shouldn't fail. XScreenSaverAllocInfo just returns a small
++ // struct (see "man 3 xss"). If we can't allocate this, then we've
++ // got bigger problems to worry about.
++ if ( xssInfo == NULL ) {
++ msg_printf(NULL, MSG_INFO,
++ "XScreenSaverAllocInfo failed. Out of memory? Skipping XScreenSaver idle detection.");
++ return true;
++ }
++
++ for (it = display_values.begin() ; it != display_values.end() ; it++) {
++
++ Display* disp = NULL;
+ long idle_time = 0;
+
++ disp = XOpenDisplay(it->c_str());
++ // XOpenDisplay may return NULL if there is no running X
++ // or DISPLAY points to wrong/invalid display
+ 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. X-based idle detection disabled.");
+- return true;
+- }
+- 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. X-based idle detection disabled.");
+- return true;
+- }
++ msg_printf(NULL, MSG_INFO,
++ "DISPLAY '%s' not found or insufficient access.",
++ it->c_str());
++ continue;
+ }
+
++ // Determine if the DISPLAY we have accessed has the XScreenSaver
++ // extension or not.
++ int event_base_return, error_base_return;
++ if (!XScreenSaverQueryExtension(
++ disp, &event_base_return, &error_base_return
++ )){
++ msg_printf(NULL, MSG_INFO,
++ "XScreenSaver extension not available for DISPLAY '%s'.",
++ it->c_str());
++ continue;
++ }
++
++ // All checks passed. Get the idle information.
+ 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);
++ msg_printf(NULL, MSG_INFO, "XSS idle detection succeeded on DISPLAY '%s'.", it->c_str());
++ 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.");
++ msg_printf(NULL, MSG_INFO, "DISPLAY '%s' is idle.", it->c_str());
+ } else {
+- //msg_printf(NULL, MSG_INFO, "System is active according to X.");
++ msg_printf(NULL, MSG_INFO, "DISPLAY '%s' is active.", it->c_str());
++ return false;
+ }
+- return idle_threshold < idle_time;
++
++ }
++
++ /* We should only ever get here if all Xservers (that were queryable) were
++ * idle. If none of the Xservers were queryable, we should still end up here,
++ * and simply report true. In that case, the xss_idle function effectively
++ * provides no information on the idle state of the system, as no Xservers
++ * were accessible to interrogate.
++ */
++ return true;
++
+ }
+ #endif // HAVE_XSS
+
diff --git a/debian/patches/fc4446f6027cc0d0e75e634f572b50b88588b57d.patch b/debian/patches/fc4446f6027cc0d0e75e634f572b50b88588b57d.patch
new file mode 100644
index 0000000..f0b621a
--- /dev/null
+++ b/debian/patches/fc4446f6027cc0d0e75e634f572b50b88588b57d.patch
@@ -0,0 +1,253 @@
+## Description: add some description
+## Origin/Author: add some origin or author
+## Bug: bug URL
+From fc4446f6027cc0d0e75e634f572b50b88588b57d Mon Sep 17 00:00:00 2001
+From: Preston Maness <aggroskater at gmail.com>
+Date: Wed, 30 Dec 2015 17:03:35 -0600
+Subject: [PATCH] Reinstate and Improve XScreenSaver Idle Detection
+
+The set of commits on this pull request:
+
+https://github.com/BOINC/boinc/pull/1453
+
+first reinstated previously existing code to utilize the XScreenSaver
+(XSS) X extension when determining a system's idle state (there was
+also additional DPMS code that was not reinstated).
+
+Original removal:
+
+https://github.com/BOINC/boinc/commit/bfae1032e5c1ac73f2d8d92f222293d8383a6cee
+
+The code would attempt to open a connection to the display at the client
+binary's DISPLAY environment variable and, if unable to connect, always
+report busy (undesirable).
+
+The original motivation for reinstating this code was that the remaining
+idle detection mechanisms did not detect mouse or keyboard movement if
+an Xserver was responsible for them. Only activities in terminals were
+detected. Through the course of extending and improving this code, the
+following changes have been made:
+
+ * As per "man Xserver", each local Xserver should have a socket file
+ at standard location /tmp/.X11-unix/ with standard naming scheme
+"Xn", where n is the number of the DISPLAY. This code will open this
+directory and parse its contents for open DISPLAYs, adding them to a
+vector for later interrogation of idle time by xss_idle. If no DISPLAYs
+were found, a static guess-list from DISPLAY :0 to DISPLAY :6 is set and
+interrogated.
+ * xss_idle uses the XScreenSaver X extension's API, as documented at
+ "man 3 xss". Certain checks are performed to determine if the X
+server is accessible, and if so, whether it has the XScreenSaver
+extension. If it does, then we obtain information on the DISPLAY's idle
+time and determine whether the Xserver is idle or not.
+ * The user running the boinc client (typically the "boinc" user for
+ most distributions), must have access to the Xserver for XSS idle
+detection to work. Dropping an appropriate file in /etc/X11/Xsession.d/
+(Debian flavours) or /etc/X11/xinit/xinitrc.d/ (Fedora and others)
+should permit Xservers to run something like "xhost +SI:localuser:boinc"
+on start. If the boinc client cannot access an Xserver/DISPLAY, it
+simply skips it and treats it as though it is idle. If no DISPLAY is
+accessible, then xss_idle is effectively passed through --xss_idle will
+report the system as idle-- and idle detection is left to other
+mechanisms.
+ * A debug logging flag "idle_detection_debug" was added. If this
+ flag is defined in the cc_config.xml file as "1", then verbose
+debugging information related to boinc's idle detection determinations is
+provided to the Event Log. This logging flag may also be utilized
+by other components of idle detection as/if needed/desired.
+---
+ client/hostinfo_unix.cpp | 64 ++++++++++++++++++++++++++++++++++++------------
+ client/log_flags.cpp | 1 +
+ lib/cc_config.cpp | 3 +++
+ lib/cc_config.h | 2 ++
+ 4 files changed, 55 insertions(+), 15 deletions(-)
+
+diff --git a/client/hostinfo_unix.cpp b/client/hostinfo_unix.cpp
+index 1e20ad6..a1fc652 100644
+--- a/client/hostinfo_unix.cpp
++++ b/client/hostinfo_unix.cpp
+@@ -47,7 +47,8 @@
+ // lib/prefs.h definition in an enum.
+ #undef Always
+ #include <dirent.h> //for opening /tmp/.X11-unix/
+-// (There is a DirScanner class in BOINC, but it doesn't do what we want)
++ // (There is a DirScanner class in BOINC, but it doesn't do what we want)
++#include "log_flags.h" // idle_detection_debug flag for verbose output
+ #endif
+
+ #include <cstdio>
+@@ -1983,7 +1984,10 @@ const vector<string> X_display_values_initialize() {
+ DIR *dp;
+ struct dirent *dirp;
+ if((dp = opendir(dir.c_str())) == NULL) {
+- msg_printf(NULL, MSG_INFO, "Error (%d) opening %s.", errno, dir.c_str());
++ if ( log_flags.idle_detection_debug ) {
++ msg_printf(NULL, MSG_INFO,
++ "[idle_detection] Error (%d) opening %s.", errno, dir.c_str());
++ }
+ }
+
+ while ((dirp = readdir(dp)) != NULL) {
+@@ -2010,6 +2014,12 @@ const vector<string> X_display_values_initialize() {
+ // more than seven active, local Xservers. I'm sure they exist... somewhere.
+ // But seven was the magic number for me).
+ if ( display_values.size() == 0 ) {
++ if ( log_flags.idle_detection_debug ) {
++ msg_printf(NULL, MSG_INFO,
++ "[idle_detection] No DISPLAY values found in /tmp/.X11-unix/.");
++ msg_printf(NULL, MSG_INFO,
++ "[idle_detection] Using static DISPLAY list, :{0..6}.");
++ }
+ display_values.push_back(":0");
+ display_values.push_back(":1");
+ display_values.push_back(":2");
+@@ -2037,14 +2047,18 @@ bool xss_idle(long idle_threshold) {
+
+ const vector<string> display_values = X_display_values_initialize();
+ vector<string>::const_iterator it;
++ // If we can connect to at least one DISPLAY, this is set to false.
++ bool no_available_x_display = true;
+
+ static XScreenSaverInfo* xssInfo = XScreenSaverAllocInfo();
+ // This shouldn't fail. XScreenSaverAllocInfo just returns a small
+ // struct (see "man 3 xss"). If we can't allocate this, then we've
+ // got bigger problems to worry about.
+ if ( xssInfo == NULL ) {
+- msg_printf(NULL, MSG_INFO,
+- "XScreenSaverAllocInfo failed. Out of memory? Skipping XScreenSaver idle detection.");
++ if ( log_flags.idle_detection_debug ) {
++ msg_printf(NULL, MSG_INFO,
++ "[idle_detection] XScreenSaverAllocInfo failed. Out of memory? Skipping XScreenSaver idle detection.");
++ }
+ return true;
+ }
+
+@@ -2057,9 +2071,11 @@ bool xss_idle(long idle_threshold) {
+ // XOpenDisplay may return NULL if there is no running X
+ // or DISPLAY points to wrong/invalid display
+ if (disp == NULL) {
+- msg_printf(NULL, MSG_INFO,
+- "DISPLAY '%s' not found or insufficient access.",
+- it->c_str());
++ if ( log_flags.idle_detection_debug ) {
++ msg_printf(NULL, MSG_INFO,
++ "[idle_detection] DISPLAY '%s' not found or insufficient access.",
++ it->c_str());
++ }
+ continue;
+ }
+
+@@ -2069,27 +2085,41 @@ bool xss_idle(long idle_threshold) {
+ if (!XScreenSaverQueryExtension(
+ disp, &event_base_return, &error_base_return
+ )){
+- msg_printf(NULL, MSG_INFO,
+- "XScreenSaver extension not available for DISPLAY '%s'.",
+- it->c_str());
++ if ( log_flags.idle_detection_debug ) {
++ msg_printf(NULL, MSG_INFO,
++ "[idle_detection] XScreenSaver extension not available for DISPLAY '%s'.",
++ it->c_str());
++ }
+ continue;
+ }
+
+ // All checks passed. Get the idle information.
++ no_available_x_display = 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 on DISPLAY '%s'.", it->c_str());
+- msg_printf(NULL, MSG_INFO, "idle threshold: %ld", idle_threshold);
+- msg_printf(NULL, MSG_INFO, "idle_time: %ld", idle_time);
++ if ( log_flags.idle_detection_debug ) {
++ msg_printf(NULL, MSG_INFO,
++ "[idle_detection] XSS idle detection succeeded on DISPLAY '%s'.", it->c_str());
++ msg_printf(NULL, MSG_INFO,
++ "[idle_detection] idle threshold: %ld", idle_threshold);
++ msg_printf(NULL, MSG_INFO,
++ "[idle_detection] idle_time: %ld", idle_time);
++ }
+
+ if ( idle_threshold < idle_time ) {
+- msg_printf(NULL, MSG_INFO, "DISPLAY '%s' is idle.", it->c_str());
++ if ( log_flags.idle_detection_debug ) {
++ msg_printf(NULL, MSG_INFO,
++ "[idle_detection] DISPLAY '%s' is idle.", it->c_str());
++ }
+ } else {
+- msg_printf(NULL, MSG_INFO, "DISPLAY '%s' is active.", it->c_str());
++ if ( log_flags.idle_detection_debug ) {
++ msg_printf(NULL, MSG_INFO,
++ "[idle_detection] DISPLAY '%s' is active.", it->c_str());
++ }
+ return false;
+ }
+
+@@ -2101,6 +2131,10 @@ bool xss_idle(long idle_threshold) {
+ * provides no information on the idle state of the system, as no Xservers
+ * were accessible to interrogate.
+ */
++ if ( log_flags.idle_detection_debug && no_available_x_display ) {
++ msg_printf(NULL, MSG_INFO,
++ "[idle_detection] Could not connect to any DISPLAYs. XSS idle determination impossible.");
++ }
+ return true;
+
+ }
+diff --git a/client/log_flags.cpp b/client/log_flags.cpp
+index 16002cb..fe5b1c1 100644
+--- a/client/log_flags.cpp
++++ b/client/log_flags.cpp
+@@ -87,6 +87,7 @@ void LOG_FLAGS::show() {
+ show_flag(buf, heartbeat_debug, "heartbeat_debug");
+ show_flag(buf, http_debug, "http_debug");
+ show_flag(buf, http_xfer_debug, "http_xfer_debug");
++ show_flag(buf, idle_detection_debug, "idle_detection_debug");
+ show_flag(buf, mem_usage_debug, "mem_usage_debug");
+ show_flag(buf, network_status_debug, "network_status_debug");
+ show_flag(buf, notice_debug, "notice_debug");
+diff --git a/lib/cc_config.cpp b/lib/cc_config.cpp
+index 23f78db..dad863f 100644
+--- a/lib/cc_config.cpp
++++ b/lib/cc_config.cpp
+@@ -80,6 +80,7 @@ int LOG_FLAGS::parse(XML_PARSER& xp) {
+ if (xp.parse_bool("heartbeat_debug", heartbeat_debug)) continue;
+ if (xp.parse_bool("http_debug", http_debug)) continue;
+ if (xp.parse_bool("http_xfer_debug", http_xfer_debug)) continue;
++ if (xp.parse_bool("idle_detection_debug", idle_detection_debug)) continue;
+ if (xp.parse_bool("mem_usage_debug", mem_usage_debug)) continue;
+ if (xp.parse_bool("network_status_debug", network_status_debug)) continue;
+ if (xp.parse_bool("notice_debug", notice_debug)) continue;
+@@ -127,6 +128,7 @@ int LOG_FLAGS::write(MIOFILE& out) {
+ " <heartbeat_debug>%d</heartbeat_debug>\n"
+ " <http_debug>%d</http_debug>\n"
+ " <http_xfer_debug>%d</http_xfer_debug>\n"
++ " <idle_detection_debug>%d</idle_detection_debug>\n"
+ " <mem_usage_debug>%d</mem_usage_debug>\n"
+ " <network_status_debug>%d</network_status_debug>\n"
+ " <notice_debug>%d</notice_debug>\n"
+@@ -167,6 +169,7 @@ int LOG_FLAGS::write(MIOFILE& out) {
+ heartbeat_debug ? 1 : 0,
+ http_debug ? 1 : 0,
+ http_xfer_debug ? 1 : 0,
++ idle_detection_debug ? 1 : 0,
+ mem_usage_debug ? 1 : 0,
+ network_status_debug ? 1 : 0,
+ notice_debug ? 1 : 0,
+diff --git a/lib/cc_config.h b/lib/cc_config.h
+index 29a000f..f9a1f7f 100644
+--- a/lib/cc_config.h
++++ b/lib/cc_config.h
+@@ -83,6 +83,8 @@ struct LOG_FLAGS {
+ bool heartbeat_debug;
+ bool http_debug;
+ bool http_xfer_debug;
++ bool idle_detection_debug;
++ // show details leading to idle/not-idle determinations.
+ bool mem_usage_debug;
+ // memory usage
+ bool network_status_debug;
diff --git a/debian/patches/series b/debian/patches/series
index 7ee4aaa..6aa1b22 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -31,3 +31,5 @@ envargs.patch
fix-underlinking.patch
156b0be9f13b3427973f1d83a004947225b2d8b6.patch
882d0cdd43d39bec7328be79c9da73a04c597ec7.patch
+69abe830e6069ec2139783392e8d3a73fb7e6baf.patch
+fc4446f6027cc0d0e75e634f572b50b88588b57d.patch
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-boinc/boinc.git
More information about the pkg-boinc-commits
mailing list