]> git.openfabrics.org - ~shefty/libibcm.git/commitdiff
r2761: Add a convenience function for getting an event within a
authorLibor Michalek <libor@topspin.com>
Thu, 30 Jun 2005 18:27:14 +0000 (18:27 +0000)
committerLibor Michalek <libor@topspin.com>
Thu, 30 Jun 2005 18:27:14 +0000 (18:27 +0000)
certain time limit.

Signed-off-by: Libor Michalek <libor@topspin.com>
include/infiniband/cm.h
src/cm.c

index d0566b8fe35d2d87a2ed0a020a5d1870de994aa7..f9c6163c868860ea267381af054b375ec1ebeb37 100644 (file)
@@ -245,6 +245,18 @@ struct ib_cm_event {
  */
 int ib_cm_event_get(struct ib_cm_event **event);
 
+/**
+ * ib_cm_event_get_timed - Retrieves the next pending communications event,
+ *   if no event is pending wait up to a certain timeout for an event.
+ * @timeout_ms: Maximum time in milliseconds to wait for an event.
+ * @event: Allocated information about the next communication event.
+ *    Event should be freed using ib_cm_event_put()
+ *
+ * If timeout expires without an event, the error -ETIMEDOUT will be
+ * returned
+ */
+int ib_cm_event_get_timed(int timeout_ms, struct ib_cm_event **event);
+
 /**
  * ib_cm_event_put - Free a communications event.
  * @event: Event to be released.
index e278192f4a34cda69f335db25e950585ea776931..9053a908a3ad6c80ecb21eaf1dd40786edeea4c0 100644 (file)
--- a/src/cm.c
+++ b/src/cm.c
@@ -929,6 +929,9 @@ int ib_cm_event_get_timed(int timeout_ms, struct ib_cm_event **event)
        struct pollfd ufds;
        int result;
 
+       if (!event)
+               return -EINVAL;
+
        ufds.fd      = ib_cm_get_fd();
        ufds.events  = POLLIN;
        ufds.revents = 0;
@@ -939,5 +942,8 @@ int ib_cm_event_get_timed(int timeout_ms, struct ib_cm_event **event)
        if (!result)
                return -ETIMEDOUT;
 
+       if (result < 0)
+               return result;
+
        return ib_cm_event_get(event);
 }