Skip to content

Commit

Permalink
8339475: Clean up return code handling for pthread calls in library c…
Browse files Browse the repository at this point in the history
…oding

Reviewed-by: clanger, jwaters
  • Loading branch information
MBaesken committed Sep 27, 2024
1 parent 85dba47 commit 2a2ecc9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
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 @@ -297,6 +297,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 @@ -309,12 +310,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: %s\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: %s\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 @@ -741,7 +741,10 @@ SplashCreateThread(Splash * splash) {

int rslt = pthread_attr_init(&attr);
if (rslt != 0) return;
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

7 comments on commit 2a2ecc9

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MBaesken
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk23u

@openjdk
Copy link

@openjdk openjdk bot commented on 2a2ecc9 Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MBaesken Could not automatically backport 2a2ecc99 to openjdk/jdk23u due to conflicts in the following files:

  • src/java.desktop/unix/native/libsplashscreen/splashscreen_sys.c

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk23u. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk23u.git master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b backport-MBaesken-2a2ecc99-master

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk.git 2a2ecc994e02049d6d84f083b8e92a51368577bf

# Backport the commit
$ git cherry-pick --no-commit 2a2ecc994e02049d6d84f083b8e92a51368577bf
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 2a2ecc994e02049d6d84f083b8e92a51368577bf'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk23u with the title Backport 2a2ecc994e02049d6d84f083b8e92a51368577bf.

Below you can find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 2a2ecc99 from the openjdk/jdk repository.

The commit being backported was authored by Matthias Baesken on 27 Sep 2024 and was reviewed by Christoph Langer and Julian Waters.

Thanks!

@MBaesken
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk21u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 2a2ecc9 Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MBaesken Could not automatically backport 2a2ecc99 to openjdk/jdk21u-dev due to conflicts in the following files:

  • src/java.desktop/macosx/native/libsplashscreen/splashscreen_sys.m
  • src/java.desktop/unix/native/libsplashscreen/splashscreen_sys.c

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk21u-dev. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk21u-dev.git master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b backport-MBaesken-2a2ecc99-master

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk.git 2a2ecc994e02049d6d84f083b8e92a51368577bf

# Backport the commit
$ git cherry-pick --no-commit 2a2ecc994e02049d6d84f083b8e92a51368577bf
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 2a2ecc994e02049d6d84f083b8e92a51368577bf'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk21u-dev with the title Backport 2a2ecc994e02049d6d84f083b8e92a51368577bf.

Below you can find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 2a2ecc99 from the openjdk/jdk repository.

The commit being backported was authored by Matthias Baesken on 27 Sep 2024 and was reviewed by Christoph Langer and Julian Waters.

Thanks!

@MBaesken
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk21u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 2a2ecc9 Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MBaesken Could not automatically backport 2a2ecc99 to openjdk/jdk21u-dev due to conflicts in the following files:

  • src/java.desktop/unix/native/libsplashscreen/splashscreen_sys.c

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk21u-dev. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk21u-dev.git master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b backport-MBaesken-2a2ecc99-master

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk.git 2a2ecc994e02049d6d84f083b8e92a51368577bf

# Backport the commit
$ git cherry-pick --no-commit 2a2ecc994e02049d6d84f083b8e92a51368577bf
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 2a2ecc994e02049d6d84f083b8e92a51368577bf'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk21u-dev with the title Backport 2a2ecc994e02049d6d84f083b8e92a51368577bf.

Below you can find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 2a2ecc99 from the openjdk/jdk repository.

The commit being backported was authored by Matthias Baesken on 27 Sep 2024 and was reviewed by Christoph Langer and Julian Waters.

Thanks!

Please sign in to comment.