Whamcloud - gitweb
b=15870
[fs/lustre-release.git] / lnet / lnet / lib-msg.c
index a9834b5..84dbbee 100644 (file)
 #include <lnet/lib-lnet.h>
 
 void
+lnet_build_unlink_event (lnet_libmd_t *md, lnet_event_t *ev)
+{
+        memset(ev, 0, sizeof(*ev));
+
+        ev->status   = 0;
+        ev->unlinked = 1;
+        ev->type     = LNET_EVENT_UNLINK;
+        lnet_md_deconstruct(md, &ev->md);
+        lnet_md2handle(&ev->md_handle, md);
+}
+
+void
 lnet_enq_event_locked (lnet_eq_t *eq, lnet_event_t *ev)
 {
         lnet_event_t  *eq_slot;
@@ -54,7 +66,7 @@ lnet_enq_event_locked (lnet_eq_t *eq, lnet_event_t *ev)
         if (cfs_waitq_active(&the_lnet.ln_waitq))
                 cfs_waitq_broadcast(&the_lnet.ln_waitq);
 #else
-# if !HAVE_LIBPTHREAD
+# ifndef HAVE_LIBPTHREAD
         /* LNetEQPoll() calls into _the_ LND to wait for action */
 # else
         /* Wake anyone waiting in LNetEQPoll() */
@@ -79,18 +91,18 @@ lnet_complete_msg_locked(lnet_msg_t *msg)
 
                 msg->msg_ack = 0;
                 LNET_UNLOCK();
-        
+
                 LASSERT(msg->msg_ev.type == LNET_EVENT_PUT);
                 LASSERT(!msg->msg_routing);
 
                 ack_wmd = msg->msg_hdr.msg.put.ack_wmd;
-                
+
                 lnet_prep_send(msg, LNET_MSG_ACK, msg->msg_ev.initiator, 0, 0);
 
                 msg->msg_hdr.msg.ack.dst_wmd = ack_wmd;
                 msg->msg_hdr.msg.ack.match_bits = msg->msg_ev.match_bits;
                 msg->msg_hdr.msg.ack.mlength = cpu_to_le32(msg->msg_ev.mlength);
-                
+
                 rc = lnet_send(msg->msg_ev.target.nid, msg);
 
                 LNET_LOCK();
@@ -167,12 +179,12 @@ lnet_finalize (lnet_ni_t *ni, lnet_msg_t *msg, int status)
                 LASSERT (md->md_refcount >= 0);
 
                 unlink = lnet_md_unlinkable(md);
-                
+
                 msg->msg_ev.unlinked = unlink;
-                
+
                 if (md->md_eq != NULL)
                         lnet_enq_event_locked(md->md_eq, &msg->msg_ev);
-                
+
                 if (unlink)
                         lnet_md_unlink(md);
 
@@ -199,6 +211,8 @@ lnet_finalize (lnet_ni_t *ni, lnet_msg_t *msg, int status)
 #else
         if (the_lnet.ln_finalizing)
                 goto out;
+
+        the_lnet.ln_finalizing = 1;
 #endif
 
         while (!list_empty(&the_lnet.ln_finalizeq)) {