Return-Path: X-Original-To: apmail-tomcat-dev-archive@www.apache.org Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 75775DD53 for ; Thu, 1 Nov 2012 12:48:16 +0000 (UTC) Received: (qmail 42058 invoked by uid 500); 1 Nov 2012 12:48:15 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 41775 invoked by uid 500); 1 Nov 2012 12:48:15 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 41740 invoked by uid 99); 1 Nov 2012 12:48:13 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Nov 2012 12:48:13 +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.115] (HELO eir.zones.apache.org) (140.211.11.115) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Nov 2012 12:48:11 +0000 Received: by eir.zones.apache.org (Postfix, from userid 80) id E5176A07B; Thu, 1 Nov 2012 12:47:49 +0000 (UTC) From: bugzilla@apache.org To: dev@tomcat.apache.org Subject: [Bug 54085] New: ssl_socket_recv sometimes loops infinitely with non-blocking sockets Date: Thu, 01 Nov 2012 12:47:47 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Tomcat Native X-Bugzilla-Component: Library X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: andrei@art.su X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: dev@tomcat.apache.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: priority bug_id assigned_to short_desc bug_severity classification op_sys reporter rep_platform bug_status version component product Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: https://issues.apache.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org https://issues.apache.org/bugzilla/show_bug.cgi?id=54085 Priority: P2 Bug ID: 54085 Assignee: dev@tomcat.apache.org Summary: ssl_socket_recv sometimes loops infinitely with non-blocking sockets Severity: normal Classification: Unclassified OS: Linux Reporter: andrei@art.su Hardware: PC Status: NEW Version: 1.1.24 Component: Library Product: Tomcat Native Java-based server using Tomcat Native sometimes falls into a busy loop consuming 100% CPU. The native stack trace of the problem: Thread 58 (Thread 1249868096 (LWP 29778)): #0 0x00007fdf3ca93e6b in __read_nocancel () from /lib64/libpthread.so.0 #1 0x00007fdf2205f092 in sock_read (b=0x7fdec7bc58a0, out=0x7fdeb0b31448, outl=3869) at /usr/include/bits/unistd.h:35 #2 0x00007fdf2205d56f in BIO_read (b=0x7fdec7bc58a0, out=0x7fdeb0b31448, outl=3869) at bio_lib.c:212 #3 0x00007fdf2234795b in ssl3_read_n (s=0x7fdec5a51340, n=6624, max=6624, extend=) at s3_pkt.c:199 #4 0x00007fdf22347efe in ssl3_read_bytes (s=0x7fdec5a51340, type=23, buf=0x7fdeb9a70000, len=4096, peek=0) at s3_pkt.c:324 #5 0x00007fdf223458c8 in ssl3_read (s=0x7fdec5a51340, buf=0x7fdeb9a70000, len=4096) at s3_lib.c:2574 #6 0x00007fdf2258c36e in ssl_socket_recv (sock=0x7fdeb9b2c8b0, buf=0x7fdeb9a70000, len=0x4a7f6a38) at src/sslnetwork.c:397 #7 0x00007fdf2258aa10 in Java_org_apache_tomcat_jni_Socket_recvbt (e=, o=, sock=140594574968408, buf=, offset=0, len=, timeout=1000) at src/network.c:972 The infinite loop appears to be in ssl_socket_recv() with the following scenario: 1. SSL_read() at line 397 returns -1; 2. apr_get_netos_error() at line 398 returns EAGAIN; 3. SSL_get_error() at line 402 returns SSL_ERROR_SSL. The socket is in O_NONBLOCK mode. SSL handshake has passed. Here is the patch that helped me to overcome the problem: *** sslnetwork.c --- sslnetwork-patched.c *************** *** 420,429 **** break; case SSL_ERROR_SYSCALL: case SSL_ERROR_SSL: ! if (!APR_STATUS_IS_EAGAIN(os) && ! !APR_STATUS_IS_EINTR(os)) { con->shutdown_type = SSL_SHUTDOWN_TYPE_UNCLEAN; ! return os == APR_SUCCESS ? APR_EGENERAL : os; } break; default: --- 420,428 ---- break; case SSL_ERROR_SYSCALL: case SSL_ERROR_SSL: ! if (!APR_STATUS_IS_EINTR(os)) { con->shutdown_type = SSL_SHUTDOWN_TYPE_UNCLEAN; ! return os == APR_SUCCESS || APR_STATUS_IS_EAGAIN(os) ? APR_EGENERAL : os; } break; default: -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org