[mythtv] [patch] thread safe verbose

Daniel Thor Kristjansson danielk at mrl.nyu.edu
Fri Jan 14 22:17:51 EST 2005


On Fri, 14 Jan 2005, Eric Anderson wrote:

]Daniel -
]
]I've seen the same (definitely annoying) problem and I tried implementing
]something similar last week. [But I got a backend hang at some point -- I
]wasn't sure if it was related or not so I took it out.]
]I guess one question I had when I was looking at this was -- are you 100% sure
]that none of the arguments to the VERBOSE macro end up calling VERBOSE
]themselves?? Maybe that's an okay assumption, but wouldn't it be better to do
]something like this:
]if ((print_verbose_messages & mask) != 0) ....
]Okay, so the 'ostringstream' is a little more overhead, but are you really
]printing that many messages where it matters?

What about using recursive locking? i.e.
in mythcontext.cpp, replace:
  pthread_mutex_t MythContext::verbose_lock = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
with
  pthread_mutex_t MythContext::verbose_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;

I think using verbose functions in the VERBOSE macro is bad form...
But, as you suggest, it's probably better to deal with that as 
gracefully as possible.

-- Daniel



More information about the mythtv-dev mailing list