net: sockets_service: Always clear old events when registering
Clear all previous events when register is called a second time. This is
the same behavior as before, if the call happens with `len` equal or
greater then the previous call but in the case if `len` is less then the
first call, now, all events are cleared. This is more predictable behavior.
Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com>
diff --git a/subsys/net/lib/sockets/sockets_service.c b/subsys/net/lib/sockets/sockets_service.c
index 1e0e79e..aac226f 100644
--- a/subsys/net/lib/sockets/sockets_service.c
+++ b/subsys/net/lib/sockets/sockets_service.c
@@ -71,9 +71,9 @@
goto out;
}
- if (fds == NULL) {
- cleanup_svc_events(svc);
- } else {
+ cleanup_svc_events(svc);
+
+ if (fds != NULL) {
if (len > svc->pev_len) {
NET_DBG("Too many file descriptors, "
"max is %d for service %p",