Andreas Mair | 28 Jun 08:40 2015
Picon

find track "1" not working as expected

Hi,

I'm trying to find out why MPDroid is so slow when it lists an
artist's albums. So I enabled debug logging in MPD and noticed that
MPDroid issues three MPD queries for each album it has to show.

For example:
client: [12] process command "find "albumartist" "Aerosmith" "album"
"Pump" "track" "1""
client: [12] command returned 0
client: [12] process command "find "albumartist" "Aerosmith" "album"
"Pump" "track" "01""
client: [12] command returned 0
client: [12] process command "search "albumartist" "Aerosmith" "album"
"Pump" "track" "1""
client: [12] command returned 0

I would expect, that the first command (track "1") should work, but
there's no result. That's also true for the second command (track
"01"). The third command returns every song of that album (because it
has 10 songs).
I've taken a look at the MPD sources and I think the problem is, that
MPD tries an exact *string* match. If I use "... find 01/10" it works,
but I think that's not ideal to work like this because one has to know
(1)  how many songs an album has and (2) if the number of total tracks
is stored and (3) if leading zeros are used.

I'd suggest that MPD uses *numeric* matches for numeric fields like
track or disc number. Or do I miss something?

(Continue reading)

Florian Schlichting | 23 Jun 00:38 2015
Picon
Picon

six Debian patches

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
Attachment (00-typo.patch): text/x-diff, 478 bytes
Attachment (02-protect_system.patch): text/x-diff, 441 bytes
Attachment (04-curl-proxy.patch): text/x-diff, 677 bytes
_______________________________________________
mpd-devel mailing list
mpd-devel <at> musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel
Christian Halaszovich | 22 Jun 16:42 2015
Picon

