commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1437740 - in /commons/proper/net/trunk/src: changes/changes.xml main/java/org/apache/commons/net/ftp/FTPClient.java
Date Wed, 23 Jan 2013 21:22:16 GMT
Author: sebb
Date: Wed Jan 23 21:22:15 2013
New Revision: 1437740

URL: http://svn.apache.org/viewvc?rev=1437740&view=rev
Log:
NET-465 FTPClient setSendBufferSize and setReceiveBufferSize on data socket
Reworked the original fix.

Modified:
    commons/proper/net/trunk/src/changes/changes.xml
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java

Modified: commons/proper/net/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/changes/changes.xml?rev=1437740&r1=1437739&r2=1437740&view=diff
==============================================================================
--- commons/proper/net/trunk/src/changes/changes.xml (original)
+++ commons/proper/net/trunk/src/changes/changes.xml Wed Jan 23 21:22:15 2013
@@ -64,6 +64,11 @@ The <action> type attribute can be add,u
     <body>
         <release version="3.3" date="TBA" description="
         ">
+            <action issue="NET-465" dev="sebb" type="fix">
+            FTPClient setSendBufferSize and setReceiveBufferSize on data socket.
+            The previous fix caused performance problems.
+            Added new getters and setters for the SO_SNDBUF and SO_RCVBUF values to be used
on the data socket.
+            </action>
             <action issue="NET-496" dev="sebb" type="add">
             Util copyReader/copyStream classes should use default buffer size for non-positive
buffer size parameters.
             </action>

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java?rev=1437740&r1=1437739&r2=1437740&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java (original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java Wed Jan
23 21:22:15 2013
@@ -361,7 +361,9 @@ implements Configurable
     private boolean __remoteVerificationEnabled;
     private long __restartOffset;
     private FTPFileEntryParserFactory __parserFactory;
-    private int __bufferSize;
+    private int __bufferSize; // buffersize for buffered data streams
+    private int __sendDataSocketBufferSize;
+    private int __receiveDataSocketBufferSize;
     private boolean __listHiddenFiles;
     private boolean __useEPSVwithIPv4; // whether to attempt EPSV with an IPv4 connection
 
@@ -478,7 +480,7 @@ implements Configurable
         __systemName         = null;
         __entryParser        = null;
         __entryParserKey    = "";
-        __bufferSize         = Util.DEFAULT_COPY_BUFFER_SIZE;
+        __bufferSize         = 0;
         __featuresMap = null;
     }
 
@@ -826,6 +828,12 @@ implements Configurable
                 if (__dataTimeout >= 0) {
                     socket.setSoTimeout(__dataTimeout);
                 }
+                if (__receiveDataSocketBufferSize > 0) {
+                    socket.setReceiveBufferSize(__receiveDataSocketBufferSize);
+                }
+                if (__sendDataSocketBufferSize > 0) {
+                    socket.setSendBufferSize(__sendDataSocketBufferSize);
+                }
             } finally {
                 server.close();
             }
@@ -858,6 +866,12 @@ implements Configurable
             }
 
             socket = _socketFactory_.createSocket();
+            if (__receiveDataSocketBufferSize > 0) {
+                socket.setReceiveBufferSize(__receiveDataSocketBufferSize);
+            }
+            if (__sendDataSocketBufferSize > 0) {
+                socket.setSendBufferSize(__sendDataSocketBufferSize);
+            }
             if (__passiveLocalHost != null) {
                 socket.bind(new InetSocketAddress(__passiveLocalHost, 0));
             }
@@ -893,11 +907,6 @@ implements Configurable
                     " is not same as server " + getRemoteAddress().getHostAddress());
         }
 
-        if ( __bufferSize > 0 ) {
-            socket.setReceiveBufferSize(__bufferSize);
-            socket.setSendBufferSize(__bufferSize);
-        }
-
         return socket;
     }
 
@@ -3435,6 +3444,42 @@ implements Configurable
     }
 
     /**
+     * Sets the value to be used for the data socket SO_SNDBUF option.
+     * If the value is positive, the option will be set when the data socket has been created.
+     *
+     * @param bufSize The size of the buffer, zero or negative means the value is ignored.
+     */
+    public void setSendDataSocketBufferSize(int bufSize) {
+        __sendDataSocketBufferSize = bufSize;
+    }
+
+    /**
+     * Retrieve the value to be used for the data socket SO_SNDBUF option.
+     * @return The current buffer size.
+     */
+    public int getSendDataSocketBufferSize() {
+        return __sendDataSocketBufferSize;
+    }
+
+    /**
+     * Sets the value to be used for the data socket SO_RCVBUF option.
+     * If the value is positive, the option will be set when the data socket has been created.
+     *
+     * @param bufSize The size of the buffer, zero or negative means the value is ignored.
+     */
+    public void setReceieveDataSocketBufferSize(int bufSize) {
+        __receiveDataSocketBufferSize = bufSize;
+    }
+
+    /**
+     * Retrieve the value to be used for the data socket SO_RCVBUF option.
+     * @return The current buffer size.
+     */
+    public int getReceiveDataSocketBufferSize() {
+        return __receiveDataSocketBufferSize;
+    }
+
+    /**
      * Implementation of the {@link Configurable Configurable} interface.
      * In the case of this class, configuring merely makes the config object available for
the
      * factory methods that construct parsers.



Mime
View raw message