Ying Xue | 23 May 2012 11:24
Favicon

[PATCH net-next 3/5] tipc: Standardize checking for acknowledging received messages

Introduce one new routine(acknowledge_rx_data()) to standardize checking for
acknowledging received messages.

Signed-off-by: Ying Xue <ying.xue <at> windriver.com>
---
 net/tipc/port.c   |   21 +++++++++++++++++----
 net/tipc/port.h   |    2 ++
 net/tipc/socket.c |    8 +++-----
 3 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/net/tipc/port.c b/net/tipc/port.c
index 5fe89dd..e13dfb5 100644
--- a/net/tipc/port.c
+++ b/net/tipc/port.c
 <at>  <at>  -717,10 +717,8  <at>  <at>  static void port_dispatcher_sigh(void *dummy)
 				} else if (peer_invalid)
 					goto reject;
 				dsz = msg_data_sz(msg);
-				if (unlikely(dsz &&
-					     (++p_ptr->conn_unacked >=
-					      TIPC_CONN_MSG_THRESHOLD)))
-					tipc_acknowledge(dref);
+				if (dsz)
+					acknowledge_rx_data(p_ptr);
 				skb_pull(buf, msg_hdr_sz(msg));
 				cb(usr_handle, dref, &buf, msg_data(msg), dsz);
 				break;
 <at>  <at>  -879,6 +877,21  <at>  <at>  void tipc_acknowledge(u32 ref)
 	tipc_net_route_msg(buf);
 }

+/**
+ * acknowledge_rx_data - acknowledge messages in receive buffer
+ *  <at> p_ptr: TIPC port
+ *
+ * Used to deliver acknowledgement message for SOCK_STREAM and
+ * SOCK_SEQPACKET sockets once necessary conditions satisfy.
+ */
+void acknowledge_rx_data(struct tipc_port *p_ptr)
+{
+	p_ptr->conn_unacked++;
+
+	if (p_ptr->conn_unacked >= TIPC_CONN_MSG_THRESHOLD)
+		tipc_acknowledge(p_ptr->ref);
+}
+
 /*
  * tipc_createport(): user level call.
  */
diff --git a/net/tipc/port.h b/net/tipc/port.h
index 9a66bb4..24a14b1 100644
--- a/net/tipc/port.h
+++ b/net/tipc/port.h
 <at>  <at>  -166,6 +166,8  <at>  <at>  int tipc_send_buf_fast(struct sk_buff *buf, u32 destnode);

 void tipc_acknowledge(u32 port_ref);

+void acknowledge_rx_data(struct tipc_port *p_ptr);
+
 int tipc_createport(void *usr_handle,
 		unsigned int importance, tipc_msg_err_event error_cb,
 		tipc_named_msg_err_event named_error_cb,
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index a06ace7..5b2413d 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
 <at>  <at>  -977,9 +977,8  <at>  <at>  restart:

 	/* Consume received message (optional) */
 	if (likely(!(flags & MSG_PEEK))) {
-		if ((sock->state != SS_READY) &&
-		    (++tport->conn_unacked >= TIPC_CONN_MSG_THRESHOLD))
-			tipc_acknowledge(tport->ref);
+		if (sock->state != SS_READY)
+			acknowledge_rx_data(tport);
 		advance_rx_queue(sk);
 	}
 exit:
 <at>  <at>  -1099,8 +1098,7  <at>  <at>  restart:

 	/* Consume received message (optional) */
 	if (likely(!(flags & MSG_PEEK))) {
-		if (unlikely(++tport->conn_unacked >= TIPC_CONN_MSG_THRESHOLD))
-			tipc_acknowledge(tport->ref);
+		acknowledge_rx_data(tport);
 		advance_rx_queue(sk);
 	}

--

-- 
1.7.1

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

Gmane