Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C378CEE5D for ; Wed, 23 Jan 2013 21:22:36 +0000 (UTC) Received: (qmail 58612 invoked by uid 500); 23 Jan 2013 21:22:36 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 58547 invoked by uid 500); 23 Jan 2013 21:22:36 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 58540 invoked by uid 99); 23 Jan 2013 21:22:36 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Jan 2013 21:22:36 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Jan 2013 21:22:35 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 6DB272388980; Wed, 23 Jan 2013 21:22:16 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@commons.apache.org From: sebb@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130123212216.6DB272388980@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 type attribute can be add,u + + 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. + Util copyReader/copyStream classes should use default buffer size for non-positive buffer size parameters. 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.