Skip to content

Commit

Permalink
[components/net/at]修复at socket信号量释放异常
Browse files Browse the repository at this point in the history
  • Loading branch information
yangpengya authored and mysterywolf committed Nov 4, 2024
1 parent 4fe86c9 commit a939e8e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions components/net/at/at_socket/at_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,12 +439,14 @@ static struct at_socket *alloc_socket_by_device(struct at_device *device, enum a
#endif

rt_snprintf(name, RT_NAME_MAX, "%s%d", "at_skt", idx);
/* create AT socket receive mailbox */
/* create AT socket receive semaphore */
if ((sock->recv_notice = rt_sem_create(name, 0, RT_IPC_FLAG_FIFO)) == RT_NULL)
{
LOG_E("No memory socket receive notic semaphore create.");
goto __err;
}
/* set AT socket receive semaphore 'max_value' to 1 */
rt_sem_control(sock->recv_notice, RT_IPC_CMD_SET_VLIMIT, (void *)1);

rt_snprintf(name, RT_NAME_MAX, "%s%d", "at_skt", idx);
/* create AT socket receive ring buffer lock */
Expand Down Expand Up @@ -823,7 +825,7 @@ static void at_recv_notice_cb(struct at_socket *sock, at_socket_evt_t event, con
}
rt_mutex_release(sock->recv_lock);

rt_sem_control(sock->recv_notice, RT_IPC_CMD_RESET, (void*)1);
rt_sem_release(sock->recv_notice);

at_do_event_changes(sock, AT_EVENT_RECV, RT_TRUE);
}
Expand All @@ -842,7 +844,7 @@ static void at_closed_notice_cb(struct at_socket *sock, at_socket_evt_t event, c
at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE);

sock->state = AT_SOCKET_CLOSED;
rt_sem_control(sock->recv_notice, RT_IPC_CMD_RESET, (void*)1);
rt_sem_release(sock->recv_notice);
}

#ifdef AT_USING_SOCKET_SERVER
Expand Down

0 comments on commit a939e8e

Please sign in to comment.