Skip to content

Commit

Permalink
Fixed deadlock when starting LiveTV through myth://
Browse files Browse the repository at this point in the history
libcmyth now uses a recursive mutex to allow the thread holding the connection lock to get passed another lock.
  • Loading branch information
David Teirney committed May 29, 2011
1 parent 85f5169 commit b2738b7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/cmyth/libcmyth/connection.c
Expand Up @@ -43,7 +43,7 @@
#include <signal.h>
#include <cmyth_local.h>

pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;

typedef struct {
int version;
Expand Down

8 comments on commit b2738b7

@Fneufneu
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i just want to warn you about PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP portability.
it does not exist on FreeBSD.

@davilla
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it also effects osx/ios.

@dteirney
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a recursive mutex on those platforms that can be used?

@dteirney
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can someone with FreeBSD / OSX check if PTHREAD_RECURSIVE_MUTEX_INITIALIZER exists. If so either I can change tonight after work or could you change directly. Presumable the _NP means non-portable?

@davilla
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see xbmc/threads/XBMC_mutex.cpp

@dteirney
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Davilla. There seems to be a spelling mistake in the first if def section in XBMC_mutex.cpp. XBCM_PTHREAD_MUTEX_RECURSIVE != XBMC_PTHREAD_MUTEX_RECURSIVE

@davilla
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha, noted

@davilla
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http://lists.apple.com/archives/unix-porting/2002/Sep/msg00079.html

neither PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP nor PTHREAD_RECURSIVE_MUTEX_INITIALIZER exists on osx and I also suspect any bsd base system.

Please sign in to comment.