[openib-general] libibcm get events

Joerg Zinke umaxx at oleco.net
Tue Jan 16 23:49:43 PST 2007


On Mon, 15 Jan 2007 10:46:19 +0200
Dotan Barak <dotanb at dev.mellanox.co.il> wrote:

> 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?
> >

> 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 "
> 

Many thanks for this hint, i will give it a try.

Joerg




More information about the general mailing list