@@ -878,25 +878,24 @@ var LibraryPThread = {
878
878
err ( 'pthread_join attempted on a null thread pointer!' ) ;
879
879
return { { { cDefine ( 'ESRCH' ) } } } ;
880
880
}
881
- if ( ENVIRONMENT_IS_PTHREAD && _pthread_self ( ) == thread ) {
882
- err ( 'PThread ' + thread + ' is attempting to join to itself!' ) ;
883
- return { { { cDefine ( 'EDEADLK' ) } } } ;
884
- }
885
- else if ( ! ENVIRONMENT_IS_PTHREAD && _emscripten_main_browser_thread_id ( ) == thread ) {
886
- err ( 'Main thread ' + thread + ' is attempting to join to itself!' ) ;
887
- return { { { cDefine ( 'EDEADLK' ) } } } ;
888
- }
889
881
var self = { { { makeGetValue ( 'thread' , C_STRUCTS . pthread . self , 'i32' ) } } } ;
890
882
if ( self !== thread ) {
891
883
err ( 'pthread_join attempted on thread ' + thread + ', which does not point to a valid thread, or does not exist anymore!' ) ;
892
884
return { { { cDefine ( 'ESRCH' ) } } } ;
893
885
}
894
-
895
886
var detached = Atomics . load ( HEAPU32 , ( thread + { { { C_STRUCTS . pthread . detached } } } ) >> 2 ) ;
896
887
if ( detached ) {
897
888
err ( 'Attempted to join thread ' + thread + ', which was already detached!' ) ;
898
889
return { { { cDefine ( 'EINVAL' ) } } } ; // The thread is already detached, can no longer join it!
899
890
}
891
+ if ( ENVIRONMENT_IS_PTHREAD && _pthread_self ( ) == thread ) {
892
+ err ( 'PThread ' + thread + ' is attempting to join to itself!' ) ;
893
+ return { { { cDefine ( 'EDEADLK' ) } } } ;
894
+ }
895
+ else if ( ! ENVIRONMENT_IS_PTHREAD && _emscripten_main_browser_thread_id ( ) == thread ) {
896
+ err ( 'Main thread ' + thread + ' is attempting to join to itself!' ) ;
897
+ return { { { cDefine ( 'EDEADLK' ) } } } ;
898
+ }
900
899
901
900
#if ASSERTIONS || IN_TEST_HARNESS || ! MINIMAL_RUNTIME || ! ALLOW_BLOCKING_ON_MAIN_THREAD
902
901
if ( block ) {
0 commit comments