diff options
author | Ralph Campbell <ralphc@pathscale.com> | 2006-01-17 17:20:37 +0000 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2006-11-09 11:35:58 -0800 |
commit | 1af90a30d8be4dd338c2571fda96f22a6587c7c0 (patch) | |
tree | 7e120ac135588566fecbc253ba368d480262b12b | |
parent | 91f6faf31920e0823aa6cb98f22ec39dbe661891 (diff) | |
download | libibverbs-1af90a30d8be4dd338c2571fda96f22a6587c7c0.tar.gz |
Arm CQ early enough in pingpong examples
The example pingpong programs have a race when using events where the
client sends the first packet but the server hasn't yet armed the CQ
by calling ibv_req_notify_cq() thus waiting forever in
ibv_get_cq_event(). The fix is to move the call to
ibv_req_notify_cq() before signaling the client to "start".
Signed-off-by: Ralph Campbell <ralphc@pathscale.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | examples/rc_pingpong.c | 12 | ||||
-rw-r--r-- | examples/srq_pingpong.c | 12 | ||||
-rw-r--r-- | examples/uc_pingpong.c | 12 | ||||
-rw-r--r-- | examples/ud_pingpong.c | 12 |
5 files changed, 31 insertions, 24 deletions
@@ -1,3 +1,10 @@ +2006-01-17 Ralph Campbell <ralphc@pathscale.com> + + * examples/rc_pingpong.c (main), examples/srq_pingpong.c (main), + examples/uc_pingpong.c (main), examples/ud_pingpong.c (main): Fix + race when using CQ events by arming CQ before allowing remote side + to start sending. + 2006-01-06 Roland Dreier <rdreier@cisco.com> * examples/srq_pingpong.c (main): Fix SRQ example to avoid diff --git a/examples/rc_pingpong.c b/examples/rc_pingpong.c index 72a076b..6c4ef9d 100644 --- a/examples/rc_pingpong.c +++ b/examples/rc_pingpong.c @@ -568,6 +568,12 @@ int main(int argc, char *argv[]) return 1; } + if (use_event) + if (ibv_req_notify_cq(ctx->cq, 0)) { + fprintf(stderr, "Couldn't request CQ notification\n"); + return 1; + } + my_dest.lid = pp_get_local_lid(ctx, ib_port); my_dest.qpn = ctx->qp->qp_num; my_dest.psn = lrand48() & 0xffffff; @@ -594,12 +600,6 @@ int main(int argc, char *argv[]) if (pp_connect_ctx(ctx, ib_port, my_dest.psn, rem_dest)) return 1; - if (use_event) - if (ibv_req_notify_cq(ctx->cq, 0)) { - fprintf(stderr, "Couldn't request CQ notification\n"); - return 1; - } - ctx->pending = PINGPONG_RECV_WRID; if (servername) { diff --git a/examples/srq_pingpong.c b/examples/srq_pingpong.c index 836ddc9..bc1d2e6 100644 --- a/examples/srq_pingpong.c +++ b/examples/srq_pingpong.c @@ -649,6 +649,12 @@ int main(int argc, char *argv[]) return 1; } + if (use_event) + if (ibv_req_notify_cq(ctx->cq, 0)) { + fprintf(stderr, "Couldn't request CQ notification\n"); + return 1; + } + memset(my_dest, 0, sizeof my_dest); for (i = 0; i < num_qp; ++i) { @@ -680,12 +686,6 @@ int main(int argc, char *argv[]) if (pp_connect_ctx(ctx, ib_port, my_dest, rem_dest)) return 1; - if (use_event) - if (ibv_req_notify_cq(ctx->cq, 0)) { - fprintf(stderr, "Couldn't request CQ notification\n"); - return 1; - } - if (servername) for (i = 0; i < num_qp; ++i) { if (pp_post_send(ctx, i)) { diff --git a/examples/uc_pingpong.c b/examples/uc_pingpong.c index 76ea8e9..08266d4 100644 --- a/examples/uc_pingpong.c +++ b/examples/uc_pingpong.c @@ -556,6 +556,12 @@ int main(int argc, char *argv[]) return 1; } + if (use_event) + if (ibv_req_notify_cq(ctx->cq, 0)) { + fprintf(stderr, "Couldn't request CQ notification\n"); + return 1; + } + my_dest.lid = pp_get_local_lid(ctx, ib_port); my_dest.qpn = ctx->qp->qp_num; my_dest.psn = lrand48() & 0xffffff; @@ -582,12 +588,6 @@ int main(int argc, char *argv[]) if (pp_connect_ctx(ctx, ib_port, my_dest.psn, rem_dest)) return 1; - if (use_event) - if (ibv_req_notify_cq(ctx->cq, 0)) { - fprintf(stderr, "Couldn't request CQ notification\n"); - return 1; - } - ctx->pending = PINGPONG_RECV_WRID; if (servername) { diff --git a/examples/ud_pingpong.c b/examples/ud_pingpong.c index e364cd5..fd9bd42 100644 --- a/examples/ud_pingpong.c +++ b/examples/ud_pingpong.c @@ -564,6 +564,12 @@ int main(int argc, char *argv[]) return 1; } + if (use_event) + if (ibv_req_notify_cq(ctx->cq, 0)) { + fprintf(stderr, "Couldn't request CQ notification\n"); + return 1; + } + my_dest.lid = pp_get_local_lid(ctx, ib_port); my_dest.qpn = ctx->qp->qp_num; my_dest.psn = lrand48() & 0xffffff; @@ -590,12 +596,6 @@ int main(int argc, char *argv[]) if (pp_connect_ctx(ctx, ib_port, my_dest.psn, rem_dest)) return 1; - if (use_event) - if (ibv_req_notify_cq(ctx->cq, 0)) { - fprintf(stderr, "Couldn't request CQ notification\n"); - return 1; - } - ctx->pending = PINGPONG_RECV_WRID; if (servername) { |