OLD | NEW |
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 /* This Source Code Form is subject to the terms of the Mozilla Public | 2 /* This Source Code Form is subject to the terms of the Mozilla Public |
3 * License, v. 2.0. If a copy of the MPL was not distributed with this | 3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
5 | 5 |
6 #include "primpl.h" | 6 #include "primpl.h" |
7 #include <process.h> /* for _beginthreadex() */ | 7 #include <process.h> /* for _beginthreadex() */ |
8 | 8 |
9 #if defined(_MSC_VER) && _MSC_VER <= 1200 | 9 #if defined(_MSC_VER) && _MSC_VER <= 1200 |
10 /* | 10 /* |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 if (thread->flags & (_PR_PRIMORDIAL | _PR_ATTACHED)) { | 58 if (thread->flags & (_PR_PRIMORDIAL | _PR_ATTACHED)) { |
59 /* | 59 /* |
60 ** Warning: | 60 ** Warning: |
61 ** -------- | 61 ** -------- |
62 ** NSPR requires a real handle to every thread. | 62 ** NSPR requires a real handle to every thread. |
63 ** GetCurrentThread() returns a pseudo-handle which | 63 ** GetCurrentThread() returns a pseudo-handle which |
64 ** is not suitable for some thread operations (e.g., | 64 ** is not suitable for some thread operations (e.g., |
65 ** suspending). Therefore, get a real handle from | 65 ** suspending). Therefore, get a real handle from |
66 ** the pseudo handle via DuplicateHandle(...) | 66 ** the pseudo handle via DuplicateHandle(...) |
67 */ | 67 */ |
68 DuplicateHandle( | 68 BOOL ok = DuplicateHandle( |
69 GetCurrentProcess(), /* Process of source handle */ | 69 GetCurrentProcess(), /* Process of source handle */ |
70 GetCurrentThread(), /* Pseudo Handle to dup */ | 70 GetCurrentThread(), /* Pseudo Handle to dup */ |
71 GetCurrentProcess(), /* Process of handle */ | 71 GetCurrentProcess(), /* Process of handle */ |
72 &(thread->md.handle), /* resulting handle */ | 72 &(thread->md.handle), /* resulting handle */ |
73 0L, /* access flags */ | 73 0L, /* access flags */ |
74 FALSE, /* Inheritable */ | 74 FALSE, /* Inheritable */ |
75 DUPLICATE_SAME_ACCESS); /* Options */ | 75 DUPLICATE_SAME_ACCESS); /* Options */ |
| 76 if (!ok) { |
| 77 return PR_FAILURE; |
| 78 } |
| 79 thread->id = GetCurrentThreadId(); |
| 80 thread->md.id = thread->id; |
76 } | 81 } |
77 | 82 |
78 /* Create the blocking IO semaphore */ | 83 /* Create the blocking IO semaphore */ |
79 thread->md.blocked_sema = CreateSemaphore(NULL, 0, 1, NULL); | 84 thread->md.blocked_sema = CreateSemaphore(NULL, 0, 1, NULL); |
80 if (thread->md.blocked_sema == NULL) | 85 if (thread->md.blocked_sema == NULL) |
81 return PR_FAILURE; | 86 return PR_FAILURE; |
82 else | 87 else |
83 return PR_SUCCESS; | 88 return PR_SUCCESS; |
84 } | 89 } |
85 | 90 |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 | 433 |
429 #pragma data_seg(".CRT$XLB") | 434 #pragma data_seg(".CRT$XLB") |
430 PIMAGE_TLS_CALLBACK p_thread_callback_nspr = PR_OnThreadExit; | 435 PIMAGE_TLS_CALLBACK p_thread_callback_nspr = PR_OnThreadExit; |
431 | 436 |
432 // Reset the default section. | 437 // Reset the default section. |
433 #pragma data_seg() | 438 #pragma data_seg() |
434 | 439 |
435 #endif // _WIN64 | 440 #endif // _WIN64 |
436 | 441 |
437 #endif // NSPR_STATIC | 442 #endif // NSPR_STATIC |
OLD | NEW |