From dev-return-12460-apmail-activemq-dev-archive=activemq.apache.org@activemq.apache.org Mon Sep 08 15:50:43 2008 Return-Path: Delivered-To: apmail-activemq-dev-archive@www.apache.org Received: (qmail 89881 invoked from network); 8 Sep 2008 15:50:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 8 Sep 2008 15:50:43 -0000 Received: (qmail 9489 invoked by uid 500); 8 Sep 2008 15:50:41 -0000 Delivered-To: apmail-activemq-dev-archive@activemq.apache.org Received: (qmail 9461 invoked by uid 500); 8 Sep 2008 15:50:41 -0000 Mailing-List: contact dev-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list dev@activemq.apache.org Received: (qmail 9438 invoked by uid 99); 8 Sep 2008 15:50:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Sep 2008 08:50:40 -0700 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; Mon, 08 Sep 2008 15:49:51 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 978FE234C1C7 for ; Mon, 8 Sep 2008 08:49:52 -0700 (PDT) Message-ID: <349771725.1220888992606.JavaMail.jira@brutus> Date: Mon, 8 Sep 2008 08:49:52 -0700 (PDT) From: "Chris Fraire (JIRA)" To: dev@activemq.apache.org Subject: [jira] Created: (AMQNET-112) Threading issues -- Insufficient synchronization in Connection, Session, etc. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Threading issues -- Insufficient synchronization in Connection, Session, etc. ----------------------------------------------------------------------------- Key: AMQNET-112 URL: https://issues.apache.org/activemq/browse/AMQNET-112 Project: ActiveMQ .Net Issue Type: Bug Components: ActiveMQ Client Reporter: Chris Fraire Assignee: James Strachan Attachments: Apache.NMS.ActiveMQ.patch I have been debugging some threading issues in NMS, and I have attached a patch file with some proposed changes to correct the following issues: * Some threading issues in Connection, Session, and DispatchingThread - it is insufficient to use ArrayList.Synchronized or Hashtable.Synchronized since enumeration is not synchronized. Instead, use regular collections and explicit locking using a private object, myLock - instead of Connection.connected, use a volatile single-state-change bool called triedConnect, to add synchronization to CheckConnected without adversely-affecting performance - mark as volatile certain bools which have a single state change (e.g., Connection.closed, which starts at false and changes once to true) and then double-check for minimal locking - some uses of AtomicBoolean (e.g., Connection.started) offered insufficient code synchronization. Instead, use regular bool and locking of the aforementioned myLock - remove Connection.closing field, and instead always accommodate that Connection.RemoveSession modifies the sessions list. - instead of (bool) DispatchingThread.m_bStopFlag, use a ManualResetEvent (in addition to the existing AutoResetEvent) to signal the worker thread - in TcpTransport, recognize that ShutdownCommand may cause broker to close connection, to avoid a spurious error message - accommodate potential ThreadAbortExceptions which can occur from explicitly-aborted worker threads - increase the wait for stopping async delivery, from 5 seconds to 30 - use Interlocked.Increment for thread-safe int increments. (Interlocked.Increment wraps Int32.MaxValue to Int32.MinValue; will this be a problem?) * Tweak implementation of IDisposeable in TcpTransport, MutexTransport, TransportFilter, WireFormatNegotiator so finalizers call Dispose Thank you, Chris -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.