diff options
| author | Donald Sharp <sharpd@nvidia.com> | 2022-05-17 16:29:29 -0400 | 
|---|---|---|
| committer | Donald Sharp <sharpd@nvidia.com> | 2022-05-20 09:52:16 -0400 | 
| commit | c905f04c7ce7b09189999d4908c379f880b6b179 (patch) | |
| tree | 28d5769ebac08b41f3410ca7ecc4c7138b15500a /ospf6d/ospf6_neighbor.c | |
| parent | 23b11ab185878eb77b3212b9673856bc99d960f2 (diff) | |
ospf6d: Clean up thread interface
a) Remove setting of thread pointer to NULL after
thread invocation, this is already done.
b) Use thread_is_scheduled()
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'ospf6d/ospf6_neighbor.c')
| -rw-r--r-- | ospf6d/ospf6_neighbor.c | 57 | 
1 files changed, 33 insertions, 24 deletions
diff --git a/ospf6d/ospf6_neighbor.c b/ospf6d/ospf6_neighbor.c index 8dca0913d3..439b94c9af 100644 --- a/ospf6d/ospf6_neighbor.c +++ b/ospf6d/ospf6_neighbor.c @@ -435,8 +435,7 @@ void ospf6_check_nbr_loading(struct ospf6_neighbor *on)  		if (on->request_list->count == 0)  			thread_add_event(master, loading_done, on, 0, NULL);  		else if (on->last_ls_req == NULL) { -			if (on->thread_send_lsreq != NULL) -				THREAD_OFF(on->thread_send_lsreq); +			THREAD_OFF(on->thread_send_lsreq);  			thread_add_event(master, ospf6_lsreq_send, on, 0,  					 &on->thread_send_lsreq);  		} @@ -481,7 +480,6 @@ void adj_ok(struct thread *thread)  		SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT);  		THREAD_OFF(on->thread_send_dbdesc); -		on->thread_send_dbdesc = NULL;  		thread_add_event(master, ospf6_dbdesc_send, on, 0,  				 &on->thread_send_dbdesc); @@ -527,7 +525,6 @@ void seqnumber_mismatch(struct thread *thread)  	THREAD_OFF(on->thread_send_dbdesc);  	on->dbdesc_seqnum++; /* Incr seqnum as per RFC2328, sec 10.3 */ -	on->thread_send_dbdesc = NULL;  	thread_add_event(master, ospf6_dbdesc_send, on, 0,  			 &on->thread_send_dbdesc);  } @@ -562,7 +559,6 @@ void bad_lsreq(struct thread *thread)  	THREAD_OFF(on->thread_send_dbdesc);  	on->dbdesc_seqnum++; /* Incr seqnum as per RFC2328, sec 10.3 */ -	on->thread_send_dbdesc = NULL;  	thread_add_event(master, ospf6_dbdesc_send, on, 0,  			 &on->thread_send_dbdesc); @@ -850,15 +846,17 @@ static void ospf6_neighbor_show_detail(struct vty *vty,  		timerclear(&res); -		if (on->thread_send_dbdesc) +		if (thread_is_scheduled(on->thread_send_dbdesc))  			timersub(&on->thread_send_dbdesc->u.sands, &now, &res);  		timerstring(&res, duration, sizeof(duration));  		json_object_int_add(json_neighbor, "pendingLsaDbDescCount",  				    on->dbdesc_list->count);  		json_object_string_add(json_neighbor, "pendingLsaDbDescTime",  				       duration); -		json_object_string_add(json_neighbor, "dbDescSendThread", -				       (on->thread_send_dbdesc ? "on" : "off")); +		json_object_string_add( +			json_neighbor, "dbDescSendThread", +			(thread_is_scheduled(on->thread_send_dbdesc) ? "on" +								     : "off"));  		json_array = json_object_new_array();  		for (ALL_LSDB(on->dbdesc_list, lsa, lsanext))  			json_object_array_add( @@ -867,15 +865,17 @@ static void ospf6_neighbor_show_detail(struct vty *vty,  				       json_array);  		timerclear(&res); -		if (on->thread_send_lsreq) +		if (thread_is_scheduled(on->thread_send_lsreq))  			timersub(&on->thread_send_lsreq->u.sands, &now, &res);  		timerstring(&res, duration, sizeof(duration));  		json_object_int_add(json_neighbor, "pendingLsaLsReqCount",  				    on->request_list->count);  		json_object_string_add(json_neighbor, "pendingLsaLsReqTime",  				       duration); -		json_object_string_add(json_neighbor, "lsReqSendThread", -				       (on->thread_send_lsreq ? "on" : "off")); +		json_object_string_add( +			json_neighbor, "lsReqSendThread", +			(thread_is_scheduled(on->thread_send_lsreq) ? "on" +								    : "off"));  		json_array = json_object_new_array();  		for (ALL_LSDB(on->request_list, lsa, lsanext))  			json_object_array_add( @@ -885,7 +885,7 @@ static void ospf6_neighbor_show_detail(struct vty *vty,  		timerclear(&res); -		if (on->thread_send_lsupdate) +		if (thread_is_scheduled(on->thread_send_lsupdate))  			timersub(&on->thread_send_lsupdate->u.sands, &now,  				 &res);  		timerstring(&res, duration, sizeof(duration)); @@ -895,7 +895,9 @@ static void ospf6_neighbor_show_detail(struct vty *vty,  				       duration);  		json_object_string_add(  			json_neighbor, "lsUpdateSendThread", -			(on->thread_send_lsupdate ? "on" : "off")); +			(thread_is_scheduled(on->thread_send_lsupdate) +				 ? "on" +				 : "off"));  		json_array = json_object_new_array();  		for (ALL_LSDB(on->lsupdate_list, lsa, lsanext))  			json_object_array_add( @@ -904,15 +906,17 @@ static void ospf6_neighbor_show_detail(struct vty *vty,  				       json_array);  		timerclear(&res); -		if (on->thread_send_lsack) +		if (thread_is_scheduled(on->thread_send_lsack))  			timersub(&on->thread_send_lsack->u.sands, &now, &res);  		timerstring(&res, duration, sizeof(duration));  		json_object_int_add(json_neighbor, "pendingLsaLsAckCount",  				    on->lsack_list->count);  		json_object_string_add(json_neighbor, "pendingLsaLsAckTime",  				       duration); -		json_object_string_add(json_neighbor, "lsAckSendThread", -				       (on->thread_send_lsack ? "on" : "off")); +		json_object_string_add( +			json_neighbor, "lsAckSendThread", +			(thread_is_scheduled(on->thread_send_lsack) ? "on" +								    : "off"));  		json_array = json_object_new_array();  		for (ALL_LSDB(on->lsack_list, lsa, lsanext))  			json_object_array_add( @@ -1000,47 +1004,52 @@ static void ospf6_neighbor_show_detail(struct vty *vty,  			vty_out(vty, "      %s\n", lsa->name);  		timerclear(&res); -		if (on->thread_send_dbdesc) +		if (thread_is_scheduled(on->thread_send_dbdesc))  			timersub(&on->thread_send_dbdesc->u.sands, &now, &res);  		timerstring(&res, duration, sizeof(duration));  		vty_out(vty,  			"    %d Pending LSAs for DbDesc in Time %s [thread %s]\n",  			on->dbdesc_list->count, duration, -			(on->thread_send_dbdesc ? "on" : "off")); +			(thread_is_scheduled(on->thread_send_dbdesc) ? "on" +								     : "off"));  		for (ALL_LSDB(on->dbdesc_list, lsa, lsanext))  			vty_out(vty, "      %s\n", lsa->name);  		timerclear(&res); -		if (on->thread_send_lsreq) +		if (thread_is_scheduled(on->thread_send_lsreq))  			timersub(&on->thread_send_lsreq->u.sands, &now, &res);  		timerstring(&res, duration, sizeof(duration));  		vty_out(vty,  			"    %d Pending LSAs for LSReq in Time %s [thread %s]\n",  			on->request_list->count, duration, -			(on->thread_send_lsreq ? "on" : "off")); +			(thread_is_scheduled(on->thread_send_lsreq) ? "on" +								    : "off"));  		for (ALL_LSDB(on->request_list, lsa, lsanext))  			vty_out(vty, "      %s\n", lsa->name);  		timerclear(&res); -		if (on->thread_send_lsupdate) +		if (thread_is_scheduled(on->thread_send_lsupdate))  			timersub(&on->thread_send_lsupdate->u.sands, &now,  				 &res);  		timerstring(&res, duration, sizeof(duration));  		vty_out(vty,  			"    %d Pending LSAs for LSUpdate in Time %s [thread %s]\n",  			on->lsupdate_list->count, duration, -			(on->thread_send_lsupdate ? "on" : "off")); +			(thread_is_scheduled(on->thread_send_lsupdate) +				 ? "on" +				 : "off"));  		for (ALL_LSDB(on->lsupdate_list, lsa, lsanext))  			vty_out(vty, "      %s\n", lsa->name);  		timerclear(&res); -		if (on->thread_send_lsack) +		if (thread_is_scheduled(on->thread_send_lsack))  			timersub(&on->thread_send_lsack->u.sands, &now, &res);  		timerstring(&res, duration, sizeof(duration));  		vty_out(vty,  			"    %d Pending LSAs for LSAck in Time %s [thread %s]\n",  			on->lsack_list->count, duration, -			(on->thread_send_lsack ? "on" : "off")); +			(thread_is_scheduled(on->thread_send_lsack) ? "on" +								    : "off"));  		for (ALL_LSDB(on->lsack_list, lsa, lsanext))  			vty_out(vty, "      %s\n", lsa->name);  | 
