/* If the socket is in CLOSE or CLOSE_WAIT we should not close the connection if there is still some data pending.  */
static int iscsi_sw_sk_state_check(struct sock *sk)
/* If the socket is in CLOSE or CLOSE_WAIT we should not close the connection if there is still some data pending.  */
static int iscsi_sw_sk_state_check(struct sock *sk)
{
	struct iscsi_conn *conn = (struct iscsi_conn*)sk->sk_user_data;
	if ((sk->sk_state == TCP_CLOSE_WAIT || sk->sk_state == TCP_CLOSE) &&
	    !atomic_read(&sk->sk_rmem_alloc)) {
		ISCSI_SW_TCP_DBG(conn, "TCP_CLOSE|TCP_CLOSE_WAIT\n");
		iscsi_conn_failure(conn, ISCSI_ERR_TCP_CONN_CLOSE);
		return -ECONNRESET;
	}
	return 0;
}