Skip to content

Commit

Permalink
Fix terrible bug in thread trampoline
Browse files Browse the repository at this point in the history
New threads created while the coroutine library is loaded have a pretty
good chance of getting corrupted it seems. eio threading hasn't been
put through too much scrutiny unfortunately, so I didn't catch this
until now.
  • Loading branch information
laverdet committed Feb 18, 2011
1 parent ac01c73 commit ab87395
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{ {
"name": "fibers", "name": "fibers",
"version": "0.1.4", "version": "0.1.5",
"description": "Cooperative multi-tasking for Javascript; or, the closest thing to a thread you'll see in node", "description": "Cooperative multi-tasking for Javascript; or, the closest thing to a thread you'll see in node",
"keywords": ["fiber", "fibers", "coroutine", "thread", "async", "parallel", "worker"], "keywords": ["fiber", "fibers", "coroutine", "thread", "async", "parallel", "worker"],
"homepage": "https://github.com/laverdet/node-fibers", "homepage": "https://github.com/laverdet/node-fibers",
Expand Down
3 changes: 1 addition & 2 deletions src/coroutine.cc
Expand Up @@ -323,9 +323,8 @@ int pthread_key_create(pthread_key_t* key, pthread_dtor_t dtor) {
void thread_trampoline(void** args_vector) { void thread_trampoline(void** args_vector) {
void* (*entry)(void*) = (void*(*)(void*))args_vector[0]; void* (*entry)(void*) = (void*(*)(void*))args_vector[0];
void* arg = args_vector[1]; void* arg = args_vector[1];
Thread& thread = *static_cast<Thread*>(args_vector[1]); Thread& thread = *static_cast<Thread*>(args_vector[2]);
delete[] args_vector; delete[] args_vector;
thread.handle = o_pthread_self();
o_pthread_setspecific(thread_key, &thread); o_pthread_setspecific(thread_key, &thread);
entry(arg); entry(arg);
} }
Expand Down

0 comments on commit ab87395

Please sign in to comment.