|
1 #This patch was developed both in-house and from outside. We plan to submit it |
|
2 #upstream, but do not yet have a target date for doing so |
|
3 # HG changeset patch |
|
4 # Parent 68a7383fdd511ce1ea9a0dfc24404b3d74e67055 |
|
5 |
|
6 diff -r 68a7383fdd51 examples/rping.c |
|
7 --- a/examples/rping.c Tue Mar 15 19:57:38 2016 -0700 |
|
8 +++ b/examples/rping.c Thu Mar 17 00:08:03 2016 -0700 |
|
9 @@ -88,6 +88,7 @@ |
|
10 RDMA_READ_COMPLETE, |
|
11 RDMA_WRITE_ADV, |
|
12 RDMA_WRITE_COMPLETE, |
|
13 + CALLING_DISCONNECT, |
|
14 DISCONNECTED, |
|
15 ERROR |
|
16 }; |
|
17 @@ -290,6 +291,20 @@ |
|
18 |
|
19 if (wc.status) { |
|
20 if (wc.status == IBV_WC_WR_FLUSH_ERR) { |
|
21 + /* |
|
22 + * FLUSH Error can be polled before RDMA-CM |
|
23 + * DISCONNECT is notified. Ensure that cb_state |
|
24 + * is set appropriately in such a case. |
|
25 + * sleep for sometime if Disconnect has not |
|
26 + * been called. The FLUSH WR can be because |
|
27 + * the remote end initiated the disconnect. |
|
28 + */ |
|
29 + if (!(cb->state == CALLING_DISCONNECT || cb->state == DISCONNECTED)) |
|
30 + sleep(2); |
|
31 + |
|
32 + if (cb->state == DISCONNECTED) |
|
33 + return (0); |
|
34 + |
|
35 flushed = 1; |
|
36 continue; |
|
37 |
|
38 @@ -824,7 +839,9 @@ |
|
39 } |
|
40 |
|
41 rping_test_server(cb); |
|
42 + cb->state = CALLING_DISCONNECT; |
|
43 rdma_disconnect(cb->child_cm_id); |
|
44 + pthread_cancel(cb->cqthread); |
|
45 pthread_join(cb->cqthread, NULL); |
|
46 rping_free_buffers(cb); |
|
47 rping_free_qp(cb); |
|
48 @@ -943,6 +960,7 @@ |
|
49 |
|
50 ret = 0; |
|
51 err3: |
|
52 + cb->state = CALLING_DISCONNECT; |
|
53 rdma_disconnect(cb->child_cm_id); |
|
54 pthread_join(cb->cqthread, NULL); |
|
55 rdma_destroy_id(cb->child_cm_id); |
|
56 @@ -1122,6 +1140,7 @@ |
|
57 |
|
58 ret = 0; |
|
59 err4: |
|
60 + cb->state = CALLING_DISCONNECT; |
|
61 rdma_disconnect(cb->cm_id); |
|
62 err3: |
|
63 pthread_join(cb->cqthread, NULL); |