From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp49.i.mail.ru (smtp49.i.mail.ru [94.100.177.109]) (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 23F3E4696CF for ; Fri, 10 Apr 2020 05:51:30 +0300 (MSK) From: Alexander Turenko Date: Fri, 10 Apr 2020 05:50:51 +0300 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 13/13] popen: use of exception safe functions for IO List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cyrill Gorcunov Cc: tarantool-patches@dev.tarantool.org popen read / write functions provides are written in C and intended to be used from C: the contract is to return -1 at failure and set an entry to the diagnostics area. However a C++ exception from coio read / write functions would pass over a popen function stack frame. The solution is to use the recently introduced coio exception safe functions. Part of #4031 --- src/lib/core/popen.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib/core/popen.c b/src/lib/core/popen.c index bf7d597bd..d39d8640a 100644 --- a/src/lib/core/popen.c +++ b/src/lib/core/popen.c @@ -321,8 +321,10 @@ popen_write_timeout(struct popen_handle *handle, const void *buf, handle->pid, stdX_str(idx), idx, buf, count, handle->ios[idx].fd, timeout); - return coio_write_timeout(&handle->ios[idx], buf, - count, timeout); + int rc = coio_write_timeout_noxc(&handle->ios[idx], buf, count, + timeout); + assert(rc < 0 || rc == (ssize_t)count); + return rc; } /** @@ -383,8 +385,8 @@ popen_read_timeout(struct popen_handle *handle, void *buf, handle->pid, stdX_str(idx), idx, buf, count, handle->ios[idx].fd, timeout); - return coio_read_ahead_timeout(&handle->ios[idx], buf, 1, count, - timeout); + return coio_read_ahead_timeout_noxc(&handle->ios[idx], buf, 1, count, + timeout); } /** -- 2.25.0