[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
 <at>  <at>  -587,7 +587,12  <at>  <at>  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
(Continue reading)

Christian Halaszovich | 18 Jun 12:02 2015
Picon

[PATCH] Emmit 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 and an error message are
generated if it failed.
---
 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
<at> <at> -587,7 +587,12 <at> <at> 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
<at> <at> -30,6 +30,8 <at> <at>
 #ifndef THREAD_UTIL_HXX
 #define THREAD_UTIL_HXX
 
+#include "util/Error.hxx"
+
 #ifdef __linux__
 #include <sched.h>
 #include <sys/syscall.h>
<at> <at> -81,9 +83,11 <at> <at> SetThreadIdlePriority()
 
 /**
  * Raise the current thread's priority to "real-time" (very high).
+ * <at> param[out] error Receives error information on failure 
+ * <at> 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;
<at> <at> -94,8 +98,15 <at> <at> 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 <at> musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel
Christian Halaszovich | 17 Jun 13:34 2015
Picon

[PATCH 1/2] SetThreadRealtime() now reports if getting realtime scheduling was successful. (Only meaningful on Linux systems.)

Hello mpd developers,

after using mpd for quite some time I would like to contribute a little to its development.

Under certain circumstances, on linux systems OutputThread fails to get realtime scheduling. I think it would be useful to inform the user when this happens. Therefore I'm submitting 2 patches.

Patch 1/2. Check the return value of sched_setscheduler() in SetThreadRealtime. Report to the caller, if we were successful. To this end SetThreadRealtime now returns false, if ached_setschedluer failed or true on all other cases. On non-linux systems SetThreadRealtime does not do anything and will always return true.

Patch 2/2. In OutputThread (seems to be the only caller of SetThreadRelatime) the return value is checked. If SetThreadRealtime failed, a warning is logged using LogWarning. I decide to put LogWarning here, since the caller of SetThreadRealtime should decide how to handle this.

Please let me know what you think about this.

Best,
Christian Halaszovich

---
 src/thread/Util.hxx | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/thread/Util.hxx b/src/thread/Util.hxx
index ff8dbbe..5e63e44 100644
--- a/src/thread/Util.hxx
+++ b/src/thread/Util.hxx
<at> <at> -81,10 +81,12 <at> <at> SetThreadIdlePriority()
 
 /**
  * Raise the current thread's priority to "real-time" (very high).
+ * return value: true on success
  */
-static inline void
+static inline bool
 SetThreadRealtime()
 {
+ bool success = true;
 #ifdef __linux__
  struct sched_param sched_param;
  sched_param.sched_priority = 50;
<at> <at> -94,8 +96,9 <at> <at> SetThreadRealtime()
  policy |= SCHED_RESET_ON_FORK;
 #endif
 
- sched_setscheduler(0, policy, &sched_param);
+ success = 0==sched_setscheduler(0, policy, &sched_param);
 #endif
+ return success; // on non-linux machines we will always pretend it worked
 };
 
 #endif
-- 
1.9.1

_______________________________________________
mpd-devel mailing list
mpd-devel <at> musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel
Christian Halaszovich | 17 Jun 13:36 2015
Picon

[PATCH 2/2] Added a warning that will be logged if OutputThread fails to get realtime scheduling.

---
 src/output/OutputThread.cxx | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/output/OutputThread.cxx b/src/output/OutputThread.cxx
index 9baaaf0..c16942d 100644
--- a/src/output/OutputThread.cxx
+++ b/src/output/OutputThread.cxx
<at> <at> -587,7 +587,9 <at> <at> AudioOutput::Task()
 {
  FormatThreadName("output:%s", name);
 
- SetThreadRealtime();
+ if(!SetThreadRealtime()) {
+ LogWarning(output_domain, "OutputThread could not get realtime scheduling, continuing anyway");
+ }
  SetThreadTimerSlackUS(100);
 
  mutex.lock();
-- 
1.9.1

_______________________________________________
mpd-devel mailing list
mpd-devel <at> musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel
salorium ♥ | 12 Jun 09:29 2015
Picon

Add Elapsed time in mpc‏

Hello,
i want a git account for add elapsed time on mpc

real name : Saleur Geoffrey
email address : salorium <at> hotmail.fr
preferred user name : salorium
projects you wish to work on : mpc
SSH public key(s) (as attachment or URL, do not copy and paste) : http://salorium.com/id_rsa.pub

Elapsed time:
https://github.com/salorium/mpc

Thank you,
_______________________________________________
mpd-devel mailing list
mpd-devel <at> musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel
salorium ♥ | 27 May 22:08 2015
Picon

Add Elapsed time in mpc

Hello,
i want a git account for add elapsed time on mpc
  1. real name : Saleur Geoffrey
  2. email address : salorium <at> hotmail.fr
  3. preferred user name : salorium
  4. projects you wish to work on : mpc
  5. SSH public key(s) (as attachment or URL, do not copy and paste) : http://salorium.com/id_rsa.pub
Elapsed time :
https://github.com/salorium/mpc

Thank you,

_______________________________________________
mpd-devel mailing list
mpd-devel <at> musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel
Thomas Guillem | 21 May 23:43 2015
Picon

[PATCH 0/6] Change the Ape/Riff/Aiff/Id3 scanners to use an InputStream

This set of patches modify the tag scanners to use an InputStream. That way
you can use these scanners with a remote input like NFS and SMB.

Waiting for your comments.

Best regards,
Thomas Guillem

Thomas Guillem (6):
  InputStream: add ReadFull method
  tag: Ape/Riff/Aiff/Id3 now use an InputStream
  SongUpdate: use an InputStream to scan from decoders and tag scanners
  FileCommands: use one InputStream for both scanners
  EmbeddedCuePlaylist: use one InputStream for both scanners
  Remove unused TagFile.cxx

 Makefile.am                                        |   2 -
 src/SongUpdate.cxx                                 |  83 +++++++++--------
 src/TagFile.cxx                                    | 100 ---------------------
 src/TagFile.hxx                                    |  38 --------
 src/command/FileCommands.cxx                       |  21 +++--
 src/input/InputStream.cxx                          |  31 ++++++-
 src/input/InputStream.hxx                          |  21 +++++
 src/playlist/plugins/EmbeddedCuePlaylistPlugin.cxx |  22 +++--
 src/tag/Aiff.cxx                                   |  29 ++----
 src/tag/Aiff.hxx                                   |   4 +-
 src/tag/ApeLoader.cxx                              |  43 ++++++---
 src/tag/ApeLoader.hxx                              |  11 +++
 src/tag/ApeTag.cxx                                 |  19 ++++
 src/tag/ApeTag.hxx                                 |  10 +++
 src/tag/Riff.cxx                                   |  29 ++----
 src/tag/Riff.hxx                                   |   4 +-
 src/tag/TagId3.cxx                                 | 100 ++++++++++++++-------
 src/tag/TagId3.hxx                                 |  11 ++-
 18 files changed, 299 insertions(+), 279 deletions(-)
 delete mode 100644 src/TagFile.cxx
 delete mode 100644 src/TagFile.hxx

--

-- 
2.1.4

_______________________________________________
mpd-devel mailing list
mpd-devel <at> musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel
Yclept Nemo | 21 May 05:31 2015
Picon

[PATCH] Workaround: open() ignores 'mode' with O_TMPFILE

From f530e59fd363722a7a4fa9fd60b2da2241c1a9fc Mon Sep 17 00:00:00 2001
From: Yclept Nemo <pscjtwjdjtAhnbjm/dpn>
Date: Wed, 20 May 2015 23:18:15 -0400
Subject: [PATCH] Workaround: open() ignores 'mode' with O_TMPFILE

---
 configure.ac                   | 51 ++++++++++++++++++++++++++++++++++++++++++
 src/fs/io/FileOutputStream.cxx |  8 ++-----
 src/system/FileDescriptor.cxx  |  4 ++++
 src/system/FileDescriptor.hxx  |  9 ++++++++
 4 files changed, 66 insertions(+), 6 deletions(-)

diff --git a/configure.ac b/configure.ac
index 82f814d..ed76f51 100644
--- a/configure.ac
+++ b/configure.ac
<at> <at> -561,6 +561,57 <at> <at> if test x$enable_largefile != xno; then
 fi
 
 dnl ---------------------------------------------------------------------------
+dnl LIBC Workarounds
+dnl ---------------------------------------------------------------------------
+if test "x$host_is_linux" = xyes && test "x$ac_cv_func_linkat" = xyes && test "x$enable_largefile" != xno; then
+    AC_MSG_CHECKING( [if O_TMPFILE requires fchmod])
+    AC_RUN_IFELSE(
+          [AC_LANG_PROGRAM(
+              [[#define _FILE_OFFSET_BITS 64
+                #include <fcntl.h>
+                #include <limits.h>
+                #include <sys/types.h>
+                #include <sys/stat.h>
+              ]] 
+            , [[struct stat statbuf;
+                int fd;
+                int mode = 0666;
+                if ((fd = open(".", O_TMPFILE|O_WRONLY, mode)) < 0)
+                    return 1;
+                if (fstat(fd, &statbuf) < 0)
+                    return 1;
+                if (close(fd) < 0)
+                    return 1;
+                if ((statbuf.st_mode & (S_IRWXU|S_IRWXG|S_IRWXO)) != mode)
+                    return 1;
+                return 0;
+              ]]
+            )
+          ]
+        , open_tmpfile_fchmod=no
+        , open_tmpfile_fchmod=yes
+        , open_tmpfile_fchmod=yes
+        )
+    if test "x$open_tmpfile_fchmod" = xyes; then
+        AC_MSG_RESULT([yes])
+        AC_CHECK_FUNCS(
+              [fchmod]
+            , [ AC_DEFINE([OPEN_TMPFILE_FCHMOD],
+                          [1],
+                          [Workaround: _LARGE_FILE + O_TMPFILE -> mode == 0])
+                AC_MSG_NOTICE([Enabling open/tmpfile workaround using fchmod])
+              ]
+            , [ AC_DEFINE([HAVE_LINKAT],
+                          [0])
+                AC_MSG_NOTICE([Disabling linkat support])
+              ]
+            )
+    else
+        AC_MSG_RESULT([no])
+    fi
+fi
+
+dnl ---------------------------------------------------------------------------
 dnl Miscellaneous Libraries
 dnl ---------------------------------------------------------------------------
 
diff --git a/src/fs/io/FileOutputStream.cxx b/src/fs/io/FileOutputStream.cxx
index a4ef8f6..6451b8c 100644
--- a/src/fs/io/FileOutputStream.cxx
+++ b/src/fs/io/FileOutputStream.cxx
<at> <at> -106,13 +106,10 <at> <at> FileOutputStream::Cancel()
 #include <errno.h>
 
 #ifdef HAVE_LINKAT
-#ifndef O_TMPFILE
-/* supported since Linux 3.11 */
-#define __O_TMPFILE 020000000
-#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
 #include <stdio.h>
 #endif
 
+#ifdef HAVE_LINKAT
 /**
  * Open a file using Linux's O_TMPFILE for writing the given file.
  */
<at> <at> -125,8 +122,7 <at> <at> OpenTempFile(FileDescriptor &fd, Path path)
 
     return fd.Open(directory.c_str(), O_TMPFILE|O_WRONLY, 0666);
 }
-
-#endif /* HAVE_LINKAT */
+#endif
 
 FileOutputStream::FileOutputStream(Path _path, Error &error)
     :BaseFileOutputStream(_path)
diff --git a/src/system/FileDescriptor.cxx b/src/system/FileDescriptor.cxx
index db258e1..f30c9c2 100644
--- a/src/system/FileDescriptor.cxx
+++ b/src/system/FileDescriptor.cxx
<at> <at> -61,6 +61,10 <at> <at> bool
 FileDescriptor::Open(const char *pathname, int flags, mode_t mode)
 {
     fd = ::open(pathname, flags | O_NOCTTY | O_CLOEXEC, mode);
+#ifdef OPEN_TMPFILE_FCHMOD
+    if ((flags & O_TMPFILE) && IsDefined())
+        fchmod(fd, mode);
+#endif
     return IsDefined();
 }
 
diff --git a/src/system/FileDescriptor.hxx b/src/system/FileDescriptor.hxx
index 75a7684..43cb857 100644
--- a/src/system/FileDescriptor.hxx
+++ b/src/system/FileDescriptor.hxx
<at> <at> -36,11 +36,20 <at> <at>
 #include <assert.h>
 #include <unistd.h>
 #include <sys/types.h>
+#include <fcntl.h>
 
 #ifdef USE_SIGNALFD
 #include <signal.h>
 #endif
 
+#ifdef HAVE_LINKAT
+#ifndef O_TMPFILE
+/* supported since Linux 3.11 */
+#define __O_TMPFILE 020000000
+#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
+#endif
+#endif
+
 /**
  * An OO wrapper for a UNIX file descriptor.
  *
--
2.1.4


_______________________________________________
mpd-devel mailing list
mpd-devel <at> musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel
Yclept Nemo | 20 May 09:43 2015
Picon

Upstream MPD aborts on second run

/* Summary:
 *  O_TMPFILE linked with zero permissions when _FILE_OFFSET_BITS is 64
 *
 * Upstream MPD aborts on second run with the following message:
 *  errno: Failed to open ~/.mpd/database: Permission denied
 *  fatal_error: Can't open db file "~/.mpd/database" for reading/writing: Permission denied
 * The problem was introduced in the following commit:
 *  8b217d531305433df01c789dab4dc81d58f05eba
 *  fs/io/FileOutputStream: use O_TMPFILE if available
 * The problem only manifests under the following conditions:
 *  _FILE_OFFSET_BITS is set to 64 (presumably an value other than 32)
 *  open() a file with the O_TMPFILE flag and appropriate mode
 *  linkat() the file
 * The resulting linked file will have the permission bits set to 0.
 *
 * This is either related to or identical and fixed by the following bug-report (2015-02-24):
 *  https://sourceware.org/bugzilla/show_bug.cgi?id=17523
 * In any case, directly using SYS_open is a valid workaround.
 *
 * The following is a simple test-case.
 *
 * Run:
 *  bash -vc "$( sed -n 's#^ \*  \(rm .*\)$#\1#p' test.tmpfile2.cpp )"
 *
 * Command:
 *  rm -f /tmp/testfile? test.tmpfile2 && g++ test.tmpfile2.cpp -o test.tmpfile2 && ./test.tmpfile2 && ls -lah /tmp/testfile?
 *
 * System details:
 *  i686, Linux 3.19.0-16-generic, Ubuntu GLIBC 2.21-0ubuntu4, Ubuntu GCC 4.9.2-10ubuntu13
 *
 * Proposed solution:
 *  modify FileDescriptor.cxx:FileDescriptor::Open(...) to use syscall(SYS_open, ...) instead of open(...)
 *  version this to glibc <= 2.21 (__GLIBC__, __GLIBC_MINOR__ ?)
*/

#define _FILE_OFFSET_BITS 64

#include <fcntl.h>
#include <unistd.h>
#include <limits.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/syscall.h>


int main() {
    int flags = O_WRONLY;

    char path[PATH_MAX];

    // problem: false
    int fd0 = open("/tmp/testfile0", O_CREAT|flags, 0666);
    close(fd0);

    // problem: true
    int fd1 = open("/tmp", O_TMPFILE|flags, 0666);
    snprintf(path, sizeof(path), "/proc/self/fd/%d", fd1);
    linkat
        ( AT_FDCWD, path
        , AT_FDCWD, "/tmp/testfile1"
        , AT_SYMLINK_FOLLOW
        );
    close(fd1);

    // problem: false
    int fd2 = syscall
        ( SYS_open
        , "/tmp"
        , O_TMPFILE|flags
        , 0666
        );
    snprintf(path, sizeof(path), "/proc/self/fd/%d", fd2);
    linkat
        ( AT_FDCWD, path
        , AT_FDCWD, "/tmp/testfile2"
        , AT_SYMLINK_FOLLOW
        );
    close(fd2);
}

_______________________________________________
mpd-devel mailing list
mpd-devel <at> musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel

Gmane