Skip to content
Snippets Groups Projects
Commit 3f1db5bf authored by Nikolay Shirokovskiy's avatar Nikolay Shirokovskiy Committed by Vladimir Davydov
Browse files

coio: make coio write and read a cancellation point

It is nice to make these functions a cancellation point. Currently if we
use them in a loop and fiber is cancelled then whether the function
check for cancel or not depends on peer speed. If the latter is fast
enough we won't wait and won't check for cancel. So we will have to add
check for cancel in loop itself. Instead let's add this check to the
functions. We do not change accept and connect functions as such case is
unlikely for them.

Part of #8423

NO_TEST=rely on existing tests
NO_CHANGELOG=internal
NO_DOC=internal
parent 31079f50
No related branches found
No related tags found
No related merge requests found
......@@ -270,6 +270,10 @@ coio_read_ahead_timeout(struct iostream *io, void *buf, size_t sz,
size_t bufsiz, ev_tstamp timeout)
{
assert(sz <= bufsiz);
if (fiber_is_cancelled()) {
diag_set(FiberIsCancelled);
return -1;
}
ev_tstamp start, delay;
coio_timeout_init(&start, &delay, timeout);
ssize_t to_read = (ssize_t) sz;
......@@ -368,6 +372,10 @@ ssize_t
coio_write_timeout(struct iostream *io, const void *buf, size_t sz,
ev_tstamp timeout)
{
if (fiber_is_cancelled()) {
diag_set(FiberIsCancelled);
return -1;
}
ssize_t towrite = sz;
ev_tstamp start, delay;
coio_timeout_init(&start, &delay, timeout);
......@@ -422,6 +430,10 @@ ssize_t
coio_writev_timeout(struct iostream *io, struct iovec *iov, int iovcnt,
size_t size_hint, ev_tstamp timeout)
{
if (fiber_is_cancelled()) {
diag_set(FiberIsCancelled);
return -1;
}
size_t total = 0;
size_t iov_len = 0;
struct iovec *end = iov + iovcnt;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment