From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id BB3236C7D3; Wed, 17 Feb 2021 23:16:30 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org BB3236C7D3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1613592990; bh=hZlxk4fEyvk/40ep/7WOuoWn8tCyq28CbuCzOP22ZDM=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=JoI5a9Sm2CTFbL44FMmDGwRftxoMC1dcXicIJfCBuOmnw0lEFJMJEkmprWc6gOsge YC7Kn7SG/YaMVp4Rw3Sj/ufJI7/HKq/jLSWfj+oRgTkzw2Kc/KoMksKsNIVd1+EasM X3U3avFvM3vZWAOC1IsoNAlHBO5aDRFNyFaYte68= Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 5CFD96C182 for ; Wed, 17 Feb 2021 23:15:53 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 5CFD96C182 Received: by mail-lf1-f46.google.com with SMTP id v5so23814998lft.13 for ; Wed, 17 Feb 2021 12:15:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jvqjHLVYiSiHbn9/zCq67OzrobYQqtuJZmEjEB+8sw0=; b=GcVrRXENHQeMzmMlelKRFcEvHIUlh1ui/qxYu8VEdtticSr9LLTe6Ks35rk5NraNFZ pVtQw4Td2HYu4W5GJFH6XsUiFA1rK3hI5EncAFT+O6nNw+/4wXpAk0lzWgPNgELrOXzr +SHT0qQHWpFSDZo+ol/lyUf1K8aJ5OStLbI4OyGpOdo8F4me7PiUvc6YqedjS3u8qW4A OJTDjYXVOqSCyVGlFS+B/1wiNrCYLy/l/BN1dnLkPJQaF/Z9eQzFYVKEwtgVFBGyIbXB /YtefiUpzqed+iDhXe02Ht7uN22d3tP/q+S0p430fn/LcvQ1kImgcqNFFSKPDUR5he7u YlJw== X-Gm-Message-State: AOAM531SXMBdnapPfBSU/WL0+eDWTwCXLzXCRw/Tw+zRFMNh+58x/VMT YO709efL6Jdq818kHO2vX8G6JBsL9vI= X-Google-Smtp-Source: ABdhPJwy8M3DPdAfjBUnzjmXdLqFBCEWPT6yzLMeVR6vnrfgKRcOhoNSf/e6mIxGBqyT30AkEyztbw== X-Received: by 2002:a05:6512:a8b:: with SMTP id m11mr363106lfu.112.1613592952375; Wed, 17 Feb 2021 12:15:52 -0800 (PST) Received: from grain.localdomain ([5.18.171.94]) by smtp.gmail.com with ESMTPSA id j18sm354018lfe.145.2021.02.17.12.15.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Feb 2021 12:15:51 -0800 (PST) Received: by grain.localdomain (Postfix, from userid 1000) id B25A65601F0; Wed, 17 Feb 2021 23:15:25 +0300 (MSK) To: tml Date: Wed, 17 Feb 2021 23:15:19 +0300 Message-Id: <20210217201521.436951-3-gorcunov@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210217201521.436951-1-gorcunov@gmail.com> References: <20210217123945.396396-1-gorcunov@gmail.com> <20210217201521.436951-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 2/4] box/func: update module cache in one pass X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Cyrill Gorcunov via Tarantool-patches Reply-To: Cyrill Gorcunov Cc: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" When module get reloaded we can update the cache entry directly instead of delete+add pair. Part-of #4642 Signed-off-by: Cyrill Gorcunov --- src/box/func.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/box/func.c b/src/box/func.c index 0d552652d..5757f7c25 100644 --- a/src/box/func.c +++ b/src/box/func.c @@ -159,6 +159,21 @@ module_cache_put(struct module *module) return 0; } +/** + * Update the module cache. + */ +static void +module_cache_update(struct module *module) +{ + const char *package = module->cmod->package; + size_t package_len = module->cmod->package_len; + mh_int_t i = mh_strnptr_find_inp(modules, package, package_len); + if (i == mh_end(modules)) + panic("failed to update module cache"); + mh_strnptr_node(modules, i)->str = package; + mh_strnptr_node(modules, i)->val = module; +} + /** * Delete a module from the module cache */ @@ -281,9 +296,7 @@ module_reload(const char *package, const char *package_end) func->module = new_module; rlist_move(&new_module->funcs, &func->item); } - module_cache_del(package, package_end); - if (module_cache_put(new_module) != 0) - goto restore; + module_cache_update(new_module); module_gc(old_module); return 0; restore: -- 2.29.2