You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ma...@apache.org on 2022/08/02 07:54:40 UTC
[incubator-nuttx-apps] branch master updated: wireless/gs2200m: Release all blocking socket
This is an automated email from the ASF dual-hosted git repository.
masayuki pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new cfa5af51c wireless/gs2200m: Release all blocking socket
cfa5af51c is described below
commit cfa5af51cd25f9122eafc640299db2759bba7541
Author: Takayoshi Koizumi <ta...@gmail.com>
AuthorDate: Sun Jul 31 21:56:35 2022 +0000
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.
---
wireless/gs2200m/gs2200m_main.c | 54 +++++++++++++++++++++++++++++++++--------
1 file changed, 44 insertions(+), 10 deletions(-)
diff --git a/wireless/gs2200m/gs2200m_main.c b/wireless/gs2200m/gs2200m_main.c
index 8e1821277..ee72e1ce6 100644
--- a/wireless/gs2200m/gs2200m_main.c
+++ b/wireless/gs2200m/gs2200m_main.c
@@ -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,21 +1690,37 @@ static int gs2200m_loop(FAR struct gs2200m_s *priv)
ret = read(fd[1], &cid, sizeof(cid));
ASSERT(ret == sizeof(cid));
- /* find usock by the cid */
+ /* Check if all socket destroy or not */
- usock = gs2200m_find_socket_by_cid(priv, cid);
-
- if (NULL == usock)
+ if (cid == DISASSOCIATION_CID)
{
- gs2200m_printf("=== %s: cid=%c not found (ignored)\n",
- __func__, 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
{
- /* send event to call xxxx_request() */
-
- usock_send_event(fd[0], priv, usock,
- USRSOCK_EVENT_RECVFROM_AVAIL);
+ /* find usock by the cid */
+
+ usock = gs2200m_find_socket_by_cid(priv, cid);
+
+ if (NULL == usock)
+ {
+ gs2200m_printf("=== %s: cid=%c not found (ignored)\n",
+ __func__, cid);
+ }
+ else
+ {
+ /* send event to call xxxx_request() */
+
+ usock_send_event(fd[0], priv, usock,
+ USRSOCK_EVENT_RECVFROM_AVAIL);
+ }
}
}
}