[openib-general] libibcm get events
Dotan Barak
dotanb at dev.mellanox.co.il
Mon Jan 15 00:46:19 PST 2007
Joerg Zinke wrote:
> Hi,
>
> is there a non-blocking alternative for ib_cm_get_event() available? Any
> hints on how to check for events without blocking and waiting for the
> next one?
>
> Regards,
>
> Joerg
>
Here is a response that Or Gerlitz send a few weeks ago on getting
completion events in non blocking mode, i think that this can be useful
in your case too:
"sure, yes, for both questions: the actual object to deliver cq event is
struct ibv_comp_channel whose only field is a file descriptor with which
you can implement the requirements, use poll/select to set a timeout, or
make it non blocking such that you can
int rc;
struct ibv_comp_channel my_ch;
struct pollfd my_pollfd;
flags = fcntl(my_ch.fd, F_GETFL)
rc = fcntl(my_ch.fd, F_SETFL, flags | O_NONBLOCK)
will make ibv_get_event to return immediately if there is no event to
consume at the channel
my_pollfd.fd = my_ch.fd;
my_pollfd.events = POLLIN;
my_pollfd.revents = 0;
rc = poll(&my_pollfd, 1, ms_timeout);
will allow you to either get a timeout if ms milliseconds have elapsed
or there is an event waiting for you to consume "
Dotan
More information about the general
mailing list