[openib-general] best way to get ibv_get_cq_event to return

Or Gerlitz ogerlitz at voltaire.com
Sun Jan 7 01:03:54 PST 2007


Greenwood, Steve wrote:
> I have a thread that uses ibv_get_cq_event to handling completing RDMA 
> requests.  This call seems to have roughly the same capabilities as the 
> Mellanox vapi call EVAPI_poll_cq_block with one important exception.  
> The open-fabrics routine does not have a timeout argument. 

> Beyond restructuring my application, is there a simple way to make get 
> ibv_get_cq_event return without a message arriving?

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_SETFL)
	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

Or.
	










More information about the general mailing list