aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/server.c
diff options
context:
space:
mode:
authorYing Xue <ying.xue@windriver.com>2014-03-06 08:40:16 -0500
committerDavid S. Miller <davem@davemloft.net>2014-03-06 14:46:23 -0500
commit6d4ebeb4df0176b1973875840a9f7e91394c0685 (patch)
tree072142513553957311a604d24175d3e2d33f1231 /net/tipc/server.c
parent9e9cb6221aa7cb04765484fe87cc2d1b92edce64 (diff)
tipc: allow connection shutdown callback to be invoked in advance
Currently connection shutdown callback function is called when connection instance is released in tipc_conn_kref_release(), and receiving packets and sending packets are running in different threads. Even if connection is closed by the thread of receiving packets, its shutdown callback may not be called immediately as the connection reference count is non-zero at that moment. So, although the connection is shut down by the thread of receiving packets, the thread of sending packets doesn't know it. Before its shutdown callback is invoked to tell the sending thread its connection has been closed, the sending thread may deliver messages by tipc_conn_sendmsg(), this is why the following error information appears: "Sending subscription event failed, no memory" To eliminate it, allow connection shutdown callback function to be called before connection id is removed in tipc_close_conn(), which makes the sending thread know the truth in time that its socket is closed so that it doesn't send message to it. We also remove the "Sending XXX failed..." error reporting for topology and config services. Signed-off-by: Ying Xue <ying.xue@windriver.com> Signed-off-by: Erik Hugne <erik.hugne@ericsson.com> Reviewed-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/server.c')
-rw-r--r--net/tipc/server.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/net/tipc/server.c b/net/tipc/server.c
index 373979789a73..bbaa8f56024a 100644
--- a/net/tipc/server.c
+++ b/net/tipc/server.c
@@ -87,7 +87,6 @@ static void tipc_clean_outqueues(struct tipc_conn *con);
87static void tipc_conn_kref_release(struct kref *kref) 87static void tipc_conn_kref_release(struct kref *kref)
88{ 88{
89 struct tipc_conn *con = container_of(kref, struct tipc_conn, kref); 89 struct tipc_conn *con = container_of(kref, struct tipc_conn, kref);
90 struct tipc_server *s = con->server;
91 90
92 if (con->sock) { 91 if (con->sock) {
93 tipc_sock_release_local(con->sock); 92 tipc_sock_release_local(con->sock);
@@ -95,10 +94,6 @@ static void tipc_conn_kref_release(struct kref *kref)
95 } 94 }
96 95
97 tipc_clean_outqueues(con); 96 tipc_clean_outqueues(con);
98
99 if (con->conid)
100 s->tipc_conn_shutdown(con->conid, con->usr_data);
101
102 kfree(con); 97 kfree(con);
103} 98}
104 99
@@ -181,6 +176,9 @@ static void tipc_close_conn(struct tipc_conn *con)
181 struct tipc_server *s = con->server; 176 struct tipc_server *s = con->server;
182 177
183 if (test_and_clear_bit(CF_CONNECTED, &con->flags)) { 178 if (test_and_clear_bit(CF_CONNECTED, &con->flags)) {
179 if (con->conid)
180 s->tipc_conn_shutdown(con->conid, con->usr_data);
181
184 spin_lock_bh(&s->idr_lock); 182 spin_lock_bh(&s->idr_lock);
185 idr_remove(&s->conn_idr, con->conid); 183 idr_remove(&s->conn_idr, con->conid);
186 s->idr_in_use--; 184 s->idr_in_use--;