diff options
author | Alexey Melnichuk <alexeymelnichuck@gmail.com> | 2017-03-21 15:48:31 +0300 |
---|---|---|
committer | Alexey Melnichuk <alexeymelnichuck@gmail.com> | 2017-03-21 15:48:31 +0300 |
commit | 2c5f337169b6377cd43e699f557f46846ccdde7b (patch) | |
tree | caf22bce2a5a2498455db53fcaef6b1315f29a4d | |
parent | db584d359b59fc70153c91697fd2328bdf3b86e9 (diff) | |
download | lua-llthreads2-2c5f337169b6377cd43e699f557f46846ccdde7b.tar.gz lua-llthreads2-2c5f337169b6377cd43e699f557f46846ccdde7b.tar.bz2 lua-llthreads2-2c5f337169b6377cd43e699f557f46846ccdde7b.zip |
Fix. Correctly handle error from `_beginthreadex` (close #12)
`_beginthread` returns -1 in case of error, but `_beginthreadex` returns 0.
https://msdn.microsoft.com/en-us/library/kdzttdcb.aspx
-rw-r--r-- | src/llthread.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/llthread.c b/src/llthread.c index eee7290..eb0c861 100644 --- a/src/llthread.c +++ b/src/llthread.c | |||
@@ -384,6 +384,9 @@ static int llthread_start(llthread_t *this, int start_detached, int joinable) { | |||
384 | 384 | ||
385 | #ifndef USE_PTHREAD | 385 | #ifndef USE_PTHREAD |
386 | this->thread = (HANDLE)_beginthreadex(NULL, 0, llthread_child_thread_run, child, 0, NULL); | 386 | this->thread = (HANDLE)_beginthreadex(NULL, 0, llthread_child_thread_run, child, 0, NULL); |
387 | if(0 == this->thread){ | ||
388 | this->thread = INVALID_THREAD; | ||
389 | } | ||
387 | if(INVALID_THREAD == this->thread){ | 390 | if(INVALID_THREAD == this->thread){ |
388 | rc = -1; | 391 | rc = -1; |
389 | } | 392 | } |