Return-Path: Delivered-To: apmail-mina-dev-archive@www.apache.org Received: (qmail 76711 invoked from network); 15 Feb 2011 03:12:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 15 Feb 2011 03:12:24 -0000 Received: (qmail 52899 invoked by uid 500); 15 Feb 2011 03:12:24 -0000 Delivered-To: apmail-mina-dev-archive@mina.apache.org Received: (qmail 52709 invoked by uid 500); 15 Feb 2011 03:12:22 -0000 Mailing-List: contact dev-help@mina.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@mina.apache.org Delivered-To: mailing list dev@mina.apache.org Received: (qmail 52701 invoked by uid 99); 15 Feb 2011 03:12:22 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Feb 2011 03:12:22 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Feb 2011 03:12:20 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 1D89F1A5B33 for ; Tue, 15 Feb 2011 03:11:59 +0000 (UTC) Date: Tue, 15 Feb 2011 03:11:59 +0000 (UTC) From: "John R. Fallows (JIRA)" To: dev@mina.apache.org Message-ID: <1618384214.16610.1297739519117.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <1759675994.16590.1297739037445.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] Updated: (DIRMINA-819) Synchronous behavior while adding and removing connections MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/DIRMINA-819?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] John R. Fallows updated DIRMINA-819: ------------------------------------ Attachment: sync.patch > Synchronous behavior while adding and removing connections > ---------------------------------------------------------- > > Key: DIRMINA-819 > URL: https://issues.apache.org/jira/browse/DIRMINA-819 > Project: MINA > Issue Type: Bug > Affects Versions: 2.0.0-RC1, 2.0.0, 2.0.1, 2.0.2 > Environment: java version "1.6.0_22" > Java(TM) SE Runtime Environment (build 1.6.0_22-b04) > Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03, mixed mode) > Reporter: John R. Fallows > Attachments: sync.patch > > > We discovered some blocking behavior in the Mina AbstractPollingIoProcessor that is triggered while adding and removing connections. > This class manages an internal worker that must be started when the first connection is added, and stopped when the last connection is removed. > The code achieves this by using a synchronized block in startupProcessor() as follows: > public final void remove(T session) { > scheduleRemove(session); > startupProcessor(); > } > private void scheduleRemove(T session) { > removingSessions.add(session); > } > private void startupProcessor() { > synchronized (lock) { > if (processor == null) { > processor = new Processor(); > executor.execute(new NamePreservingRunnable(processor, > threadName)); > } > } > // Just stop the select() and start it again, so that the processor > // can be activated immediately. > wakeup(); > } > Each call to session.close() triggers the "filterClose" event on the filter chain, ending in a call to removeSession (shown above) where the synchronized lock is obtained to verify that the processor is running in order to close the connection. When a large number of connections are closed at the same time, they will contend for the synchronized lock. Similar behavior occurs when new connections are established via addSession (not shown here). Both removeSession and addSession synchronize on the same lock, so they also contend with each other as connections come and go. > Note that we found similar behavior in AbstractPollingIoAcceptor and AbstractPollingIoConnector as well. -- This message is automatically generated by JIRA. - For more information on JIRA, see: http://www.atlassian.com/software/jira