[mythtv] [patch] thread safe verbose
Eric Anderson
rico99 at sbcglobal.net
Fri Jan 14 19:05:03 EST 2005
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) \
{\
ostringstream oss; \
oss << QDateTime::currentDateTime().toString("yyyy-MM-dd
hh:mm:ss.zzz") \
<< " " << args << endl; \
pthread_mutex_lock(&MythContext::verbose_lock);\
cout << oss.str(); \
pthread_mutex_unlock(&MythContext::verbose_lock);\
}
Okay, so the 'ostringstream' is a little more overhead, but are you
really
printing that many messages where it matters?
What do you think?
-Eric
On Jan 14, 2005, at 9:23 AM, Daniel Thor Kristjansson wrote:
>
> I've been annoyed with error messages that are corrupted because two
> threads are trying to output a message at the same time. This patch
> addresses the ones that use the VERBOSE macro by adding a mutex
> to the macro so that only one thread outputs using the VERBOSE macro
> at once.
>
> The compile will take a while after you apply this, but the code will
> be much easier to debug.
>
> --
> Daniel<safe-
> verbose.patch>_______________________________________________
> mythtv-dev mailing list
> mythtv-dev at mythtv.org
> http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev
More information about the mythtv-dev
mailing list