8317919: pthread_attr_init handle return value and destroy pthread_attr_t object
Reviewed-by: mdoerr, lucy
This commit is contained in:
parent
ff0b397e13
commit
ec310fe809
@ -769,7 +769,8 @@ bool os::create_thread(Thread* thread, ThreadType thr_type,
|
||||
|
||||
// Init thread attributes.
|
||||
pthread_attr_t attr;
|
||||
pthread_attr_init(&attr);
|
||||
int rslt = pthread_attr_init(&attr);
|
||||
guarantee(rslt == 0, "pthread_attr_init has to return 0");
|
||||
guarantee(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) == 0, "???");
|
||||
|
||||
// Make sure we run in 1:1 kernel-user-thread mode.
|
||||
@ -803,6 +804,7 @@ bool os::create_thread(Thread* thread, ThreadType thr_type,
|
||||
stack_size / K);
|
||||
thread->set_osthread(nullptr);
|
||||
delete osthread;
|
||||
pthread_attr_destroy(&attr);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -911,7 +911,12 @@ bool os::create_thread(Thread* thread, ThreadType thr_type,
|
||||
|
||||
// init thread attributes
|
||||
pthread_attr_t attr;
|
||||
pthread_attr_init(&attr);
|
||||
int rslt = pthread_attr_init(&attr);
|
||||
if (rslt != 0) {
|
||||
thread->set_osthread(nullptr);
|
||||
delete osthread;
|
||||
return false;
|
||||
}
|
||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||
|
||||
// Calculate stack size if it's not specified by caller.
|
||||
@ -960,6 +965,7 @@ bool os::create_thread(Thread* thread, ThreadType thr_type,
|
||||
stack_size / K);
|
||||
thread->set_osthread(nullptr);
|
||||
delete osthread;
|
||||
pthread_attr_destroy(&attr);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -273,8 +273,10 @@ SplashCreateThread(Splash * splash) {
|
||||
pthread_attr_t attr;
|
||||
int rc;
|
||||
|
||||
pthread_attr_init(&attr);
|
||||
int rslt = pthread_attr_init(&attr);
|
||||
if (rslt != 0) return;
|
||||
rc = pthread_create(&thr, &attr, SplashScreenThread, (void *) splash);
|
||||
pthread_attr_destroy(&attr);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -773,8 +773,10 @@ SplashCreateThread(Splash * splash) {
|
||||
pthread_attr_t attr;
|
||||
int rc;
|
||||
|
||||
pthread_attr_init(&attr);
|
||||
int rslt = pthread_attr_init(&attr);
|
||||
if (rslt != 0) return;
|
||||
rc = pthread_create(&thr, &attr, SplashScreenThread, (void *) splash);
|
||||
pthread_attr_destroy(&attr);
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user