Unverified Commit 167d155c authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!5713 v2 tipc: wait and exit until all work queues are done

parents 22f53135 f147e8f4
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -92,10 +92,15 @@ static int __net_init tipc_init_net(struct net *net)

static void __net_exit tipc_exit_net(struct net *net)
{
	struct tipc_net *tn = tipc_net(net);

	tipc_net_stop(net);
	tipc_bcast_stop(net);
	tipc_nametbl_stop(net);
	tipc_sk_rht_destroy(net);

	while (atomic_read(&tn->wq_count))
		cond_resched();
}

static struct pernet_operations tipc_net_ops = {
+3 −0
Original line number Diff line number Diff line
@@ -122,6 +122,9 @@ struct tipc_net {
	/* Topology subscription server */
	struct tipc_topsrv *topsrv;
	atomic_t subscription_count;

	/* The numbers of work queues in schedule */
	atomic_t wq_count;
};

static inline struct tipc_net *tipc_net(struct net *net)
+2 −0
Original line number Diff line number Diff line
@@ -771,6 +771,7 @@ static void cleanup_bearer(struct work_struct *work)
		kfree_rcu(rcast, rcu);
	}

	atomic_dec(&tipc_net(sock_net(ub->ubsock->sk))->wq_count);
	if (ub->ubsock)
		udp_tunnel_sock_release(ub->ubsock);
	synchronize_net();
@@ -792,6 +793,7 @@ static void tipc_udp_disable(struct tipc_bearer *b)
	RCU_INIT_POINTER(ub->bearer, NULL);

	/* sock_release need to be done outside of rtnl lock */
	atomic_inc(&tipc_net(sock_net(ub->ubsock->sk))->wq_count);
	INIT_WORK(&ub->work, cleanup_bearer);
	schedule_work(&ub->work);
}