From: <lk...@us...> - 2005-07-20 19:12:27
|
Update of /cvsroot/openorb/TransactionService/src/main/org/openorb/ots/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14922/src/main/org/openorb/ots/Impl Modified Files: TimeOutControl.java Terminator.java Log Message: fix for bug 1240265, contributed by Chris Dodenhoff Index: TimeOutControl.java =================================================================== RCS file: /cvsroot/openorb/TransactionService/src/main/org/openorb/ots/Impl/TimeOutControl.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- TimeOutControl.java 4 Jun 2004 09:58:48 -0000 1.8 +++ TimeOutControl.java 20 Jul 2005 19:12:18 -0000 1.9 @@ -86,14 +86,49 @@ */ public void run() { - try - { - sleep( m_time_out * 1000 ); - proceed(); - } - catch ( java.lang.Exception e ) + long timeLeft = m_time_out * 1000; + long startTime = System.currentTimeMillis(); + boolean bWait = true; + + while ( bWait ) { - m_logger.error( "OTS TimeoutControl error " + e.toString(), e ); + try + { + sleep( timeLeft ); + bWait = false; + } + catch ( InterruptedException e ) + { + if ( !isTransactionComplete() ) + { + // Reduce time left to wait + long timeNow = System.currentTimeMillis(); + long timeSleeping = startTime - timeNow; + timeLeft -= timeSleeping; + if ( timeLeft <= 0 ) // timeout ! + { + bWait = false; + } + else + { + startTime = timeNow; + } + } + else + { + bWait = false; + } + } } + + proceed(); + } + + /** + * Check if the transaction is complete + */ + private boolean isTransactionComplete() + { + return ( m_transaction_state == FINISHED ); } } Index: Terminator.java =================================================================== RCS file: /cvsroot/openorb/TransactionService/src/main/org/openorb/ots/Impl/Terminator.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- Terminator.java 4 Jun 2004 10:32:17 -0000 1.16 +++ Terminator.java 20 Jul 2005 19:12:18 -0000 1.17 @@ -123,6 +123,7 @@ if ( m_time_ctrl != null ) { m_time_ctrl.finish(); + m_time_ctrl.interrupt(); } // // Commit all sub transactions @@ -264,6 +265,7 @@ if ( m_time_ctrl != null ) { m_time_ctrl.finish(); + m_time_ctrl.interrupt(); } // // Rollback all sub transactions |