85 JNIEXPORT jint JNICALL |
85 JNIEXPORT jint JNICALL |
86 Java_jdk_internal_net_rdma_LinuxRdmaSocketDispatcherImpl_read0(JNIEnv *env, |
86 Java_jdk_internal_net_rdma_LinuxRdmaSocketDispatcherImpl_read0(JNIEnv *env, |
87 jclass clazz, jobject fdo, jlong address, jint len) { |
87 jclass clazz, jobject fdo, jlong address, jint len) { |
88 jint fd = (*env)->GetIntField(env, fdo, fd_fdID); |
88 jint fd = (*env)->GetIntField(env, fdo, fd_fdID); |
89 void *buf = (void *)jlong_to_ptr(address); |
89 void *buf = (void *)jlong_to_ptr(address); |
90 jint result = convertReturnVal(env, rs_read(fd, buf, len), JNI_TRUE); |
90 return convertReturnVal(env, rs_read(fd, buf, len), JNI_TRUE); |
91 /* |
|
92 if (result == IOS_UNAVAILABLE |
|
93 && (rs_fcntl(fd, F_GETFL, 0) & O_NONBLOCK) == 0) { // blocking |
|
94 struct pollfd pfd[1]; |
|
95 pfd[0].fd = fd; |
|
96 pfd[0].events = POLLIN; |
|
97 rs_poll(pfd, 1, -1); |
|
98 if (pfd[0].revents & POLLIN) |
|
99 result = convertReturnVal(env, rs_read(fd, buf, len), JNI_TRUE); |
|
100 else { |
|
101 JNU_ThrowIOExceptionWithLastError(env, "Read failed"); |
|
102 return IOS_THROWN; |
|
103 } |
|
104 } |
|
105 */ |
|
106 return result; |
|
107 } |
91 } |
108 |
92 |
109 JNIEXPORT jlong JNICALL |
93 JNIEXPORT jlong JNICALL |
110 Java_jdk_internal_net_rdma_LinuxRdmaSocketDispatcherImpl_readv0(JNIEnv *env, |
94 Java_jdk_internal_net_rdma_LinuxRdmaSocketDispatcherImpl_readv0(JNIEnv *env, |
111 jclass clazz, jobject fdo, jlong address, jint len) { |
95 jclass clazz, jobject fdo, jlong address, jint len) { |
112 jint fd = (*env)->GetIntField(env, fdo, fd_fdID); |
96 jint fd = (*env)->GetIntField(env, fdo, fd_fdID); |
113 struct iovec *iov = (struct iovec *)jlong_to_ptr(address); |
97 struct iovec *iov = (struct iovec *)jlong_to_ptr(address); |
114 jlong result = convertLongReturnVal(env, rs_readv(fd, iov, len), JNI_TRUE); |
98 return convertLongReturnVal(env, rs_readv(fd, iov, len), JNI_TRUE); |
115 /* |
|
116 if (result == IOS_UNAVAILABLE |
|
117 && (rs_fcntl(fd, F_GETFL, 0) & O_NONBLOCK) == 0) { // blocking |
|
118 struct pollfd pfd[1]; |
|
119 pfd[0].fd = fd; |
|
120 pfd[0].events = POLLIN; |
|
121 rs_poll(pfd, 1, -1); |
|
122 if (pfd[0].revents & POLLIN) |
|
123 result = convertLongReturnVal(env, rs_readv(fd, iov, len), JNI_TRUE); |
|
124 else { |
|
125 JNU_ThrowIOExceptionWithLastError(env, "Read failed"); |
|
126 return IOS_THROWN; |
|
127 } |
|
128 } |
|
129 */ |
|
130 return result; |
|
131 } |
99 } |
132 |
100 |
133 JNIEXPORT jint JNICALL |
101 JNIEXPORT jint JNICALL |
134 Java_jdk_internal_net_rdma_LinuxRdmaSocketDispatcherImpl_write0(JNIEnv *env, |
102 Java_jdk_internal_net_rdma_LinuxRdmaSocketDispatcherImpl_write0(JNIEnv *env, |
135 jclass clazz, jobject fdo, jlong address, jint len) { |
103 jclass clazz, jobject fdo, jlong address, jint len) { |
136 jint fd = (*env)->GetIntField(env, fdo, fd_fdID); |
104 jint fd = (*env)->GetIntField(env, fdo, fd_fdID); |
137 void *buf = (void *)jlong_to_ptr(address); |
105 void *buf = (void *)jlong_to_ptr(address); |
138 jint result = convertReturnVal(env, rs_write(fd, buf, len), JNI_FALSE); |
106 return convertReturnVal(env, rs_write(fd, buf, len), JNI_FALSE); |
139 /* |
|
140 if (result == IOS_UNAVAILABLE |
|
141 && (rs_fcntl(fd, F_GETFL, 0) & O_NONBLOCK) == 0) { // blocking |
|
142 struct pollfd pfd[1]; |
|
143 pfd[0].fd = fd; |
|
144 pfd[0].events = POLLOUT; |
|
145 rs_poll(pfd, 1, -1); |
|
146 if (pfd[0].revents & POLLOUT) |
|
147 result = convertReturnVal(env, rs_write(fd, buf, len), JNI_FALSE); |
|
148 else { |
|
149 JNU_ThrowIOExceptionWithLastError(env, "Write failed"); |
|
150 return IOS_THROWN; |
|
151 } |
|
152 } |
|
153 */ |
|
154 return result; |
|
155 } |
107 } |
156 |
108 |
157 JNIEXPORT jlong JNICALL |
109 JNIEXPORT jlong JNICALL |
158 Java_jdk_internal_net_rdma_LinuxRdmaSocketDispatcherImpl_writev0(JNIEnv *env, |
110 Java_jdk_internal_net_rdma_LinuxRdmaSocketDispatcherImpl_writev0(JNIEnv *env, |
159 jclass clazz, jobject fdo, jlong address, jint len) { |
111 jclass clazz, jobject fdo, jlong address, jint len) { |
160 jint fd = (*env)->GetIntField(env, fdo, fd_fdID); |
112 jint fd = (*env)->GetIntField(env, fdo, fd_fdID); |
161 struct iovec *iov = (struct iovec *)jlong_to_ptr(address); |
113 struct iovec *iov = (struct iovec *)jlong_to_ptr(address); |
162 jlong result = convertLongReturnVal(env, rs_writev(fd, iov, len), |
114 return convertLongReturnVal(env, rs_writev(fd, iov, len), JNI_FALSE); |
163 JNI_FALSE); |
|
164 /* |
|
165 if (result == IOS_UNAVAILABLE |
|
166 && (rs_fcntl(fd, F_GETFL, 0) & O_NONBLOCK) == 0) { // blocking |
|
167 struct pollfd pfd[1]; |
|
168 pfd[0].fd = fd; |
|
169 pfd[0].events = POLLOUT; |
|
170 rs_poll(pfd, 1, -1); |
|
171 if (pfd[0].revents & POLLOUT) |
|
172 result = convertLongReturnVal(env, rs_writev(fd, iov, len), JNI_FALSE); |
|
173 else { |
|
174 JNU_ThrowIOExceptionWithLastError(env, "Write failed"); |
|
175 return IOS_THROWN; |
|
176 } |
|
177 } |
|
178 */ |
|
179 return result; |
|
180 } |
115 } |
181 |
116 |
182 static void closeFileDescriptor(JNIEnv *env, int fd) { |
117 static void closeFileDescriptor(JNIEnv *env, int fd) { |
183 if (fd != -1) { |
118 if (fd != -1) { |
184 int result = rs_close(fd); |
119 int result = rs_close(fd); |