[Tarantool-patches] [PATCH 13/13] popen: use of exception safe functions for IO

Alexander Turenko alexander.turenko at tarantool.org
Fri Apr 10 05:50:51 MSK 2020


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



More information about the Tarantool-patches mailing list