You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Michael Bachran <mb...@voiceobjects.com> on 2003/02/11 10:41:33 UTC
Logkit: Possible 'deadlock' in AsyncLogTarget ...
Hi,
Sorry for disturbing the release process of LogKit :-).
But there is a possible 'deadlock' in doProcessEvent() of AsyncLogTarget.
When waiting in case of a full queue ...
(AsynLogTarget:131)
final int size = m_list.size();
while( m_queueSize <= size )
{
try
{
m_list.wait();
}
catch( final InterruptedException ie )
{
//This really should not occur ...
//Maybe we should log it though for
//now lets ignore it
}
}
... we do not recalculate the size. Therefore any thread waiting for the queue to get a free slot
will not recognize when an element is removed.
This means all threads of a system that are logging to that target might block here forever
(if the consumer is to slow or the queue to small).
I would recommend to patch like this:
- final int size = m_list.size();
+ int size = m_list.size();
while( m_queueSize <= size )
{
try
{
m_list.wait();
}
catch( final InterruptedException ie )
{
//This really should not occur ...
//Maybe we should log it though for
//now lets ignore it
}
+ size = m_list.size();
}
(... or use the size() function directly for comparison).
Additionally I got an issue when restarting my system (including complete reestablishment of the log-system without closing the JVM)
because the AsyncTargets are not closing the targets they are wrapping and when restarting opening a stream to
an underlying file-target will not get the required write-access.
I somehow hacked it like this (close() cannot be called from the interface LogTarget):
(AsynLogTarget:192)
else if( interupted || Thread.interrupted() )
{
//ie there is nothing in queue and thread is interrupted
//thus we stop thread
+ try
+ {
+ if ( m_logTarget instanceof AbstractTarget )
+ {
+ ((AbstractTarget)m_logTarget).close();
+ }
+ }
+ catch( final Throwable throwable )
+ {
+ getErrorHandler().error( "Unknown error closing target.", throwable, event );
+ }
return;
}
Michael
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org
RE: Logkit: Possible 'deadlock' in AsyncLogTarget ...
Posted by Leo Sutic <le...@inspireinfrastructure.com>.
> From: Michael Bachran [mailto:mbachran@voiceobjects.com]
>
> Hi,
>
> Sorry for disturbing the release process of LogKit :-).
Don't worry, we'll get this patch into 1.2.1.
/LS
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org