[PATCH 1/3] fiber: Move fiber_stack_destroy prior the fiber_stack_create
Cyrill Gorcunov
gorcunov at gmail.com
Wed Oct 2 21:42:04 MSK 2019
This will allow us to call it from inside fiber_stack_create
as we need to clean up resources on error.
Part-of #4541
---
src/lib/core/fiber.c | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/src/lib/core/fiber.c b/src/lib/core/fiber.c
index ce90f930c..dde556b85 100644
--- a/src/lib/core/fiber.c
+++ b/src/lib/core/fiber.c
@@ -868,6 +868,24 @@ fiber_stack_watermark_create(struct fiber *fiber)
}
#endif /* HAVE_MADV_DONTNEED */
+static void
+fiber_stack_destroy(struct fiber *fiber, struct slab_cache *slabc)
+{
+ if (fiber->stack != NULL) {
+ VALGRIND_STACK_DEREGISTER(fiber->stack_id);
+#if ENABLE_ASAN
+ ASAN_UNPOISON_MEMORY_REGION(fiber->stack, fiber->stack_size);
+#endif
+ void *guard;
+ if (stack_direction < 0)
+ guard = page_align_down(fiber->stack - page_size);
+ else
+ guard = page_align_up(fiber->stack + fiber->stack_size);
+ fiber_mprotect(guard, page_size, PROT_READ | PROT_WRITE);
+ slab_put(slabc, fiber->stack_slab);
+ }
+}
+
static int
fiber_stack_create(struct fiber *fiber, size_t stack_size)
{
@@ -913,24 +931,6 @@ fiber_stack_create(struct fiber *fiber, size_t stack_size)
return 0;
}
-static void
-fiber_stack_destroy(struct fiber *fiber, struct slab_cache *slabc)
-{
- if (fiber->stack != NULL) {
- VALGRIND_STACK_DEREGISTER(fiber->stack_id);
-#if ENABLE_ASAN
- ASAN_UNPOISON_MEMORY_REGION(fiber->stack, fiber->stack_size);
-#endif
- void *guard;
- if (stack_direction < 0)
- guard = page_align_down(fiber->stack - page_size);
- else
- guard = page_align_up(fiber->stack + fiber->stack_size);
- fiber_mprotect(guard, page_size, PROT_READ | PROT_WRITE);
- slab_put(slabc, fiber->stack_slab);
- }
-}
-
struct fiber *
fiber_new_ex(const char *name, const struct fiber_attr *fiber_attr,
fiber_func f)
--
2.20.1
More information about the Tarantool-patches
mailing list