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

8259943: FileDescriptor.close0 does not handle EINTR #2173

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter
Filter file types
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.

Always

Just for now

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -162,8 +162,17 @@ fileDescriptorClose(JNIEnv *env, jobject this)
dup2(devnull, fd);
close(devnull);
}
} else if (close(fd) == -1) {
JNU_ThrowIOExceptionWithLastError(env, "close failed");
} else {
int result;
#if defined(_AIX)
/* AIX allows close to be restarted after EINTR */
RESTARTABLE(close(fd), result);

This comment has been minimized.

@AlanBateman

AlanBateman Jan 21, 2021
Contributor

close is not restartable (except AIX apparently). This means you have to explicitly handle EINTR, see UnixNativeDispatcher.close0 for an example.

This comment has been minimized.

@bplb

bplb Jan 21, 2021
Author Member

I had it that way before creating the PR; will revert.

#else
result = close(fd);
#endif
if (result == -1 && errno != EINTR) {
JNU_ThrowIOExceptionWithLastError(env, "close failed");
}
}
}

@@ -234,7 +243,9 @@ jlong
handleGetLength(FD fd)
{
struct stat64 sb;
if (fstat64(fd, &sb) == 0) {
int result;
RESTARTABLE(fstat64(fd, &sb), result);
if (result == 0) {
return sb.st_size;
} else {
return -1;
ProTip! Use n and p to navigate between commits in a pull request.