From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp3.mail.ru (smtp3.mail.ru [94.100.179.58]) (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 A22E6469710 for ; Wed, 27 May 2020 12:17:14 +0300 (MSK) Date: Wed, 27 May 2020 12:17:13 +0300 From: Kirill Yukhin Message-ID: <20200527091713.xjorn2y3mcebyc25@tarantool.org> References: <0f65635ef9ee95131ac0e83b0b70e8c204a322b8.1589968157.git.kyukhin@tarantool.org> <20200523183032.GB2714@atlas> <20200525131354.junz5joymznc6r6j@tarantool.org> <20200526151626.GI2464@grain> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200526151626.GI2464@grain> Subject: Re: [Tarantool-patches] [PATCH 1/2] Copy DSO module before load instead of symlink-ing List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cyrill Gorcunov Cc: tarantool-patches@dev.tarantool.org Hello, On 26 май 18:16, Cyrill Gorcunov wrote: > On Mon, May 25, 2020 at 04:13:54PM +0300, Kirill Yukhin wrote: > > + > > + off_t pos, left; > > + for (left = st.st_size, pos = 0; left > 0;) { > > + off_t ret = eio_sendfile_sync(dest_fd, source_fd, pos, > > + st.st_size); > > + if (ret < 0) { > > + diag_set(SystemError, "failed to copy DSO %s to %s", > > + path, load_name); > > + close(source_fd); > > + close(dest_fd); > > + goto error; > > + } > > + pos += ret; > > + left -= ret; > > + } > > + close(source_fd); > > + close(dest_fd); > > Kirill, we don't need the for() cycle here, the eio_sendfile_sync > will handle the cycle by self (inside implementation). Ah, sure, thanks! Iterative patch in the bottom. Branch force-pushed. We should probably update coio_do_copyfile() as well. This is where I've copy-and-pasted from. -- Regards, Kirill Yukhin diff --git a/src/box/func.c b/src/box/func.c index e0c45a4..a8697d3 100644 --- a/src/box/func.c +++ b/src/box/func.c @@ -308,22 +308,14 @@ module_load(const char *package, const char *package_end) goto error; } - off_t pos, left; - for (left = st.st_size, pos = 0; left > 0;) { - off_t ret = eio_sendfile_sync(dest_fd, source_fd, pos, - st.st_size); - if (ret < 0) { - diag_set(SystemError, "failed to copy DSO %s to %s", - path, load_name); - close(source_fd); - close(dest_fd); - goto error; - } - pos += ret; - left -= ret; - } + off_t ret = eio_sendfile_sync(dest_fd, source_fd, 0, st.st_size); close(source_fd); close(dest_fd); + if (ret != st.st_size) { + diag_set(SystemError, "failed to copy DSO %s to %s", + path, load_name); + goto error; + } module->handle = dlopen(load_name, RTLD_NOW | RTLD_LOCAL); if (unlink(load_name) != 0)