3
3
*
4
4
* Author: Patrick Stuedi <[email protected] >
5
5
*
6
- * Copyright (C) 2016, IBM Corporation
6
+ * Copyright (C) 2016-2018 , IBM Corporation
7
7
*
8
8
* Licensed under the Apache License, Version 2.0 (the "License");
9
9
* you may not use this file except in compliance with the License.
@@ -78,48 +78,42 @@ static unsigned long long createObjectId(void *obj) {
78
78
*/
79
79
}
80
80
81
-
82
81
/* *
83
82
* Throw a Java exception by name. Similar to SignalError.
84
83
*/
85
- JNIEXPORT void JNICALL
86
- JNU_ThrowByName (JNIEnv *env, const char *name, const char *msg)
87
- {
88
- jclass cls = env->FindClass (name);
84
+ JNIEXPORT void JNICALL JNU_ThrowByName (JNIEnv *env, const char *name,
85
+ const char *msg) {
86
+ jclass cls = env->FindClass (name);
89
87
90
- if (cls != 0 ) /* Otherwise an exception has already been thrown */
91
- env->ThrowNew (cls, msg);
88
+ if (cls != 0 ) /* Otherwise an exception has already been thrown */
89
+ env->ThrowNew (cls, msg);
92
90
}
93
91
94
92
/* Throw an IOException, using provided message string.
95
93
*/
96
- void JNU_ThrowIOException (JNIEnv *env, const char *msg)
97
- {
98
- JNU_ThrowByName (env, " java/io/IOException" , msg);
94
+ void JNU_ThrowIOException (JNIEnv *env, const char *msg) {
95
+ JNU_ThrowByName (env, " java/io/IOException" , msg);
99
96
}
100
97
101
98
/* Throw an IOException, using the last-error string for the detail
102
99
* string.
103
100
*/
104
- void JNU_ThrowIOExceptionWithLastError (JNIEnv *env, const char *msg)
105
- {
106
- char * errorMsg;
107
- asprintf (&errorMsg, " %s: %s\n " , msg, strerror (errno));
108
- JNU_ThrowIOException (env, errorMsg);
109
- free (errorMsg);
101
+ void JNU_ThrowIOExceptionWithLastError (JNIEnv *env, const char *msg) {
102
+ char *errorMsg;
103
+ asprintf (&errorMsg, " %s: %s\n " , msg, strerror (errno));
104
+ JNU_ThrowIOException (env, errorMsg);
105
+ free (errorMsg);
110
106
}
111
107
112
108
/* Throw an IOException, using return code.
113
109
*/
114
- void JNU_ThrowIOExceptionWithReturnCode (JNIEnv *env, const char *msg, int ret)
115
- {
116
- char * errorMsg;
117
- asprintf (&errorMsg, " %s: %s\n " , msg, strerror (ret));
118
- JNU_ThrowIOException (env, errorMsg);
119
- free (errorMsg);
110
+ void JNU_ThrowIOExceptionWithReturnCode (JNIEnv *env, const char *msg, int ret) {
111
+ char *errorMsg;
112
+ asprintf (&errorMsg, " %s: %s\n " , msg, strerror (ret));
113
+ JNU_ThrowIOException (env, errorMsg);
114
+ free (errorMsg);
120
115
}
121
116
122
-
123
117
/*
124
118
* Class: com_ibm_disni_verbs_impl_NativeDispatcher
125
119
* Method: _createEventChannel
@@ -139,8 +133,8 @@ Java_com_ibm_disni_verbs_impl_NativeDispatcher__1createEventChannel(
139
133
log (" j2c::createEventChannel: obj_id %llu\n " , obj_id);
140
134
} else {
141
135
log (" j2c::createEventChannel: rdma_create_event_channel failed\n " );
142
- JNU_ThrowIOExceptionWithLastError (env,
143
- " j2c::createEventChannel: rdma_create_event_channel failed" );
136
+ JNU_ThrowIOExceptionWithLastError (
137
+ env, " j2c::createEventChannel: rdma_create_event_channel failed" );
144
138
}
145
139
146
140
return obj_id;
@@ -170,7 +164,7 @@ Java_com_ibm_disni_verbs_impl_NativeDispatcher__1createId(JNIEnv *env,
170
164
} else {
171
165
log (" j2c::createId: rdma_create_id failed\n " );
172
166
JNU_ThrowIOExceptionWithLastError (env,
173
- " j2c::createId: rdma_create_id failed" );
167
+ " j2c::createId: rdma_create_id failed" );
174
168
}
175
169
} else {
176
170
log (" j2c::createId: cm_channel (%p) \n " , cm_channel);
@@ -230,11 +224,13 @@ Java_com_ibm_disni_verbs_impl_NativeDispatcher__1createQP(
230
224
ret = ibv_query_qp (qp, &tmp_attr, IBV_QP_STATE, &tmp_init_attr);
231
225
} else {
232
226
log (" j2c::createQP: rdma_create_qp failed %s\n " , strerror (errno));
233
- JNU_ThrowIOExceptionWithLastError (env, " j2c::createQP: rdma_create_qp failed" );
227
+ JNU_ThrowIOExceptionWithLastError (env,
228
+ " j2c::createQP: rdma_create_qp failed" );
234
229
}
235
230
} else {
236
231
log (" j2c::createQP: cm_listen_id or protection or cq null\n " );
237
- JNU_ThrowIOException (env, " j2c::createQP: cm_listen_id or protection or cq null\n " );
232
+ JNU_ThrowIOException (
233
+ env, " j2c::createQP: cm_listen_id or protection or cq null\n " );
238
234
}
239
235
240
236
return obj_id;
@@ -261,7 +257,8 @@ Java_com_ibm_disni_verbs_impl_NativeDispatcher__1bindAddr(JNIEnv *env,
261
257
} else {
262
258
log (" j2c::bind: rdma_bind_addr failed, cm_listen_id %p \n " ,
263
259
(void *)cm_listen_id);
264
- JNU_ThrowIOExceptionWithLastError (env, " j2c::bind: rdma_bind_addr failed" );
260
+ JNU_ThrowIOExceptionWithLastError (env,
261
+ " j2c::bind: rdma_bind_addr failed" );
265
262
}
266
263
} else {
267
264
log (" j2c::bind: cm_listen_id null\n " );
@@ -307,12 +304,13 @@ Java_com_ibm_disni_verbs_impl_NativeDispatcher__1resolveAddr(
307
304
cm_listen_id = (struct rdma_cm_id *)id;
308
305
if (cm_listen_id != NULL ) {
309
306
int ret = rdma_resolve_addr (cm_listen_id, NULL , (struct sockaddr *)d_addr,
310
- (int )timeout);
307
+ (int )timeout);
311
308
if (ret == 0 ) {
312
309
log (" j2c::resolveAddr: ret %i\n " , ret);
313
310
} else {
314
311
log (" j2c::resolveAddr: rdma_resolve_addr failed\n " );
315
- JNU_ThrowIOExceptionWithLastError (env, " j2c::resolveAddr: rdma_resolve_addr failed" );
312
+ JNU_ThrowIOExceptionWithLastError (
313
+ env, " j2c::resolveAddr: rdma_resolve_addr failed" );
316
314
}
317
315
} else {
318
316
log (" j2c::resolveAddr: cm_listen_id null\n " );
@@ -339,7 +337,8 @@ Java_com_ibm_disni_verbs_impl_NativeDispatcher__1resolveRoute(JNIEnv *env,
339
337
log (" j2c::resolveRoute: ret %i\n " , ret);
340
338
} else {
341
339
log (" j2c::resolveRoute: rdma_resolve_route failed\n " );
342
- JNU_ThrowIOExceptionWithLastError (env, " j2c::resolveRoute: rdma_resolve_route failed" );
340
+ JNU_ThrowIOExceptionWithLastError (
341
+ env, " j2c::resolveRoute: rdma_resolve_route failed" );
343
342
}
344
343
} else {
345
344
log (" j2c::resolveRoute: cm_listen_id null\n " );
@@ -422,7 +421,8 @@ JNIEXPORT void JNICALL Java_com_ibm_disni_verbs_impl_NativeDispatcher__1connect(
422
421
ibv_get_device_guid (cm_listen_id->verbs ->device ));
423
422
} else {
424
423
log (" j2c::connect: rdma_connect failed\n " );
425
- JNU_ThrowIOExceptionWithLastError (env, " j2c::connect: rdma_connect failed" );
424
+ JNU_ThrowIOExceptionWithLastError (env,
425
+ " j2c::connect: rdma_connect failed" );
426
426
}
427
427
} else {
428
428
log (" j2c:connect: cm_listen_id null\n " );
@@ -684,7 +684,8 @@ Java_com_ibm_disni_verbs_impl_NativeDispatcher__1allocPd(JNIEnv *env,
684
684
log (" j2c::allocPd: obj_id %llu\n " , obj_id);
685
685
} else {
686
686
log (" j2c::allocPd: ibv_alloc_pd failed\n " );
687
- JNU_ThrowIOExceptionWithLastError (env, " j2c::allocPd: ibv_alloc_pd failed" );
687
+ JNU_ThrowIOExceptionWithLastError (env,
688
+ " j2c::allocPd: ibv_alloc_pd failed" );
688
689
}
689
690
} else {
690
691
log (" j2c::allocPd: context null\n " );
@@ -716,7 +717,8 @@ Java_com_ibm_disni_verbs_impl_NativeDispatcher__1createCompChannel(JNIEnv *env,
716
717
log (" j2c::createCompChannel: obj_id %llu\n " , obj_id);
717
718
} else {
718
719
log (" j2c::createCompChannel: ibv_create_comp_channel failed\n " );
719
- JNU_ThrowIOExceptionWithLastError (env, " j2c::createCompChannel: ibv_create_comp_channel failed" );
720
+ JNU_ThrowIOExceptionWithLastError (
721
+ env, " j2c::createCompChannel: ibv_create_comp_channel failed" );
720
722
}
721
723
} else {
722
724
log (" j2c::createCompChannel: context null\n " );
@@ -753,7 +755,8 @@ Java_com_ibm_disni_verbs_impl_NativeDispatcher__1createCQ(
753
755
(void *)obj_id, (void *)cq, cq->handle , _ncqe);
754
756
} else {
755
757
log (" j2c::createCQ: ibv_create_cq failed\n " );
756
- JNU_ThrowIOExceptionWithLastError (env, " j2c::createCQ: ibv_create_cq failed" );
758
+ JNU_ThrowIOExceptionWithLastError (env,
759
+ " j2c::createCQ: ibv_create_cq failed" );
757
760
}
758
761
} else {
759
762
log (" j2c::createCQ: context or comp_channel null\n " );
@@ -784,7 +787,8 @@ Java_com_ibm_disni_verbs_impl_NativeDispatcher__1modifyQP(JNIEnv *env,
784
787
log (" j2c::modify_qp: ret %i\n " , ret);
785
788
} else {
786
789
log (" j2c::modify_qp: ibv_modify_qp failed\n " );
787
- JNU_ThrowIOExceptionWithReturnCode (env, " j2c::modify_qp: ibv_modify_qp failed" , ret);
790
+ JNU_ThrowIOExceptionWithReturnCode (
791
+ env, " j2c::modify_qp: ibv_modify_qp failed" , ret);
788
792
}
789
793
} else {
790
794
log (" j2c::modify_qp: queuepair null\n " );
@@ -845,7 +849,8 @@ Java_com_ibm_disni_verbs_impl_NativeDispatcher__1expPrefetchMr(
845
849
} else {
846
850
log (" j2c::expPrefetchMr: ibv_exp_prefetch_mr failed, error %s\n " ,
847
851
strerror (errno));
848
- JNU_ThrowIOExceptionWithLastError (env, " j2c::expPrefetchMr: ibv_exp_prefetch_mr failed" );
852
+ JNU_ThrowIOExceptionWithLastError (
853
+ env, " j2c::expPrefetchMr: ibv_exp_prefetch_mr failed" );
849
854
}
850
855
} else {
851
856
log (" j2c::expPrefetchMr: mr null\n " );
@@ -890,7 +895,7 @@ JNIEXPORT jlong JNICALL Java_com_ibm_disni_verbs_impl_NativeDispatcher__1regMr(
890
895
}
891
896
} else {
892
897
log (" j2c::regMr: protection null\n " );
893
- JNU_ThrowIOException (env, " j2c::regMr: protection null\n " );
898
+ JNU_ThrowIOException (env, " j2c::regMr: protection null\n " );
894
899
}
895
900
896
901
return obj_id;
@@ -914,7 +919,8 @@ JNIEXPORT void JNICALL Java_com_ibm_disni_verbs_impl_NativeDispatcher__1deregMr(
914
919
log (" j2c::deregMr: ret %i\n " , ret);
915
920
} else {
916
921
log (" j2c::deregMr: ibv_dereg_failed, error %s\n " , strerror (errno));
917
- JNU_ThrowIOExceptionWithReturnCode (env, " j2c::deregMr: ibv_dereg_failed, error" , ret);
922
+ JNU_ThrowIOExceptionWithReturnCode (
923
+ env, " j2c::deregMr: ibv_dereg_failed, error" , ret);
918
924
}
919
925
} else {
920
926
log (" j2c::deregMr: mr null\n " );
@@ -942,7 +948,8 @@ Java_com_ibm_disni_verbs_impl_NativeDispatcher__1postSend(JNIEnv *env,
942
948
// log("j2c::post_send: ret %i\n", ret);
943
949
} else {
944
950
log (" j2c::post_send: ibv_post_send failed %s\n " , strerror (ret));
945
- JNU_ThrowIOExceptionWithReturnCode (env, " j2c::post_send: ibv_post_send failed" , ret);
951
+ JNU_ThrowIOExceptionWithReturnCode (
952
+ env, " j2c::post_send: ibv_post_send failed" , ret);
946
953
}
947
954
948
955
} else {
@@ -972,7 +979,8 @@ Java_com_ibm_disni_verbs_impl_NativeDispatcher__1postRecv(JNIEnv *env,
972
979
// log("j2c::post_recv: ret %i\n", ret);
973
980
} else {
974
981
log (" j2c::post_recv: ibv_post_recv failed %s\n " , strerror (ret));
975
- JNU_ThrowIOExceptionWithReturnCode (env, " j2c::post_recv: ibv_post_recv failed" , ret);
982
+ JNU_ThrowIOExceptionWithReturnCode (
983
+ env, " j2c::post_recv: ibv_post_recv failed" , ret);
976
984
}
977
985
} else {
978
986
log (" j2c::post_recv: queuepair null\n " );
@@ -1213,7 +1221,8 @@ Java_com_ibm_disni_verbs_impl_NativeDispatcher__1getContextNumCompVectors(
1213
1221
obj_id, num_comp_vectors);
1214
1222
} else {
1215
1223
log (" j2c::getContextNumCompVectors: failed, obj_id %llu\n " , obj_id);
1216
- JNU_ThrowIOException (env, " j2c::getContextNumCompVectors: failed, ibv_context null" );
1224
+ JNU_ThrowIOException (
1225
+ env, " j2c::getContextNumCompVectors: failed, ibv_context null" );
1217
1226
}
1218
1227
1219
1228
return num_comp_vectors;
0 commit comments