Whamcloud - gitweb
b=14132
[fs/lustre-release.git] / lnet / ulnds / socklnd / usocklnd_cb.c
index c1337e9..1195f42 100644 (file)
@@ -1,12 +1,41 @@
 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
  * vim:expandtab:shiftwidth=8:tabstop=8:
  *
- * Copyright (C) 2001, 2002 Cluster File Systems, Inc.
- *   Author: Maxim Patlasov <maxim@clusterfs.com>
+ * GPL HEADER START
  *
- *   This file is part of the Lustre file system, http://www.lustre.org
- *   Lustre is a trademark of Cluster File Systems, Inc.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Use is subject to license terms.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ *
+ * lnet/ulnds/socklnd/usocklnd_cb.c
+ *
+ * Author: Maxim Patlasov <maxim@clusterfs.com>
  */
 
 #include "usocklnd.h"
@@ -32,29 +61,29 @@ usocklnd_send_tx_immediately(usock_conn_t *conn, usock_tx_t *tx)
                 conn->uc_sending = 0;
                 pthread_mutex_unlock(&conn->uc_lock);
                 partial_send = 1;
-        } else {                
+        } else {
                 usocklnd_destroy_tx(peer->up_ni, tx);
                 /* NB: lnetmsg was finalized, so we *must* return 0 */
 
-                if (rc < 0) { /* real error */                       
+                if (rc < 0) { /* real error */
                         usocklnd_conn_kill(conn);
                         return 0;
                 }
-                
+
                 /* rc == 1: tx was sent completely */
                 rc = 0; /* let's say to caller 'Ok' */
                 //counter_imm_complete++;
         }
 
         pthread_mutex_lock(&conn->uc_lock);
-        conn->uc_sending = 0;               
+        conn->uc_sending = 0;
 
         /* schedule write handler */
         if (partial_send ||
             (conn->uc_state == UC_READY &&
              (!list_empty(&conn->uc_tx_list) ||
               !list_empty(&conn->uc_zcack_list)))) {
-                conn->uc_tx_deadline = 
+                conn->uc_tx_deadline =
                         cfs_time_shift(usock_tuns.ut_timeout);
                 conn->uc_tx_flag = 1;
                 rc2 = usocklnd_add_pollrequest(conn, POLL_TX_SET_REQUEST, POLLOUT);
@@ -79,16 +108,16 @@ usocklnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
         int               rc;
         usock_conn_t     *conn;
         int               send_immediately;
-        
+
         tx = usocklnd_create_tx(lntmsg);
         if (tx == NULL)
                 return -ENOMEM;
-        
+
         rc = usocklnd_find_or_create_peer(ni, target, &peer);
         if (rc) {
                 LIBCFS_FREE (tx, tx->tx_size);
                 return rc;
-        }                
+        }
         /* peer cannot disappear now because its refcount was incremented */
 
         type = usocklnd_get_conn_type(lntmsg);
@@ -121,7 +150,7 @@ usocklnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed,
         /* I don't think that we'll win much concurrency moving lock()
          * call below lnet_extract_iov() */
         pthread_mutex_lock(&conn->uc_lock);
-        
+
         conn->uc_rx_lnetmsg = msg;
         conn->uc_rx_nob_wanted = mlen;
         conn->uc_rx_nob_left = rlen;
@@ -133,8 +162,8 @@ usocklnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed,
         /* the gap between lnet_parse() and usocklnd_recv() happened? */
         if (conn->uc_rx_state == UC_RX_PARSE_WAIT) {
                 conn->uc_rx_flag = 1; /* waiting for incoming lnet payload */
-                conn->uc_rx_deadline = 
-                        cfs_time_shift(usock_tuns.ut_timeout);                
+                conn->uc_rx_deadline =
+                        cfs_time_shift(usock_tuns.ut_timeout);
                 rc = usocklnd_add_pollrequest(conn, POLL_RX_SET_REQUEST, POLLIN);
                 if (rc != 0) {
                         usocklnd_conn_kill_locked(conn);
@@ -144,23 +173,23 @@ usocklnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed,
         }
 
         conn->uc_rx_state = UC_RX_LNET_PAYLOAD;
-  recv_out:        
+  recv_out:
         pthread_mutex_unlock(&conn->uc_lock);
         usocklnd_conn_decref(conn);
         return rc;
 }
 
 int
-usocklnd_accept(lnet_ni_t *ni, int sock_fd)
+usocklnd_accept(lnet_ni_t *ni, cfs_socket_t *sock)
 {
         int           rc;
         usock_conn_t *conn;
-        
-        rc = usocklnd_create_passive_conn(ni, sock_fd, &conn);
+
+        rc = usocklnd_create_passive_conn(ni, sock, &conn);
         if (rc)
                 return rc;
         LASSERT(conn != NULL);
-        
+
         /* disable shutdown event temporarily */
         lnet_ni_addref(ni);
 
@@ -170,7 +199,7 @@ usocklnd_accept(lnet_ni_t *ni, int sock_fd)
 
         /* NB: conn reference counter was incremented while adding
          * poll request if rc == 0 */
-        
+
         usocklnd_conn_decref(conn); /* should destroy conn if rc != 0 */
         return rc;
 }