[PATCH 1/3] acd: Emit event as the last statement in handler

Andrew Zaborowski <andrew.zaborowski at intel.com>
Newsgroups dev.linux.lists.ell
Message-ID <[email protected]>
Move l_acd_stop() to before the call to the event handler for
L_ACD_EVENT_LOST to allow the handler to free the l_acd instance if
needed.
---
 ell/acd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/ell/acd.c b/ell/acd.c
index 2d84843..723ae17 100644
--- a/ell/acd.c
+++ b/ell/acd.c
@@ -317,12 +317,12 @@ static bool acd_read_handler(struct l_io *io, void *user_data)
 		if (acd->policy == L_ACD_DEFEND_POLICY_NONE) {
 			ACD_DEBUG("Conflict detected, giving up address");
 
+			l_acd_stop(acd);
+
 			if (acd->event_func)
 				acd->event_func(L_ACD_EVENT_LOST,
 							acd->user_data);
 
-			l_acd_stop(acd);
-
 			break;
 		}
 
@@ -387,6 +387,8 @@ static bool acd_read_handler(struct l_io *io, void *user_data)
 		acd->timeout = NULL;
 
 		ACD_DEBUG("Lost address");
+		l_acd_stop(acd);
+
 		/*
 		* RFC 5227 Section 2.4(b)
 		* "if this is not the first conflicting ARP packet the host has seen,
@@ -398,8 +400,6 @@ static bool acd_read_handler(struct l_io *io, void *user_data)
 		if (acd->event_func)
 			acd->event_func(L_ACD_EVENT_LOST, acd->user_data);
 
-		l_acd_stop(acd);
-
 		break;
 	}
 
-- 
2.34.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.