james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r1228296 - in /james/protocols/trunk: api/src/main/java/org/apache/james/protocols/api/handler/CommandDispatcher.java netty/src/main/java/org/apache/james/protocols/netty/NettyProtocolTransport.java
Date Fri, 06 Jan 2012 17:37:05 GMT
Author: norman
Date: Fri Jan  6 17:37:05 2012
New Revision: 1228296

URL: http://svn.apache.org/viewvc?rev=1228296&view=rev
Log:
Add optimization for zero-copy when possible

Modified:
    james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/handler/CommandDispatcher.java
    james/protocols/trunk/netty/src/main/java/org/apache/james/protocols/netty/NettyProtocolTransport.java

Modified: james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/handler/CommandDispatcher.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/handler/CommandDispatcher.java?rev=1228296&r1=1228295&r2=1228296&view=diff
==============================================================================
--- james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/handler/CommandDispatcher.java
(original)
+++ james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/handler/CommandDispatcher.java
Fri Jan  6 17:37:05 2012
@@ -222,10 +222,6 @@ public class CommandDispatcher<Session e
         }
         curCommandName = curCommandName.toUpperCase(Locale.US);
 
-        if (session.getLogger().isDebugEnabled()) {
-            session.getLogger().debug(getClass().getName() + " received: " + cmdString);
-        }
-
         BaseRequest request = new BaseRequest(curCommandName, curCommandArgument);
         return request;
 

Modified: james/protocols/trunk/netty/src/main/java/org/apache/james/protocols/netty/NettyProtocolTransport.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/netty/src/main/java/org/apache/james/protocols/netty/NettyProtocolTransport.java?rev=1228296&r1=1228295&r2=1228296&view=diff
==============================================================================
--- james/protocols/trunk/netty/src/main/java/org/apache/james/protocols/netty/NettyProtocolTransport.java
(original)
+++ james/protocols/trunk/netty/src/main/java/org/apache/james/protocols/netty/NettyProtocolTransport.java
Fri Jan  6 17:37:05 2012
@@ -19,17 +19,23 @@
 
 package org.apache.james.protocols.netty;
 
+import java.io.FileInputStream;
+import java.io.IOException;
 import java.io.InputStream;
 import java.net.InetSocketAddress;
+import java.nio.channels.FileChannel;
+import java.util.Iterator;
 
 import javax.net.ssl.SSLEngine;
 
 import org.apache.james.protocols.api.AbstractProtocolTransport;
+import org.apache.james.protocols.api.CombinedInputStream;
 import org.apache.james.protocols.api.ProtocolSession;
 import org.apache.james.protocols.api.handler.LineHandler;
 import org.jboss.netty.buffer.ChannelBuffers;
 import org.jboss.netty.channel.Channel;
 import org.jboss.netty.channel.ChannelFutureListener;
+import org.jboss.netty.channel.DefaultFileRegion;
 import org.jboss.netty.handler.ssl.SslHandler;
 import org.jboss.netty.handler.stream.ChunkedStream;
 
@@ -135,6 +141,39 @@ public class NettyProtocolTransport exte
         if (startTLS) {
             prepareStartTLS();
         }
+        if (!isTLSStarted()) {
+            if (in instanceof FileInputStream) {
+                FileChannel fChannel = ((FileInputStream) in).getChannel();
+                try {
+                    channel.write(new DefaultFileRegion(fChannel, 0, fChannel.size(), true));
+
+                } catch (IOException e) {
+                    // We handle this later
+                    channel.write(new ChunkedStream(in));
+                }
+                return;
+
+            } else if (in instanceof CombinedInputStream) {
+                Iterator<InputStream> streams = ((CombinedInputStream) in).iterator();
+                while(streams.hasNext()) {
+                    InputStream pIn = streams.next();
+                    if (pIn instanceof FileInputStream) {
+                        FileChannel fChannel = ((FileInputStream) in).getChannel();
+                        try {
+                            channel.write(new DefaultFileRegion(fChannel, 0, fChannel.size(),
true));
+                            return;
+
+                        } catch (IOException e) {
+                            // We handle this later
+                            channel.write(new ChunkedStream(in));
+                        }                    
+                    } else {
+                        channel.write(new ChunkedStream(in));
+                    }
+                }
+                return;
+            }
+        } 
         channel.write(new ChunkedStream(in));
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message