+ if (eqwaitni != NULL) {
+ /* I have a single NI that I have to call into, to get
+ * events queued, or to block. */
+ lnet_ni_addref_locked(eqwaitni);
+ LNET_UNLOCK();
+
+ if (timeout_ms <= 0) {
+ (eqwaitni->ni_lnd->lnd_wait)(eqwaitni, timeout_ms);
+ } else {
+ gettimeofday(&then, NULL);
+
+ (eqwaitni->ni_lnd->lnd_wait)(eqwaitni, timeout_ms);
+
+ gettimeofday(&now, NULL);
+ timeout_ms -= (now.tv_sec - then.tv_sec) * 1000 +
+ (now.tv_usec - then.tv_usec) / 1000;
+ if (timeout_ms < 0)
+ timeout_ms = 0;
+ }
+
+ LNET_LOCK();
+ lnet_ni_decref_locked(eqwaitni);
+
+ /* don't call into eqwaitni again if timeout has
+ * expired */
+ if (timeout_ms == 0)
+ eqwaitni = NULL;
+
+ continue; /* go back and check for events */
+ }
+
+ if (timeout_ms == 0) {
+ LNET_UNLOCK();
+ RETURN (0);
+ }
+
+# ifndef HAVE_LIBPTHREAD
+ /* If I'm single-threaded, LNET fails at startup if it can't
+ * set the_lnet.ln_eqwaitni correctly. */
+ LBUG();
+# else