Author: fhanik
Date: Mon May 21 02:14:08 2007
New Revision: 540077

URL: http://svn.apache.org/viewvc?view=rev&rev=540077
Log:
Only lock when incrementing the counter on sending messages, can be further 
optimized to have a lock per member

Modified:
    
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/group/interceptors/OrderInterceptor.java

Modified: 
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/group/interceptors/OrderInterceptor.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/group/interceptors/OrderInterceptor.java?view=diff&rev=540077&r1=540076&r2=540077
==============================================================================
--- 
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/group/interceptors/OrderInterceptor.java
 (original)
+++ 
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/group/interceptors/OrderInterceptor.java
 Mon May 21 02:14:08 2007
@@ -69,21 +69,29 @@
             super.sendMessage(destination, msg, payload);
             return;
         }
-        try {
-            outLock.writeLock().lock();
-            for ( int i=0; i<destination.length; i++ ) {
-                int nr = incCounter(destination[i]);
+        ChannelException cx = null;
+        for (int i=0; i<destination.length; i++ ) {
+            try {
+                int nr = 0;
+                try {
+                    outLock.writeLock().lock();
+                    nr = incCounter(destination[i]);
+                } finally {
+                    outLock.writeLock().unlock();
+                }
                 //reduce byte copy
                 msg.getMessage().append(nr);
                 try {
                     getNext().sendMessage(new Member[] {destination[i]}, msg, 
payload);
-                }finally {
+                } finally {
                     msg.getMessage().trim(4);
                 }
+            }catch ( ChannelException x ) {
+                if ( cx == null ) cx = x;
+                cx.addFaultyMember(x.getFaultyMembers());
             }
-        }finally {
-            outLock.writeLock().unlock();
-        }
+        }//for
+        if ( cx != null ) throw cx;
     }
 
     public void messageReceived(ChannelMessage msg) {



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to