[MDEV-10357] my_context_continue() does not store current fiber on Windows Created: 2016-07-11  Updated: 2016-09-30  Resolved: 2016-08-09

Status: Closed
Project: MariaDB Server
Component/s: Platform Windows
Affects Version/s: 5.5, 10.0, 10.1
Fix Version/s: 5.5.51

Type: Bug Priority: Major
Reporter: Vladislav Vaintroub Assignee: Vladislav Vaintroub
Resolution: Fixed Votes: 0
Labels: client


 Description   

This prevents context to be executed in a different thread from the one that issued
my_context_spawn, seriously limiting "async" APIs.

simple patch:

 
diff --git a/mysys/my_context.c b/mysys/my_context.c
index 5faa041..62fc05b 100644
--- a/mysys/my_context.c
+++ b/mysys/my_context.c
@@ -696,30 +696,27 @@ my_context_destroy(struct my_context *c)
 int
 my_context_spawn(struct my_context *c, void (*f)(void *), void *d)
 {
-  void *current_fiber;
   c->user_func= f;
   c->user_arg= d;
+  return my_context_continue(c);
+}
+
+int
+my_context_continue(struct my_context *c)
+{
   /*
     This seems to be a common trick to run ConvertThreadToFiber() only on the
     first occurence in a thread, in a way that works on multiple Windows
     versions.
   */
-  current_fiber= GetCurrentFiber();
+  void *current_fiber= GetCurrentFiber();
   if (current_fiber == NULL || current_fiber == (void *)0x1e00)
     current_fiber= ConvertThreadToFiber(c);
   c->app_fiber= current_fiber;
   DBUG_SWAP_CODE_STATE(&c->dbug_state);
   SwitchToFiber(c->lib_fiber);
   DBUG_SWAP_CODE_STATE(&c->dbug_state);
-  return c->return_value;
-}
 
-int
-my_context_continue(struct my_context *c)
-{
-  DBUG_SWAP_CODE_STATE(&c->dbug_state);
-  SwitchToFiber(c->lib_fiber);
-  DBUG_SWAP_CODE_STATE(&c->dbug_state);
   return c->return_value;
 }


Generated at Thu Feb 08 07:41:37 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.