fix segfault in debug mode (#2794)

This commit is contained in:
shizhe 2020-01-18 01:37:06 +08:00 committed by coolsnowwolf
parent 5537db1a88
commit a6fb452315

View File

@ -0,0 +1,37 @@
--- a/src/main.c
+++ b/src/main.c
@@ -219,6 +219,16 @@ static int check_ipv6()
*/
int main(int argc,char *argv[])
{
+#if DEBUG>0
+ {
+ int err;
+ /* Generate a key for storing our thread id's */
+ if ((err=pthread_key_create(&thrid_key, NULL)) != 0) {
+ log_error("pthread_key_create failed: %s",strerror(err));
+ _exit(1);
+ }
+ }
+#endif
int i,sig,pfd=-1; /* Initialized to inhibit compiler warning */
main_thrid=pthread_self();
@@ -626,17 +636,6 @@ int main(int argc,char *argv[])
pthread_sigmask(SIG_BLOCK,&sigs_msk,NULL);
#endif
-#if DEBUG>0
- {
- int err;
- /* Generate a key for storing our thread id's */
- if ((err=pthread_key_create(&thrid_key, NULL)) != 0) {
- log_error("pthread_key_create failed: %s",strerror(err));
- _exit(1);
- }
- }
-#endif
-
{
#if DEBUG>0
int thrdsucc=1;