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 0C32E7F601; Sun, 7 Feb 2021 21:13:43 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 0C32E7F601 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1612721623; bh=sbCSofmLSxm9c3L3gfvfjyNlReuJQDr23prKJat3gVE=; h=To:Cc:References:Date:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=Fq/3zjFoXmrOve7h3u7tc5DMAHprI4xDwF6dVFdjgP4YHRG2Xf/NpS+ZTxyzQc8ca mGuZp/Q36PF9qbqJxU5W6Jnn1vjo05eqF1WXp70z0JVrU+QJwiNM8jle399NTHkBSD BtfR2nZADtlPomp098KABxl+7zbVmi1J5SzAYKKo= Received: from smtp30.i.mail.ru (smtp30.i.mail.ru [94.100.177.90]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id EC1197030B for ; Sun, 7 Feb 2021 20:20:37 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org EC1197030B Received: by smtp30.i.mail.ru with esmtpa (envelope-from ) id 1l8njf-0007ua-OX; Sun, 07 Feb 2021 20:20:36 +0300 To: Cyrill Gorcunov , tml Cc: Mons Anderson References: <20210205185436.638894-1-gorcunov@gmail.com> <20210205185436.638894-8-gorcunov@gmail.com> Message-ID: Date: Sun, 7 Feb 2021 18:20:34 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210205185436.638894-8-gorcunov@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD953AC099BC0052A9CAEF2BF42A2A7729330F8028A4C0D8125182A05F5380850400AD1D6119AA85F64724A55A01EF1C6E67D018A2FBFF97AB35E755154D1E17406 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7CA8E915ACC910FBDEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637DEEC83A7CF8598608638F802B75D45FF5571747095F342E8C7A0BC55FA0FE5FCA1425B1BFD02B95D9232A84F5FA4DFEF92F14305C0317C24389733CBF5DBD5E913377AFFFEAFD269A417C69337E82CC2CC7F00164DA146DAFE8445B8C89999729449624AB7ADAF37F6B57BC7E64490611E7FA7ABCAF51C92176DF2183F8FC7C0A29E2F051442AF778941B15DA834481F9449624AB7ADAF37BA3038C0950A5D3613377AFFFEAFD2691661749BA6B97735F4A3654BDD83CEEB7B076A6E789B0E97A8DF7F3B2552694A1E7802607F20496D49FD398EE364050FC65AC60A1F0286FECEDA8D6C8C3B0531B3661434B16C20AC78D18283394535A975ECD9A6C639B01BC09775C1D3CA48CF82C525EC1B8D9DED35872C767BF85DA22EF20D2F80756B5F40A5AABA2AD3711975ECD9A6C639B01B78DA827A17800CE72958EBC9E2F10130731C566533BA786A40A5AABA2AD371193C9F3DD0FB1AF5EB39B26F9A09A85A293C9F3DD0FB1AF5EB4E70A05D1297E1BBCB5012B2E24CD356 X-C1DE0DAB: 0D63561A33F958A5491F7F3D87843CDA348EEEA5CEC434388EF13632CE3B5DEED59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75448CF9D3A7B2C848410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D344FDECC3B9E4D57D48580AB8E7E784302FFE376BFA229517844A8FCBED470B38B1C9D6E54F4CA628C1D7E09C32AA3244C2DC11DC92CD4D46D7A73EC64FCF6544830452B15D76AEC14FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojMxr0zTsJFiSpYXnPF6YY1A== X-Mailru-Sender: 504CC1E875BF3E7D9BC0E5172ADA3110E20A360582E3622A496AF13A91C46206AC1792E89F09F0F807784C02288277CA03E0582D3806FB6A5317862B1921BA260ED6CFD6382C13A6112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v15 07/11] module_cache: use references as a main usage counter 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: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Thanks for the patch! See 2 comments below. > + > +/** > + * Decrease module reference and delete it if last one. > + */ > +static void > +module_unref(struct module *module) > +{ > + assert(module->refs > 0); > + if (module->refs-- == 1) { > + if (!module_is_orphan(module)) { > + size_t len = strlen(module->package); > + module_cache_del(module->package, > + &module->package[len]); 1. You can also compare pointer in the hash. If it matches - delete it. Then you wouldn't need the orphan concept at all. > + } > + module_delete(module); > + } > +} > @@ -511,10 +541,15 @@ module_reload(const char *package, const char *package_end) > panic("module: can't update module cache (%s)", package); > } > > - module_gc(old); > + module_set_orphan(old); > + module_unref(old); > + > + /* From explicit load above */ > + module_unref(new); 2. Where is the explicit ref?