wireless/gs2200m: Release all blocking socket
When dis-associtaion happens, the socket is destroyed. And all blocking
sockets are released for that error handling can be performed.
@@ -453,6 +453,24 @@ static int usock_send_event(int fd, FAR struct gs2200m_s *priv,
return _write_to_usock(fd, &event, sizeof(event));
}
+/****************************************************************************
+ * Name: usock_sendevent_toall
+ ****************************************************************************/
+
+static void usock_sendevent_toall(FAR struct gs2200m_s *priv, int fd)
+{
+ int i;
+
+ for (i = 0; i < SOCKET_COUNT; i++)
+ {
+ if (priv->sockets[i].state != CLOSED)
+ {
+ usock_send_event(fd, priv, &priv->sockets[i],
+ USRSOCK_EVENT_RECVFROM_AVAIL);
+ }
+ }
+}
+
/****************************************************************************
* Name: socket_request
****************************************************************************/
@@ -1672,6 +1690,21 @@ static int gs2200m_loop(FAR struct gs2200m_s *priv)
ret = read(fd[1], &cid, sizeof(cid));
ASSERT(ret == sizeof(cid));
+ /* Check if all socket destroy or not */
+
+ if (cid == DISASSOCIATION_CID)
+ {
+ gs2200m_printf("=== %s: Disassocitaion event\n",
+ __func__);
+
+ /* To release sockets blocking in user-sock,
+ * send event to all opened sockets.
+ */
+
+ usock_sendevent_toall(priv, fd[0]);
+ }
+ else
+ {
/* find usock by the cid */
usock = gs2200m_find_socket_by_cid(priv, cid);
@@ -1690,6 +1723,7 @@ static int gs2200m_loop(FAR struct gs2200m_s *priv)
}
}
}
+ }
close(fd[1]);
close(fd[0]);
