On Fri, 2007-03-02 at 10:56 -0600, Steve Wise wrote:
> On Fri, 2007-03-02 at 16:32 +0000, Tang, Changqing wrote:
> > 
> > HI, 
> >     I did not realize that ibv_get_async_event() is a blocking call,
> > it forces me to call it in another thread. But if I don't want to use
> > thread in my application, how do I use this function ?
> > 
> >     Thanks.
> > 
> > --CQ
> 
> You can select() or poll() on the async file descriptor for the QP.
> 
> Then you only call ibv_get_async_event() when poll/select indicates
> there is something to read.

Something like this:


struct my_cxt {
...
        struct ibv_context *context;
        struct rdma_event_channel *rch;
...
};

<snip>

                fds[0].fd = ctx->rch->fd;
                fds[0].events = POLLIN|POLLERR;
                fds[1].fd = ctx->context->async_fd;
                fds[1].events = POLLHUP|POLLNVAL|POLLPRI|POLLOUT|POLLIN|POLLERR;
                if (poll(fds, 2, -1) == -1) {
                        perror("poll");
                        exit(1);
                }
                if (fds[0].revents) {
                        struct rdma_cm_event *event;

                        rdma_get_cm_event(ctx->rch, &event);
                        printf("RDMA CM EVENT %d - %s!\n", event->event, 
rdma_str_event(event));
                        rdma_ack_cm_event(event);
                        ...
                }
                if (fds[1].revents) {
                        struct ibv_async_event event;

                        ibv_get_async_event(ctx->context, &event);
                        printf("ASYNC EVENT %d - %s!\n", event.event_type, 
ibv_str_async_event(&event));
                        ibv_ack_async_event(&event);
                        ...
                }


_______________________________________________
general mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to