Skip to content
Snippets Groups Projects
Commit 35b724c0 authored by Serge Petrenko's avatar Serge Petrenko Committed by Vladimir Davydov
Browse files

core: introduce cord_exit() function

cord_exit should be always called in the exiting thread. It's a single
place to call all the thread-specific module deinitalization routines.

In-scope-of #4264

NO_DOC=refactoring
NO_TEST=refactoring
NO_CHANGELOG=refactoring
parent b9fd4557
No related branches found
No related tags found
No related merge requests found
......@@ -122,6 +122,7 @@ static int
coio_on_stop(void *data)
{
(void) data;
cord_exit(cord());
cord_destroy(cord());
free(cord());
return 0;
......
......@@ -1560,6 +1560,13 @@ cord_add_garbage(struct cord *cord, struct fiber *f)
cord->garbage = f;
}
void
cord_exit(struct cord *cord)
{
assert(cord == cord());
(void)cord;
}
void
cord_destroy(struct cord *cord)
{
......@@ -1625,6 +1632,9 @@ void *cord_thread_func(void *p)
CORD_ON_EXIT_WONT_RUN);
if (!changed)
handler->callback(handler->argument);
cord_exit(cord());
return res;
}
......@@ -1874,6 +1884,7 @@ fiber_init(int (*invoke)(fiber_func f, va_list ap))
void
fiber_free(void)
{
cord_exit(&main_cord);
cord_destroy(&main_cord);
}
......
......@@ -771,6 +771,13 @@ extern __thread struct cord *cord_ptr;
void
cord_create(struct cord *cord, const char *name);
/**
* Perform all the thread-specific deinitialization. Must be called in the
* exiting thread.
*/
void
cord_exit(struct cord *cord);
void
cord_destroy(struct cord *cord);
......
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