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 6523593879; Mon, 18 Jan 2021 23:38:35 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6523593879 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1611002315; bh=BbHW0sZkDqzO57b+l9gFKvg4O4EiPMkkxFb1Gp3z9+M=; 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=lmsnNtuhJJy4TbIeng9dx/f+yum02K0902iJupBFusp49Ico1mjgODhlRpno6pIff bhgmC3KEajQhKumWT3trOLvG0aStd4FKdxurkUdhsLGfSl/t9Ut2JdHkTQ7pW9Lmg0 71WfmMJ5vgN6weea5WFGoDSkY42aMP3KgwYm0avg= Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (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 8EF8993879 for ; Mon, 18 Jan 2021 23:37:01 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 8EF8993879 Received: by mail-lf1-f41.google.com with SMTP id o10so25877699lfl.13 for ; Mon, 18 Jan 2021 12:37:01 -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=BhX96YypLpKNNT9JeiomhpJeq/bHZFMqW6bJFbspfS8=; b=puhVd6ZE0b+xETj/RoZjP3Bb1aRo7U+jL028yEAqJrxOJEmpKYilzoBuTZVlZq6ovI zQP5ksR4Fa3oUNzm693pMekXw7mxu3OPatzYvW8zVveygAkXdcWVND2E9ANvbNGiXmrk npw2ISL2gI9Bd+dfu/fZO8+2Z8nUQhsu7rD+TVuz0YXEAZ41vWIkmyUWI8ZDSZQqyAu8 np0tNnDSvYOSY/6iqxr5Kgzc+wazcqeBMeq0y2KJX5iBZ4L9BppMh1PTyoQnZMtxtwbk TjHEIU6kHH3rOu56hFpvi+ufRaqz28/Vq3K755w0O/YedFZKF3OMgixrPKh7uLDiq8Vx o+Qw== X-Gm-Message-State: AOAM531QU5oD0hXb30HnHJwLzUgIC0YBDb2bF/gGhq3uYa94u+w6Wyzi YRJG3XfvU9fQMMPDHhJltSrW2CiO5K4= X-Google-Smtp-Source: ABdhPJx3pzVpwg0u7t2OKe2XeGVcA/quG2Iy8pijunOaYFHeuWYpI8aFV6piPBNidZPefrj2nj1GHQ== X-Received: by 2002:a19:2c4:: with SMTP id 187mr361932lfc.391.1611002220487; Mon, 18 Jan 2021 12:37:00 -0800 (PST) Received: from grain.localdomain ([5.18.91.94]) by smtp.gmail.com with ESMTPSA id e27sm1767615ljb.6.2021.01.18.12.36.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jan 2021 12:36:59 -0800 (PST) Received: by grain.localdomain (Postfix, from userid 1000) id 68ABA56017B; Mon, 18 Jan 2021 23:35:59 +0300 (MSK) To: tml Date: Mon, 18 Jan 2021 23:35:53 +0300 Message-Id: <20210118203556.281700-6-gorcunov@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118203556.281700-1-gorcunov@gmail.com> References: <20210118203556.281700-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v12 5/8] module_cache: rename calls to ref in module structure 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" We will use this field not only to count a number of active calls to the module but to prevent the module from disappear when it get loaded via "cmod" interface (will be implemented in next patches). Same time make it 64 bit long since there might be a number of such references size_t didn't prevent from numeric overflow. Part-of #4642 Signed-off-by: Cyrill Gorcunov --- src/box/module_cache.c | 8 ++++---- src/box/module_cache.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/box/module_cache.c b/src/box/module_cache.c index 48e55f421..ae874caab 100644 --- a/src/box/module_cache.c +++ b/src/box/module_cache.c @@ -214,7 +214,7 @@ module_load(const char *package, const char *package_end) memcpy(module->package, package, package_len); module->package[package_len] = 0; rlist_create(&module->funcs_list); - module->calls = 0; + module->ref = 0; const char *tmpdir = getenv("TMPDIR"); if (tmpdir == NULL) @@ -312,7 +312,7 @@ module_delete(struct module *module) static void module_gc(struct module *module) { - if (rlist_empty(&module->funcs_list) && module->calls == 0) + if (rlist_empty(&module->funcs_list) && module->ref == 0) module_delete(module); } @@ -404,9 +404,9 @@ module_sym_call(struct module_sym *mod_sym, struct port *args, */ struct module *module = mod_sym->module; assert(module != NULL); - ++module->calls; + ++module->ref; int rc = mod_sym->addr(&ctx, data, data + data_sz); - --module->calls; + --module->ref; module_gc(module); region_truncate(region, region_svp); diff --git a/src/box/module_cache.h b/src/box/module_cache.h index fd789f603..feb1f2266 100644 --- a/src/box/module_cache.h +++ b/src/box/module_cache.h @@ -41,9 +41,9 @@ struct module { */ struct rlist funcs_list; /** - * Count of active calls. + * Count of active references to the module. */ - size_t calls; + int64_t ref; /** * Module's package name. */ -- 2.29.2