libcli/smb/smb_direct.c retry ibv_poll_cq()
authorStefan Metzmacher <metze@samba.org>
Thu, 29 Sep 2016 08:19:24 +0000 (10:19 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 1 Jun 2018 12:35:07 +0000 (14:35 +0200)
libcli/smb/smb_direct.c

index d5099316b667c92af82f69837a42eccdaa9b53cb..2778ac344505848c36cdb0d383c7270212493c3e 100644 (file)
@@ -1625,7 +1625,7 @@ static void smb_direct_connection_ibv_handler(struct tevent_context *ev,
        uint16_t flags;
        uint32_t data_offset;
        struct smb_direct_io *io = NULL;
-
+       int try = 1;
        errno = 0;
        ret = ibv_get_cq_event(c->ibv.comp_channel,
                               &cq, &cq_context);
@@ -1658,8 +1658,18 @@ static void smb_direct_connection_ibv_handler(struct tevent_context *ev,
        }
 
        errno = 0;
+try_again:
+       DEBUG(0,("%s:%s: try[%d] ret[%d] errno[%d] status[%s]\n",
+               __location__, __FUNCTION__, try, ret, errno, nt_errstr(status)));
+       try++;
        ZERO_STRUCT(wc);
        ret = ibv_poll_cq(cq, 1, &wc);
+       if (ret == 0 && try > 1) {
+               /*
+                * The queue is empty...
+                */
+               return;
+       }
        if (ret != 1) {
                status = map_nt_error_from_unix_common(errno);
                DEBUG(0,("%s:%s: ret[%d] errno[%d] status[%s]\n",
@@ -1710,6 +1720,7 @@ static void smb_direct_connection_ibv_handler(struct tevent_context *ev,
                        smb_direct_connection_disconnect(c, status);
                        return;
                }
+               goto try_again;
                return;
 
        case IBV_WC_RECV:
@@ -1782,6 +1793,7 @@ smb_direct_connection_debug_credits(c, __location__, __func__);
                                smb_direct_connection_disconnect(c, status);
                                return;
                        }
+               goto try_again;
                        return;
                } else if (data_offset == 0x18) {
                        if (io->data_length > (c->state.max_receive_size - data_offset)) {
@@ -1900,14 +1912,15 @@ smb_direct_connection_debug_credits(c, __location__, __func__);
                        smb_direct_connection_disconnect(c, status);
                        return;
                }
+               goto try_again;
                return;
 
        case IBV_WC_RDMA_READ:
        case IBV_WC_RDMA_WRITE:
        default:
                status = NT_STATUS_INVALID_NETWORK_RESPONSE;
-               DEBUG(0,("%s:%s: ret[%d] errno[%d] status[%s]\n",
-                       __location__, __FUNCTION__, ret, errno, nt_errstr(status)));
+               DEBUG(0,("%s:%s: GOT OPCODE[%u] IO[%p] ret[%d] errno[%d] status[%s]\n",
+                       __location__, __FUNCTION__, wc.opcode, io, ret, errno, nt_errstr(status)));
                smb_direct_connection_disconnect(c, status);
                return;
        }