File tree 2 files changed +11
-4
lines changed
2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -33,8 +33,8 @@ linux freebsd : SKYNET_LIBS += -lrt
33
33
34
34
# Turn off jemalloc and malloc hook on macosx and freebsd
35
35
36
- freebsd macosx : MALLOC_STATICLIB :=
37
- freebsd macosx : SKYNET_DEFINES :=-DNOUSE_JEMALLOC
36
+ macosx : MALLOC_STATICLIB :=
37
+ macosx : SKYNET_DEFINES :=-DNOUSE_JEMALLOC
38
38
39
39
linux macosx freebsd :
40
40
$(MAKE ) all PLAT=$@ SKYNET_LIBS=" $( SKYNET_LIBS) " SHARED=" $( SHARED) " EXPORT=" $( EXPORT) " MALLOC_STATICLIB=" $( MALLOC_STATICLIB) " SKYNET_DEFINES=" $( SKYNET_DEFINES) "
Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ struct skynet_context {
52
52
53
53
struct skynet_node {
54
54
int total ;
55
+ int init ;
55
56
uint32_t monitor_exit ;
56
57
pthread_key_t handle_key ;
57
58
};
@@ -75,8 +76,13 @@ context_dec() {
75
76
76
77
uint32_t
77
78
skynet_current_handle (void ) {
78
- void * handle = pthread_getspecific (G_NODE .handle_key );
79
- return (uint32_t )(uintptr_t )handle ;
79
+ if (G_NODE .init ) {
80
+ void * handle = pthread_getspecific (G_NODE .handle_key );
81
+ return (uint32_t )(uintptr_t )handle ;
82
+ } else {
83
+ uintptr_t v = (uint32_t )(- THREAD_MAIN );
84
+ return v ;
85
+ }
80
86
}
81
87
82
88
static void
650
656
skynet_globalinit (void ) {
651
657
G_NODE .total = 0 ;
652
658
G_NODE .monitor_exit = 0 ;
659
+ G_NODE .init = 1 ;
653
660
if (pthread_key_create (& G_NODE .handle_key , NULL )) {
654
661
fprintf (stderr , "pthread_key_create failed" );
655
662
exit (1 );
You can’t perform that action at this time.
0 commit comments