]> git.openfabrics.org - ~shefty/libibverbs.git/commitdiff
Arm CQ early enough in pingpong examples
authorRalph Campbell <ralphc@pathscale.com>
Tue, 17 Jan 2006 17:20:37 +0000 (17:20 +0000)
committerRoland Dreier <rolandd@cisco.com>
Thu, 9 Nov 2006 19:35:58 +0000 (11:35 -0800)
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>
ChangeLog
examples/rc_pingpong.c
examples/srq_pingpong.c
examples/uc_pingpong.c
examples/ud_pingpong.c

index fc1c03fb25e404349b090b4d5801afaeddf3653b..94691569be3f53672cf68401ca6b90eaca4f07f4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
index 72a076bbcd223fd74288caa0476a713134760c62..6c4ef9d62c8b6f7f1fdcfaac2286dbe26bd77ee7 100644 (file)
@@ -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) {
index 836ddc98cdfcc9c7629f088a021e1dc7bccefd4f..bc1d2e6dd51641715d4648d57be10d7aee211335 100644 (file)
@@ -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)) {
index 76ea8e962d0ef6d233043aa37758d4d6eb90bd9a..08266d492f0893671baa0bab9985fe479a474191 100644 (file)
@@ -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) {
index e364cd5d24ce76dfb5412d7171324a163168a9f3..fd9bd4229fb5bb99ddb47fd2fc347df0ad4db052 100644 (file)
@@ -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) {