-
-
Notifications
You must be signed in to change notification settings - Fork 39
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
Don't leak temporary file during test and inital loading of lib. #141
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -296,8 +296,12 @@ static jobjectArray netty_io_uring_setup(JNIEnv *env, jclass clazz, jint entries | |
return array; | ||
} | ||
|
||
static jint netty_create_file(JNIEnv *env, jclass class) { | ||
return open("io-uring-test.txt", O_RDWR | O_TRUNC | O_CREAT, 0644); | ||
static jint netty_create_file(JNIEnv *env, jclass class, jstring filename) { | ||
const char *file = (*env)->GetStringUTFChars(env, filename, 0); | ||
|
||
int fd = open(file, O_RDWR | O_TRUNC | O_CREAT, 0644); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we're Linux specific (because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good point ... let me do this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is a good idea but seems requires some checks to be sure it works
but it seems vastly supported TBH There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @franz1981 thanks a lot! Because of this I just did not change anything but added a explicit delete to the test. |
||
(*env)->ReleaseStringUTFChars(env, filename, file); | ||
return fd; | ||
} | ||
|
||
|
||
|
@@ -592,7 +596,7 @@ static const JNINativeMethod method_table[] = { | |
{"ioUringSetup", "(I)[[J", (void *) netty_io_uring_setup}, | ||
{"ioUringProbe", "(I[I)Z", (void *) netty_io_uring_probe}, | ||
{"ioUringExit", "(JIJIJII)V", (void *) netty_io_uring_ring_buffer_exit}, | ||
{"createFile", "()I", (void *) netty_create_file}, | ||
{"createFile", "(Ljava/lang/String;)I", (void *) netty_create_file}, | ||
{"ioUringEnter", "(IIII)I", (void *) netty_io_uring_enter}, | ||
{"blockingEventFd", "()I", (void *) netty_epoll_native_blocking_event_fd}, | ||
{"eventFdWrite", "(IJ)V", (void *) netty_io_uring_eventFdWrite }, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment says "side-effect free" but creating a file is not. How did we get here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, this returns a file descriptor that isn't closed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
side-effect free in terms of JNI.