Re: [mpd-devel] [PATCH] Emit a warning if the OutputThread fails to get realtime scheduling

2015-06-22 Thread Christian Halaszovich

From 48af12433916d9f20286ec4d8f9eac069f2f04d0 Mon Sep 17 00:00:00 2001
From: Christian Halaszovich 
Date: Thu, 18 Jun 2015 10:38:32 +0200
Subject: [PATCH] Emit a warning if the OutputThread fails to get 
realtime scheduling


This only applies to linux systems. Here, sched_setscheduler() is
called to get realtime scheduling. With this patch, the return value
of this function is now checked and a warning / error message is
generated if it fails.
---
 src/output/OutputThread.cxx |  7 ++-
 src/thread/Util.hxx | 19 +++
 2 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/src/output/OutputThread.cxx b/src/output/OutputThread.cxx
index 9baaaf0..d2f9ea8 100644
--- a/src/output/OutputThread.cxx
+++ b/src/output/OutputThread.cxx
@@ -587,7 +587,12 @@ AudioOutput::Task()
 {
FormatThreadName("output:%s", name);

-   SetThreadRealtime();
+   Error error;
+   if(!SetThreadRealtime(error)) {
+   LogError(error);
+   LogWarning(output_domain,
+   "OutputThread could not get realtime scheduling, continuing 
anyway");
+   }
SetThreadTimerSlackUS(100);

mutex.lock();
diff --git a/src/thread/Util.hxx b/src/thread/Util.hxx
index ff8dbbe..fdc767c 100644
--- a/src/thread/Util.hxx
+++ b/src/thread/Util.hxx
@@ -30,6 +30,8 @@
 #ifndef THREAD_UTIL_HXX
 #define THREAD_UTIL_HXX

+#include "util/Error.hxx"
+
 #ifdef __linux__
 #include 
 #include 
@@ -81,9 +83,11 @@ SetThreadIdlePriority()

 /**
  * Raise the current thread's priority to "real-time" (very high).
+ * @param[out] error   Receives error information on failure
+ * @return true on success (always true on non-linux systems)
  */
-static inline void
-SetThreadRealtime()
+static inline bool
+SetThreadRealtime(Error& error)
 {
 #ifdef __linux__
struct sched_param sched_param;
@@ -94,8 +98,15 @@ SetThreadRealtime()
policy |= SCHED_RESET_ON_FORK;
 #endif

-   sched_setscheduler(0, policy, &sched_param);
-#endif
+   if(sched_setscheduler(0, policy, &sched_param)==0) {
+   return true;
+   } else {
+   error.FormatErrno("sched_setscheduler failed");
+   return false;
+   }
+#else
+   return true; // on non-linux systems, we pretend it worked
+#endif // __linux__
 };

 #endif
--
1.9.1
___
mpd-devel mailing list
mpd-devel@musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel


Re: [mpd-devel] [PATCH] Emit a warning if the OutputThread fails to get realtime scheduling

2015-06-22 Thread Christian Halaszovich

I created a new patch, against the current master branch.

On 22.06.2015 18:42, Max Kellermann wrote:

On 2015/06/22 16:42, Christian Halaszovich  wrote:

This only applies to linux systems. Here, sched_setscheduler() is
called to get realtime scheduling. With this patch, the return value
of this function is now checked and a warning / error message is
generated if it fails.

git cannot apply this patch:

  Applying: Emit a warning if the OutputThread fails to get realtime scheduling
  error: patch failed: src/output/OutputThread.cxx:587
  error: src/output/OutputThread.cxx: patch does not apply
  error: patch failed: src/thread/Util.hxx:30
  error: src/thread/Util.hxx: patch does not apply
  Patch failed at 0001 Emit a warning if the OutputThread fails to get realtime 
scheduling


___
mpd-devel mailing list
mpd-devel@musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel


[mpd-devel] six Debian patches

2015-06-22 Thread Florian Schlichting
Hi,

in response to Debian bugs, the Debian mpd package has accumulated a
number of smallish patches (mostly docmentation), which I'd like to
forward for discussion and inclusion. Please see attached.

Florian
Description: Fix a doc typo
Author: Florian Schlichting 

--- a/doc/user.xml
+++ b/doc/user.xml
@@ -16,7 +16,7 @@
   MPD (Music Player Daemon) is, as the
   name suggests, a server software allowing you to remotely play
   your music, handle playlists, deliver music (HTTP streams with
-  various sub-protocols) and organizze playlists.
+  various sub-protocols) and organize playlists.
 
 
 
Description: also disable mpd.socket when disabling mpd.service
 e.g. when running 'update-rc.d mpd disable'
Author: Clément B. 
Bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=769951

--- a/systemd/mpd.service.in
+++ b/systemd/mpd.service.in
@@ -20,3 +20,4 @@
 
 [Install]
 WantedBy=multi-user.target
+Also=mpd.socket
Description: Protect /usr when running under systemd
Author: Florian Schlichting  
Bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=771634

--- a/systemd/mpd.service.in
+++ b/systemd/mpd.service.in
@@ -18,6 +18,9 @@
 # assign a real-time budget
 ControlGroupAttribute=cpu.rt_runtime_us 50
 
+# disallow writing to /usr, /bin, /sbin, ...
+ProtectSystem=yes
+
 [Install]
 WantedBy=multi-user.target
 Also=mpd.socket
Description: Fix "Unknown lvalue 'ControlGroup' in section 'Service'" warnings
 systemd 205 removed the ControlGroup and ControlGroupAttribute
 directives (see
 http://lists.freedesktop.org/archives/systemd-devel/2013-July/011679.html),
 so they have been ineffective since and only caused the above warnings
 to be written to the journal. However the above changelog suggests "Please
 use high-level attribute settings instead as well as slice units."
Author: Florian Schlichting 
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=781377

--- a/systemd/mpd.service.in
+++ b/systemd/mpd.service.in
@@ -9,15 +9,6 @@
 LimitRTPRIO=50
 LimitRTTIME=-1
 
-# move MPD to a top-level cgroup, as real-time budget assignment fails
-# in cgroup /system/mpd.service, because /system has a zero real-time
-# budget; see
-# http://www.freedesktop.org/wiki/Software/systemd/MyServiceCantGetRealtime/
-ControlGroup=cpu:/mpd
-
-# assign a real-time budget
-ControlGroupAttribute=cpu.rt_runtime_us 50
-
 # disallow writing to /usr, /bin, /sbin, ...
 ProtectSystem=yes
 
Description: document effect of http_proxy envvar on curl plugin
Author: Florian Schlichting  
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=624774

--- a/doc/user.xml
+++ b/doc/user.xml
@@ -1684,6 +1684,13 @@
   Opens remote files or streams over HTTP.
 
 
+
+  Note that unless overridden by the below settings (e.g. by
+  setting them to a blank value), general curl configuration
+  from environment variables such as http_proxy or specified
+  in ~/.curlrc will be in effect.
+
+
 
   
 
Description: document that socket activation voids bind_to_address setting
Author: Florian Schlichting 
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=785418

--- a/doc/mpdconf.example
+++ b/doc/mpdconf.example
@@ -75,7 +75,8 @@
 #
 # This setting sets the address for the daemon to listen on. Careful attention
 # should be paid if this is assigned to anything other then the default, any.
-# This setting can deny access to control of the daemon.
+# This setting can deny access to control of the daemon. Not effective if
+# systemd socket activiation is in use.
 #
 # For network
 #bind_to_address		"any"
___
mpd-devel mailing list
mpd-devel@musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel


Re: [mpd-devel] [PATCH] Emit a warning if the OutputThread fails to get realtime scheduling

2015-06-22 Thread Max Kellermann
On 2015/06/22 16:42, Christian Halaszovich  wrote:
> This only applies to linux systems. Here, sched_setscheduler() is
> called to get realtime scheduling. With this patch, the return value
> of this function is now checked and a warning / error message is
> generated if it fails.

git cannot apply this patch:

 Applying: Emit a warning if the OutputThread fails to get realtime scheduling
 error: patch failed: src/output/OutputThread.cxx:587
 error: src/output/OutputThread.cxx: patch does not apply
 error: patch failed: src/thread/Util.hxx:30
 error: src/thread/Util.hxx: patch does not apply
 Patch failed at 0001 Emit a warning if the OutputThread fails to get realtime 
scheduling
___
mpd-devel mailing list
mpd-devel@musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel


[mpd-devel] [PATCH] Emit a warning if the OutputThread fails to get realtime scheduling

2015-06-22 Thread Christian Halaszovich

This only applies to linux systems. Here, sched_setscheduler() is
called to get realtime scheduling. With this patch, the return value
of this function is now checked and a warning / error message is
generated if it fails.
---
 src/output/OutputThread.cxx |  7 ++-
 src/thread/Util.hxx | 19 +++
 2 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/src/output/OutputThread.cxx b/src/output/OutputThread.cxx
index 9baaaf0..d2f9ea8 100644
--- a/src/output/OutputThread.cxx
+++ b/src/output/OutputThread.cxx
@@ -587,7 +587,12 @@ AudioOutput::Task()
 {
FormatThreadName("output:%s", name);

-   SetThreadRealtime();
+   Error error;
+   if(!SetThreadRealtime(error)) {
+   LogError(error);
+   LogWarning(output_domain,
+   "OutputThread could not get realtime scheduling, continuing 
anyway");
+   }
SetThreadTimerSlackUS(100);

mutex.lock();
diff --git a/src/thread/Util.hxx b/src/thread/Util.hxx
index ff8dbbe..fdc767c 100644
--- a/src/thread/Util.hxx
+++ b/src/thread/Util.hxx
@@ -30,6 +30,8 @@
 #ifndef THREAD_UTIL_HXX
 #define THREAD_UTIL_HXX

+#include "util/Error.hxx"
+
 #ifdef __linux__
 #include 
 #include 
@@ -81,9 +83,11 @@ SetThreadIdlePriority()

 /**
  * Raise the current thread's priority to "real-time" (very high).
+ * @param[out] error   Receives error information on failure
+ * @return true on success (always true on non-linux systems)
  */
-static inline void
-SetThreadRealtime()
+static inline bool
+SetThreadRealtime(Error& error)
 {
 #ifdef __linux__
struct sched_param sched_param;
@@ -94,8 +98,15 @@ SetThreadRealtime()
policy |= SCHED_RESET_ON_FORK;
 #endif

-   sched_setscheduler(0, policy, &sched_param);
-#endif
+   if(sched_setscheduler(0, policy, &sched_param)==0) {
+   return true;
+   } else {
+   error.FormatErrno("sched_setscheduler failed");
+   return false;
+   }
+#else
+   return true; // on non-linux systems, we pretend it worked
+#endif // __linux__
 };

 #endif
--
1.9.1

___
mpd-devel mailing list
mpd-devel@musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel


Re: [mpd-devel] [PATCH] Emmit a warning if the OutputThread fails to get realtime scheduling

2015-06-22 Thread Christian Halaszovich
I see. I made the mistake of sending the patch using inbox.google.com,
which apparently mangles the formatting.
I will send the patch again, with the subject line corrected("Emmit" -> "Emit")


2015-06-22 8:52 GMT+02:00 Max Kellermann :
> On 2015/06/18 12:02, Christian Halaszovich  wrote:
>> This only applies to linux systems. Here, sched_setscheduler() is
>> called to get realtime scheduling. With this patch, the return value
>> of this function is now checked and a warning and an error message are
>> generated if it failed.
>
> Indentation is broken in your code.  Broken as in: does not exist.
___
mpd-devel mailing list
mpd-devel@musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel


Re: [mpd-devel] [PATCH 2/6] tag: Ape/Riff/Aiff/Id3 now use an InputStream

2015-06-22 Thread Max Kellermann
On 2015/06/05 16:27, Thomas Guillem  wrote:
> This allow to use these scanners for remote InputStream like SMB and
> NFS.

Fails to compile:

test/dump_rva2.cxx: In function 'int main(int, char**)':
dump_rva2.cxx:60:62: error: invalid initialization of non-const reference of 
type 'InputStream&' from an rvalue of type 'Path' 
  struct id3_tag *tag = tag_id3_load(Path::FromFS(path), error);
___
mpd-devel mailing list
mpd-devel@musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel