Skip to content
This repository
Browse code

Merge pull request #107 from sdarnell/fls_fix2

Find thread local slots using v8 isolate pointer (windows fix)
  • Loading branch information...
commit b33a5934fb14ac9448ec1532f30a2fdbf38045eb 2 parents 7133679 + 03c3431
Marcel Laverdet authored

Showing 1 changed file with 9 additions and 10 deletions. Show diff stats Hide diff stats

  1. +9 10 src/coroutine.cc
19 src/coroutine.cc
@@ -34,22 +34,21 @@ size_t Coroutine::pool_size = 120;
34 34 #ifndef WINDOWS
35 35 static void* find_thread_id_key(void* arg)
36 36 #else
37   -DWORD find_thread_id_key(LPVOID arg)
  37 +static DWORD __stdcall find_thread_id_key(LPVOID arg)
38 38 #endif
39 39 {
40 40 v8::Locker locker;
  41 + v8::Isolate* isolate = v8::Isolate::GetCurrent();
  42 + assert(isolate != NULL);
  43 + floor_thread_key = 0;
41 44 for (pthread_key_t ii = coro_thread_key - 1; ii > (coro_thread_key >= 20 ? coro_thread_key - 20 : 0); --ii) {
42   - if (ceil_thread_key) {
43   - if (pthread_getspecific(ii)) {
44   - floor_thread_key = ii;
45   - } else {
46   - break;
47   - }
48   - } else if (pthread_getspecific(ii)) {
49   - ceil_thread_key = ii;
  45 + if (pthread_getspecific(ii) == isolate) {
  46 + floor_thread_key = ii;
  47 + break;
50 48 }
51 49 }
52   - assert(ceil_thread_key - floor_thread_key + 1 == v8_tls_keys);
  50 + assert(floor_thread_key != 0);
  51 + ceil_thread_key = floor_thread_key + v8_tls_keys - 1;
53 52 return NULL;
54 53 }
55 54

0 comments on commit b33a593

Please sign in to comment.
Something went wrong with that request. Please try again.