Return-Path: Delivered-To: apmail-commons-issues-archive@locus.apache.org Received: (qmail 81150 invoked from network); 5 Mar 2008 01:22:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Mar 2008 01:22:55 -0000 Received: (qmail 17171 invoked by uid 500); 5 Mar 2008 01:22:50 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 17102 invoked by uid 500); 5 Mar 2008 01:22:49 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 17093 invoked by uid 99); 5 Mar 2008 01:22:49 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Mar 2008 17:22:49 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Mar 2008 01:22:10 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id E756D234C08A for ; Tue, 4 Mar 2008 17:21:40 -0800 (PST) Message-ID: <1031197704.1204680100946.JavaMail.jira@brutus> Date: Tue, 4 Mar 2008 17:21:40 -0800 (PST) From: "Martin Oberhuber (JIRA)" To: issues@commons.apache.org Subject: [jira] Commented: (NET-73) [net][PATCH] TelnetInputStream.read hangs when socket data ends in a command sequence MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/NET-73?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12575215#action_12575215 ] Martin Oberhuber commented on NET-73: ------------------------------------- Darn, it seems to be missing on the NET_2_0 branch indeed... and this has been detected before, see NET-179 : https://issues.apache.org/jira/browse/NET-179 Looks like that one needs to get re-opened? > [net][PATCH] TelnetInputStream.read hangs when socket data ends in a command sequence > ------------------------------------------------------------------------------------- > > Key: NET-73 > URL: https://issues.apache.org/jira/browse/NET-73 > Project: Commons Net > Issue Type: Bug > Environment: Operating System: other > Platform: All > Reporter: Rob Hasselbaum > Attachments: cmd-seq-hang.patch > > > Background: If one calls TelnetInputStream.read() in single-threaded mode (no > reader thread) and there is no data immediately available, the call blocks on > a socket read. When data starts to arrive, the stream adds all the available > bytes to its internal queue before returning the first one to the caller. To > do this, it calls __read() in a loop for as long as there are bytes available. > The __read() method returns the first byte of "user data" from the socket. If > __read() encounters a Telnet command sequence (IAC, WILL, WONT, DO, DONT, > etc.), it handles the negotiation transparently and then returns the first > byte of user data. > In most cases, this works fine, but a problem arises if a chunk of data from > the remote host ends in a Telnet command sequence. When that happens, the > TelnetInputStream.read() method hangs, even though it may have already > acquired some user data. This is because it calls __read() in a loop as long > as super.available() returns true. But if the remaining data from the socket > consists entirely of Telnet commands, __read() will process those AND THEN > BLOCK waiting for user data. > Just checking super.available() is not sufficient. We should continue the loop > only if there are bytes of USER DATA still available from the socket. Not > doing this can cause the client to wait indefinitely. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.