From 11cea17496c190969c758153034c94622211dce9 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 6 Jan 2015 12:04:15 +0100 Subject: thread/Name: indent preprocessor commands --- src/thread/Name.hxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/thread/Name.hxx b/src/thread/Name.hxx index 284d1e147..0edcc0242 100644 --- a/src/thread/Name.hxx +++ b/src/thread/Name.hxx @@ -21,10 +21,10 @@ #define MPD_THREAD_NAME_HXX #ifdef HAVE_PTHREAD_SETNAME_NP -#include -#include +# include +# include #elif defined(HAVE_PRCTL) -#include +# include #endif static inline void -- cgit v1.2.3 From b9ed850b98ff793b43482cc501505f873335bdb1 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 6 Jan 2015 12:04:02 +0100 Subject: thread/Name: enable FormatThreadName() with prctl() Add macro HAVE_THREAD_NAME which is set when any method to set the thread name is available. Use that macro in FormatThreadName() instead of just checking for HAVE_PTHREAD_SETNAME_NP. --- src/thread/Name.hxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/thread/Name.hxx b/src/thread/Name.hxx index 0edcc0242..872702af2 100644 --- a/src/thread/Name.hxx +++ b/src/thread/Name.hxx @@ -21,10 +21,14 @@ #define MPD_THREAD_NAME_HXX #ifdef HAVE_PTHREAD_SETNAME_NP +# define HAVE_THREAD_NAME # include # include #elif defined(HAVE_PRCTL) # include +# ifdef PR_SET_NAME +# define HAVE_THREAD_NAME +# endif #endif static inline void @@ -47,7 +51,7 @@ template static inline void FormatThreadName(const char *fmt, gcc_unused Args&&... args) { -#ifdef HAVE_PTHREAD_SETNAME_NP +#ifdef HAVE_THREAD_NAME char buffer[16]; snprintf(buffer, sizeof(buffer), fmt, args...); SetThreadName(buffer); -- cgit v1.2.3 From 4bd2c75056271e687e26c4d8038bdefaa7c88dc9 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 6 Jan 2015 12:08:36 +0100 Subject: thread/Name: disable pthread_setname_np() on NetBSD NetBSD's pthread_setname_np() prototype is incompatible with the rest of the world, and it requires to pass the string argument as a non-const pointer. Instead of working around this misdesign, I hereby disable the feature on NetBSD. --- src/thread/Name.hxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/thread/Name.hxx b/src/thread/Name.hxx index 872702af2..0fbad0fd2 100644 --- a/src/thread/Name.hxx +++ b/src/thread/Name.hxx @@ -20,7 +20,7 @@ #ifndef MPD_THREAD_NAME_HXX #define MPD_THREAD_NAME_HXX -#ifdef HAVE_PTHREAD_SETNAME_NP +#if defined(HAVE_PTHREAD_SETNAME_NP) && !defined(__NetBSD__) # define HAVE_THREAD_NAME # include # include @@ -34,7 +34,11 @@ static inline void SetThreadName(const char *name) { -#ifdef HAVE_PTHREAD_SETNAME_NP +#if defined(HAVE_PTHREAD_SETNAME_NP) && !defined(__NetBSD__) + /* not using pthread_setname_np() on NetBSD because it + requires a non-const pointer argument, which we don't have + here */ + #ifdef __APPLE__ pthread_setname_np(name); #else -- cgit v1.2.3 From 37e9010887783c307355f3144786ed72e8a973b0 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 6 Jan 2015 12:46:28 +0100 Subject: input/async: reset the "open" flag after seeking successfully Fixes a problem with the "curl" input plugin: IsEOF() always returns true because the "open" flag was cleared by CurlInputStream::RequestDone() when end-of-stream was reached. This flag stays false even when seeking to another position has succeeded. This patch resets the "open" flag to true after seeking successfully. --- src/input/AsyncInputStream.cxx | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/input/AsyncInputStream.cxx b/src/input/AsyncInputStream.cxx index c8e3fcfd5..5795ecead 100644 --- a/src/input/AsyncInputStream.cxx +++ b/src/input/AsyncInputStream.cxx @@ -160,6 +160,11 @@ AsyncInputStream::SeekDone() assert(io_thread_inside()); assert(IsSeekPending()); + /* we may have reached end-of-file previously, and the + connection may have been closed already; however after + seeking successfully, the connection must be alive again */ + open = true; + seek_state = SeekState::NONE; cond.broadcast(); } -- cgit v1.2.3