Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 93149 invoked from network); 28 Sep 2010 05:19:58 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 28 Sep 2010 05:19:58 -0000 Received: (qmail 11838 invoked by uid 500); 28 Sep 2010 05:19:58 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 11726 invoked by uid 500); 28 Sep 2010 05:19:55 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 11718 invoked by uid 99); 28 Sep 2010 05:19:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Sep 2010 05:19:54 +0000 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.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Sep 2010 05:19:53 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o8S5JXDk018783 for ; Tue, 28 Sep 2010 05:19:33 GMT Message-ID: <20795665.436031285651173572.JavaMail.jira@thor> Date: Tue, 28 Sep 2010 01:19:33 -0400 (EDT) From: "Regis Xu (JIRA)" To: commits@harmony.apache.org Subject: [jira] Closed: (HARMONY-6663) Time-consuming operation with lock held in ServerSocketChannelImpl.java In-Reply-To: <14139549.435751285649674171.JavaMail.jira@thor> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HARMONY-6663?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Regis Xu closed HARMONY-6663. ----------------------------- Resolution: Won't Fix > Time-consuming operation with lock held in ServerSocketChannelImpl.java > ------------------------------------------------------------------------ > > Key: HARMONY-6663 > URL: https://issues.apache.org/jira/browse/HARMONY-6663 > Project: Harmony > Issue Type: Bug > Components: Classlib > Affects Versions: 6.0M1 > Environment: Windows XP > Reporter: Wendy Feng > Original Estimate: 7h > Remaining Estimate: 7h > > I found a time-consuming operation with lock held in modules/nio/src/main/java/common/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java > public SocketChannel accept() throws IOException { > ... > synchronized (acceptLock) { > boolean isBlocking = isBlocking(); > ... > do { > try { > ((ServerSocketAdapter) socket).accept(socketGot, > (SocketChannelImpl) sockChannel); > // select successfully, break out immediately. > break; > } catch (SocketTimeoutException e) { > // continue to accept if the channel is in blocking > // mode. > } > } while (isBlocking); > } > ... > } > Thread A executes accept() method, holds a lock on "acceptLock ", but may block at socket.accept() for a long time. > Thread B executes accept(), cannot acquire the lock on "acceptLock ". > Consequence: > Lock contends, significantly downgrade software performance. > I suggest to move the do-while block out of the synchronization block as follow: > public SocketChannel accept() throws IOException { > ... > boolean isBlocking = isBlocking(); > synchronized (acceptLock) { > ... > } > do { > try { > ((ServerSocketAdapter) socket).accept(socketGot, > (SocketChannelImpl) sockChannel); > // select successfully, break out immediately. > break; > } catch (SocketTimeoutException e) { > // continue to accept if the channel is in blocking > // mode. > } > } while (isBlocking); > ... > } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.