[openib-general] Re: [PATCHv7] SDP: make SDP buildable on 2.6.12-final

Libor Michalek libor at topspin.com
Mon Jun 20 11:28:29 PDT 2005


On Mon, Jun 20, 2005 at 11:06:12AM -0700, Tom Duffy wrote:
> Here is the updated patch based off r2663 and building off of 2.6.12.
>
> Index: linux-2.6.12-openib/drivers/infiniband/ulp/sdp/sdp_inet.c
> ===================================================================
> --- linux-2.6.12-openib/drivers/infiniband/ulp/sdp/sdp_inet.c	(revision 2663)
> +++ linux-2.6.12-openib/drivers/infiniband/ulp/sdp/sdp_inet.c	(working copy)
> @@ -295,27 +295,22 @@ error:
>  static int sdp_inet_release(struct socket *sock)
>  {
>  	struct sdp_opt *conn;
> -	struct sock *sk;
> +	struct sock *sk = sock->sk;
>  	int  result;
>  	long timeout;
>  	u32  flags;
>  
> -	if (!sock->sk) {
> +	if (!sk) {
>  		sdp_dbg_warn(NULL, "release empty <%d:%d> flags <%08lx>",
>  			     sock->type, sock->state, sock->flags);
>  		return 0;
>  	}
>  
> -	sk = sock->sk;
> -	conn = SDP_GET_CONN(sk);
> +	conn = sdp_sk(sk);
>  
>  	sdp_dbg_ctrl(conn, "RELEASE: linger <%d:%lu> data <%d:%d>",
>  		     sock_flag(sk, SOCK_LINGER), sk->sk_lingertime,
>  		     conn->byte_strm, conn->src_recv);
> -	/*
> -	 * clear out sock, so we only do this once.
> -	 */
> -	sock->sk = NULL;
>  
>  	sdp_conn_lock(conn);
>  	conn->shutdown = SHUTDOWN_MASK;
> @@ -412,6 +407,7 @@ done:
>  	 * finally drop socket reference. (socket API reference)
>  	 */
>  	sock_orphan(sk);
> +	sock->sk = NULL;
>  	sdp_conn_unlock(conn);
>  	sdp_conn_put(conn);
>  

Looks good, but I do have one question, why did you move the clearing
of 'struct sock' from 'struct socket' to the end of the function?
Specifically if we are waiting on linger during the release I don't
think we want sock to have an sk, this avoids having any other user
system calls on this socket. This is done the same way in af_inet.c, 
the clear comes before the close/linger...

-Libor




More information about the general mailing list