Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8339475: Clean up return code handling for pthread calls in library coding #184

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/java.base/macosx/native/libjli/java_md_macosx.m
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ static void ParkEventLoop() {
static void MacOSXStartup(int argc, char *argv[]) {
// Thread already started?
static jboolean started = false;
int rc;
if (started) {
return;
}
Expand All @@ -345,12 +346,14 @@ static void MacOSXStartup(int argc, char *argv[]) {

// Fire up the main thread
pthread_t main_thr;
if (pthread_create(&main_thr, NULL, &apple_main, &args) != 0) {
JLI_ReportErrorMessageSys("Could not create main thread: %s\n", strerror(errno));
rc = pthread_create(&main_thr, NULL, &apple_main, &args);
if (rc != 0) {
JLI_ReportErrorMessageSys("Could not create main thread, return code: %d\n", rc);
exit(1);
}
if (pthread_detach(main_thr)) {
JLI_ReportErrorMessageSys("pthread_detach() failed: %s\n", strerror(errno));
rc = pthread_detach(main_thr);
if (rc != 0) {
JLI_ReportErrorMessage("pthread_detach() failed, return code: %d\n", rc);
exit(1);
}

Expand Down
8 changes: 1 addition & 7 deletions src/java.base/unix/native/libjli/java_md_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,7 @@ JLI_ReportErrorMessage(const char* fmt, ...) {
JNIEXPORT void JNICALL
JLI_ReportErrorMessageSys(const char* fmt, ...) {
va_list vl;
char *emsg;

/*
* TODO: its safer to use strerror_r but is not available on
* Solaris 8. Until then....
*/
emsg = strerror(errno);
char *emsg = strerror(errno);
if (emsg != NULL) {
fprintf(stderr, "%s\n", emsg);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,13 @@ static int isInAquaSession() {
SplashCreateThread(Splash * splash) {
pthread_t thr;
pthread_attr_t attr;
int rc;

int rslt = pthread_attr_init(&attr);
if (rslt != 0) return;
rc = pthread_create(&thr, &attr, SplashScreenThread, (void *) splash);
rslt = pthread_create(&thr, &attr, SplashScreenThread, (void *) splash);
if (rslt != 0) {
fprintf(stderr, "Could not create SplashScreen thread, error number:%d\n", rslt);
}
pthread_attr_destroy(&attr);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -740,11 +740,13 @@ void
SplashCreateThread(Splash * splash) {
pthread_t thr;
pthread_attr_t attr;
int rc;

int rslt = pthread_attr_init(&attr);
if (rslt != 0) return;
rc = pthread_create(&thr, &attr, SplashScreenThread, (void *) splash);
rslt = pthread_create(&thr, &attr, SplashScreenThread, (void *) splash);
if (rslt != 0) {
fprintf(stderr, "Could not create SplashScreen thread, error number:%d\n", rslt);
}
pthread_attr_destroy(&attr);
}

Expand Down