Skip to content
Snippets Groups Projects
Commit c33af288 authored by Georgy Kirichenko's avatar Georgy Kirichenko Committed by Roman Tsisyk
Browse files

Handle coio_call spurious wakeups

coio_call() must not release stack until all work is done.
Repeat yielding until task is completed in a worker thread.

Fixes #2604
parent 54d06d7b
No related branches found
No related tags found
No related merge requests found
......@@ -274,19 +274,14 @@ coio_call(ssize_t (*func)(va_list ap), ...)
task->complete = 0;
diag_create(&task->diag);
bool cancellable = fiber_set_cancellable(false);
va_start(task->ap, func);
eio_submit(&task->base);
fiber_yield();
/* Spurious wakeup indicates a severe BUG, fail early. */
if (task->complete == 0)
panic("Wrong fiber woken");
do {
fiber_yield();
} while (task->complete == 0);
va_end(task->ap);
fiber_set_cancellable(cancellable);
ssize_t result = task->base.result;
int save_errno = errno;
if (result)
......
#include "memory.h"
#include "fiber.h"
#include "coio.h"
#include "coio_task.h"
#include "fio.h"
#include "unit.h"
#include "unit.h"
......@@ -50,6 +51,23 @@ stat_timeout_test(const char *filename)
footer();
}
static ssize_t
coio_test_wakeup(va_list ap)
{
usleep(1000);
return 0;
}
static int
test_call_f(va_list ap)
{
header();
int res = coio_call(coio_test_wakeup);
note("call done with res %i", res);
footer();
return res;
}
static int
main_f(va_list ap)
{
......@@ -59,6 +77,15 @@ main_f(va_list ap)
stat_notify_test(f, filename);
fclose(f);
(void) remove(filename);
coio_enable();
struct fiber *call_fiber = fiber_new_xc("coio_call wakeup", test_call_f);
fiber_set_joinable(call_fiber, true);
fiber_start(call_fiber);
fiber_wakeup(call_fiber);
fiber_cancel(call_fiber);
fiber_join(call_fiber);
ev_break(loop(), EVBREAK_ALL);
return 0;
}
......
......@@ -3,3 +3,6 @@
*** stat_notify_test ***
# filename: 1.out
*** stat_notify_test: done ***
*** test_call_f ***
# call done with res 0
*** test_call_f: done ***
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