Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id B6E8D200D1A for ; Mon, 9 Oct 2017 17:26:44 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id B53611609CE; Mon, 9 Oct 2017 15:26:44 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 075F11609BB for ; Mon, 9 Oct 2017 17:26:43 +0200 (CEST) Received: (qmail 97613 invoked by uid 500); 9 Oct 2017 15:26:43 -0000 Mailing-List: contact commits-help@nifi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@nifi.apache.org Delivered-To: mailing list commits@nifi.apache.org Received: (qmail 97604 invoked by uid 99); 9 Oct 2017 15:26:43 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Oct 2017 15:26:43 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 1A9E3F5757; Mon, 9 Oct 2017 15:26:43 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jeremydyer@apache.org To: commits@nifi.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: nifi-minifi-cpp git commit: MINIFICPP-254: Resolve odd naming of isRunning variable so that it's clear we do not lock when we are running [Forced Update!] Date: Mon, 9 Oct 2017 15:26:43 +0000 (UTC) archived-at: Mon, 09 Oct 2017 15:26:44 -0000 Repository: nifi-minifi-cpp Updated Branches: refs/heads/master b4cdf964d -> 380a98bb8 (forced update) MINIFICPP-254: Resolve odd naming of isRunning variable so that it's clear we do not lock when we are running Originally identified by Fredrick Stakem. This closes #143 Signed-off-by: Jeremy Dyer Project: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/commit/380a98bb Tree: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/tree/380a98bb Diff: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/diff/380a98bb Branch: refs/heads/master Commit: 380a98bb85b185c109261b0bc3b0af878a57270e Parents: 96d1874 Author: Marc Parisi Authored: Sun Oct 8 10:43:54 2017 -0400 Committer: Jeremy Dyer Committed: Mon Oct 9 11:26:10 2017 -0400 ---------------------------------------------------------------------- libminifi/src/core/Connectable.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/380a98bb/libminifi/src/core/Connectable.cpp ---------------------------------------------------------------------- diff --git a/libminifi/src/core/Connectable.cpp b/libminifi/src/core/Connectable.cpp index cf01f0c..e2f033e 100644 --- a/libminifi/src/core/Connectable.cpp +++ b/libminifi/src/core/Connectable.cpp @@ -65,9 +65,11 @@ bool Connectable::setSupportedRelationships(std::set relatio // Whether the relationship is supported bool Connectable::isSupportedRelationship(core::Relationship relationship) { - const bool requiresLock = isRunning(); + // if we are running we do not need a lock since the function to change relationships_ ( setSupportedRelationships) + // cannot be executed while we are running + const bool isConnectableRunning = isRunning(); - const auto conditionalLock = !requiresLock ? std::unique_lock() : std::unique_lock(relationship_mutex_); + const auto conditionalLock = isConnectableRunning ? std::unique_lock() : std::unique_lock(relationship_mutex_); const auto &it = relationships_.find(relationship.getName()); if (it != relationships_.end()) { @@ -95,9 +97,11 @@ bool Connectable::setAutoTerminatedRelationships(std::set relation // Check whether the relationship is auto terminated bool Connectable::isAutoTerminated(core::Relationship relationship) { - const bool requiresLock = isRunning(); + // if we are running we do not need a lock since the function to change relationships_ ( setSupportedRelationships) + // cannot be executed while we are running + const bool isConnectableRunning = isRunning(); - const auto conditionalLock = !requiresLock ? std::unique_lock() : std::unique_lock(relationship_mutex_); + const auto conditionalLock = isConnectableRunning ? std::unique_lock() : std::unique_lock(relationship_mutex_); const auto &it = auto_terminated_relationships_.find(relationship.getName()); if (it != auto_terminated_relationships_.end()) {