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 A85076EC5B; Mon, 12 Apr 2021 00:56:08 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A85076EC5B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1618178168; bh=Ew3jYsQ0zM+vsusLAST6+4olUi8XqibifwypqJfh+0I=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Pi47FRR/Ga7dj2qWqGzq+kM1h4y6htPQDRSWRBKhLbujhwHZIlzpMaUdoIrLgR0fI 0WqwGCUDGHiliHGtuN+VssPT6AxgR0BF8MrCNP1GGPQJsN4FRKd7+vN06LydWaPLia J8GwzcCuzIBPkaFWuDaJCW1m8rR6Fthsmtx68TGI= Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (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 074496EC5B for ; Mon, 12 Apr 2021 00:56:06 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 074496EC5B Received: by mail-lj1-f179.google.com with SMTP id l14so10073091ljb.1 for ; Sun, 11 Apr 2021 14:56:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=wBz3Hnj0k6mBnCTEQN3RDygcMnVGMUrGASTQnDTmuxE=; b=cLiIMVr98Q1QD9mU6siDC+gkihacrH+bnktlc7gIKv2/2kDc51r6Q5z1TsxnTF7SL1 T0ejZkKfPpvxCrJHWVOcZBbkBckh8b9ooWFE4yK/ngYTx4IWzbHRegD6QcC6/NDwkskl a3RmXkMv070bZKPAap2qxSTyZDAaE0ISNtq9Tqv3GiVLTLBHMXRwnQIdFtz9qycnT+Am KmCWJyLl5EGKJm/MOOeRbHIVfthdPDQx1VIBEhEM6ybOYmEfSxHtgetzNP+KpUT8AV+o 0osQpceiMSlwhBXP+2HPTFzjVe1dBm8FfmhHwkSrUv/+az3/uOrEti5FzhVA3dcYGjTi 9z0g== X-Gm-Message-State: AOAM533+MjBHU5992LJq4t/kjg91sjC/5l3ZRVL0OMVDoDCxIU4Hdy8e YRmOh1wKaqN3eLDruJynVWRFmo+4icCZyA== X-Google-Smtp-Source: ABdhPJz6Zmr1eeJI3qKj/8UYDH98J/kSuirER+W6up3gj/ax5TFdy1P2ZChJ/WFhQo2IvsKZWPuB7A== X-Received: by 2002:a2e:553:: with SMTP id 80mr8299271ljf.501.1618178165744; Sun, 11 Apr 2021 14:56:05 -0700 (PDT) Received: from grain.localdomain ([5.18.199.94]) by smtp.gmail.com with ESMTPSA id w23sm1789009lfu.132.2021.04.11.14.56.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Apr 2021 14:56:04 -0700 (PDT) Received: by grain.localdomain (Postfix, from userid 1000) id 85F20560112; Mon, 12 Apr 2021 00:56:03 +0300 (MSK) Date: Mon, 12 Apr 2021 00:56:03 +0300 To: Vladislav Shpilevoy Message-ID: References: <20210408164151.1759348-1-gorcunov@gmail.com> <20210408164151.1759348-7-gorcunov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.0.5 (2021-01-21) Subject: Re: [Tarantool-patches] [PATCH v21 6/6] test: add box.lib test 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: tml Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" On Sun, Apr 11, 2021 at 05:43:02PM +0200, Vladislav Shpilevoy wrote: > > + | --- > > + | ... > > +assert(old_module['debug_refs'] == 3) -- box.lib + 2 box.schema.func > > 1. Why +2? There is only one function loaded from that module in > box.schema.func. Since schema.func loads module implicitly: for first load it increments not only own refs but low level module as well, then one more ref comes from function creation and finally one from new box.lib interface. IOW box.schema.func.create('cfunc.cfunc_add', {language = "C"}) box.func['cfunc.cfunc_add']:call({1,2}) --> func_c_call func_c_load schema_module_load schema_do_module_load module_load module_new module_ref(m); // ref = 1 func_c_load_from module_func_load module_ref(m) // ref = 2 old_module = box.lib.load('cfunc') --> lbox_module_load module_load cache_find module_ref(m); // ref = 3 Now when we unload function from box.schema.func func_c_unload schema_module_unref schema_module_delete module_unload // ref = 2 module_func_unload module_unref // ref = 1 So it only kept by `old_module`. > > +-- The box.lib instance should carry own > > +-- references to the module and old > > +-- function. And reloading must not > > +-- affect old functions. Thus one for > > +-- box.lib and one for box.lib function. > > 2. What do you mean "one for box.lib"? Typo, one for box.schema.func and one for box.lib. > > + > > +-- Same time the reload should update > > +-- low level module cache, thus two > > +-- for box and box function plus one > > 3. The same question. What is "for box"? > What exactly keeps these references? Two entries for box.schema.func and one for box.lib. I'll extend the comments. > > > +-- new box.lib. > > +new_module = box.lib.load('cfunc') > > + | --- > > + | ... > > +assert(new_module['debug_refs'] == 3) > > + | --- > > + | - true > > + | ... > > + > > 4. In the previous review I asked you to add tests > for automatic unload via GC. Please, add them. > > You can use collectgarbage('collect') functions, > and setmetatable(..., {__mode = 'v'}) if it will > help with anything. Will try, thanks, Vlad! > > See below my review fixes and on the branch in a > separate commit. Thanks, I'll merge them and send a final diff.