< prev index next >
src/jdk.net/linux/native/libextnet/LinuxRdmaSocketDispatcherImpl.c
Print this page
rev 53033 : [mq]: LinuxRdmaSocketDispatcherImpl.c
rev 53029 : imported patch jdk12-8195160-version25.patch
@@ -84,99 +84,89 @@
JNIEXPORT jint JNICALL
Java_jdk_internal_net_rdma_LinuxRdmaSocketDispatcherImpl_read0(JNIEnv *env,
jclass clazz, jobject fdo, jlong address, jint len) {
jint fd = (*env)->GetIntField(env, fdo, fd_fdID);
- jint flags = rs_fcntl(fd, F_GETFL, 0);
- jint non_blocking = (flags & O_NONBLOCK);
void *buf = (void *)jlong_to_ptr(address);
jint result = convertReturnVal(env, rs_read(fd, buf, len), JNI_TRUE);
- if (non_blocking == 0 && result == IOS_UNAVAILABLE) {
+ if (result == IOS_UNAVAILABLE
+ && (rs_fcntl(fd, F_GETFL, 0) & O_NONBLOCK) == 0) { // blocking
struct pollfd pfd[1];
pfd[0].fd = fd;
pfd[0].events = POLLIN;
rs_poll(pfd, 1, -1);
if (pfd[0].revents & POLLIN)
result = convertReturnVal(env, rs_read(fd, buf, len), JNI_TRUE);
else {
- const char *msg = "Read failed";
- JNU_ThrowIOExceptionWithLastError(env, msg);
+ JNU_ThrowIOExceptionWithLastError(env, "Read failed");
return IOS_THROWN;
}
}
return result;
}
JNIEXPORT jlong JNICALL
Java_jdk_internal_net_rdma_LinuxRdmaSocketDispatcherImpl_readv0(JNIEnv *env,
jclass clazz, jobject fdo, jlong address, jint len) {
jint fd = (*env)->GetIntField(env, fdo, fd_fdID);
- jint flags = rs_fcntl(fd, F_GETFL, 0);
- jint non_blocking = (flags & O_NONBLOCK);
struct iovec *iov = (struct iovec *)jlong_to_ptr(address);
jlong result = convertLongReturnVal(env, rs_readv(fd, iov, len), JNI_TRUE);
- if (non_blocking == 0 && result == IOS_UNAVAILABLE) {
+ if (result == IOS_UNAVAILABLE
+ && (rs_fcntl(fd, F_GETFL, 0) & O_NONBLOCK) == 0) { // blocking
struct pollfd pfd[1];
pfd[0].fd = fd;
pfd[0].events = POLLIN;
rs_poll(pfd, 1, -1);
if (pfd[0].revents & POLLIN)
- result = convertLongReturnVal(env, rs_readv(fd, iov, len),
- JNI_TRUE);
+ result = convertLongReturnVal(env, rs_readv(fd, iov, len), JNI_TRUE);
else {
- const char *msg = "Read failed";
- JNU_ThrowIOExceptionWithLastError(env, msg);
+ JNU_ThrowIOExceptionWithLastError(env, "Read failed");
return IOS_THROWN;
}
}
return result;
}
JNIEXPORT jint JNICALL
Java_jdk_internal_net_rdma_LinuxRdmaSocketDispatcherImpl_write0(JNIEnv *env,
jclass clazz, jobject fdo, jlong address, jint len) {
jint fd = (*env)->GetIntField(env, fdo, fd_fdID);
- jint flags = rs_fcntl(fd, F_GETFL, 0);
- jint non_blocking = (flags & O_NONBLOCK);
void *buf = (void *)jlong_to_ptr(address);
jint result = convertReturnVal(env, rs_write(fd, buf, len), JNI_FALSE);
- if (non_blocking == 0 && result == IOS_UNAVAILABLE) {
+ if (result == IOS_UNAVAILABLE
+ && (rs_fcntl(fd, F_GETFL, 0) & O_NONBLOCK) == 0) { // blocking
struct pollfd pfd[1];
pfd[0].fd = fd;
pfd[0].events = POLLOUT;
rs_poll(pfd, 1, -1);
if (pfd[0].revents & POLLOUT)
result = convertReturnVal(env, rs_write(fd, buf, len), JNI_FALSE);
else {
- const char *msg = "Write failed";
- JNU_ThrowIOExceptionWithLastError(env, msg);
+ JNU_ThrowIOExceptionWithLastError(env, "Write failed");
return IOS_THROWN;
}
}
return result;
}
JNIEXPORT jlong JNICALL
Java_jdk_internal_net_rdma_LinuxRdmaSocketDispatcherImpl_writev0(JNIEnv *env,
jclass clazz, jobject fdo, jlong address, jint len) {
jint fd = (*env)->GetIntField(env, fdo, fd_fdID);
- jint flags = rs_fcntl(fd, F_GETFL, 0);
- jint non_blocking = (flags & O_NONBLOCK);
struct iovec *iov = (struct iovec *)jlong_to_ptr(address);
jlong result = convertLongReturnVal(env, rs_writev(fd, iov, len),
JNI_FALSE);
- if (non_blocking == 0 && result == IOS_UNAVAILABLE) {
+ if (result == IOS_UNAVAILABLE
+ && (rs_fcntl(fd, F_GETFL, 0) & O_NONBLOCK) == 0) { // blocking
struct pollfd pfd[1];
pfd[0].fd = fd;
pfd[0].events = POLLOUT;
rs_poll(pfd, 1, -1);
if (pfd[0].revents & POLLOUT)
- result = convertLongReturnVal(env, rs_writev(fd, iov, len),
- JNI_FALSE);
+ result = convertLongReturnVal(env, rs_writev(fd, iov, len), JNI_FALSE);
else {
- const char *msg = "Write failed";
- JNU_ThrowIOExceptionWithLastError(env, msg);
+ JNU_ThrowIOExceptionWithLastError(env, "Write failed");
return IOS_THROWN;
}
}
return result;
}
< prev index next >