X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=net%2Ftipc%2Fport.c;h=2f5806410c644b5b970998a17c9630d5ccf8f5af;hb=cf867ac375cea7c7a834eaddaf373e2662d9e260;hp=e2646a96935df6edad1a8f7c39885d8f244aca41;hpb=e1ec1b8ccdf0df6000faa8c2d985ca5f94157e5a;p=linux-2.6 diff --git a/net/tipc/port.c b/net/tipc/port.c index e2646a9693..2f5806410c 100644 --- a/net/tipc/port.c +++ b/net/tipc/port.c @@ -1240,6 +1240,28 @@ exit: return res; } +/** + * tipc_disconnect_port - disconnect port from peer + * + * Port must be locked. + */ + +int tipc_disconnect_port(struct tipc_port *tp_ptr) +{ + int res; + + if (tp_ptr->connected) { + tp_ptr->connected = 0; + /* let timer expire on it's own to avoid deadlock! */ + tipc_nodesub_unsubscribe( + &((struct port *)tp_ptr)->subscription); + res = TIPC_OK; + } else { + res = -ENOTCONN; + } + return res; +} + /* * tipc_disconnect(): Disconnect port form peer. * This is a node local operation. @@ -1248,17 +1270,12 @@ exit: int tipc_disconnect(u32 ref) { struct port *p_ptr; - int res = -ENOTCONN; + int res; p_ptr = tipc_port_lock(ref); if (!p_ptr) return -EINVAL; - if (p_ptr->publ.connected) { - p_ptr->publ.connected = 0; - /* let timer expire on it's own to avoid deadlock! */ - tipc_nodesub_unsubscribe(&p_ptr->subscription); - res = TIPC_OK; - } + res = tipc_disconnect_port((struct tipc_port *)p_ptr); tipc_port_unlock(p_ptr); return res; }