Skip to content

Commit f300a13

Browse files
committed
net: change conn lock from mutex to rmutex
UDP and PKT will hold the dev lock and conn lock when calling back the protocol stack from the network dirver. At this time, if the poll_notify notifies usrsock_server and executes poll_teardown, a conn double lock will appear. so we changed the lock to a recursive lock sched_dumpstack /home/work/ssd1/workspace/MiRTOS-062-dev-system-CI/nuttx/Libs/libc/sched/sched_dumpstack.c:71 __assert /home/work/ssd1/workspace/MiRTOS-062-dev-system-CI/nuttx/libs/libc/assert/lib_assert.c:49 nxsem_wait_slow /home/work/ssd1/workspace/MiRTOS-062-dev-system-CI/nuttx/sched/semaphore/sem_wait.c:102 (discriminator 1) nxmutex_lock /home/work/ssd1/workspace/MiRTOS-062-dev-system-CI/nuttx/include/nuttx/mutex.h:514 udp_pollteardown /home/work/ssd1/workspace/MiRTOS-062-dev-system-CI/nuttx/net/udp/udp_netpoll.c:278 usrsock_rpmsg_poll_setup /home/work/ssd1/workspace/MiRTOS-062-dev-system-CI/nuttx/drivers/usrsock/usrsock_rpmsg_server.c:1232 usrsock_rpmsg_poll_cb /home/work/ssd1/workspace/MiRTOS-062-dev-system-CI/nuttx/drivers/usrsock/usrsock_rpmsg_server.c:1299 poll_notify /home/work/ssd1/workspace/MiRTOS-062-dev-system-CI/nuttx/fs/vfs/fs_poll.c:296 udp_poll_eventhandler /home/work/ssd1/workspace/MiRTOS-062-dev-system-CI/nuttx/net/udp/udp_netpoll.c:105 devif_conn_event /home/work/ssd1/workspace/MiRTOS-062-dev-system-CI/nuttx/net/devif/devif_callback.c:481 udp_callback /home/work/ssd1/workspace/MiRTOS-062-dev-system-CI/nuttx/net/udp/udp_callback.c:324 udp_input_conn /home/work/ssd1/workspace/MiRTOS-062-dev-system-CI/nuttx/net/udp/udp_input.c:150 ipv4_in /home/work/ssd1/workspace/MiRTOS-062-dev-system-CI/nuttx/net/devif/ipv4_input.c:425 ipv4_input /home/work/ssd1/workspace/MiRTOS-062-dev-system-CI/nuttx/net/devif/ipv4_input.c:533 tun_net_receive_tun /home/work/ssd1/workspace/MiRTOS-062-dev-system-CI/nuttx/drivers/net/tun.c:574 tun_net_receive_tun /home/work/ssd1/workspace/MiRTOS-062-dev-system-CI/nuttx/drivers/net/tun.c:574 file_writev_compat /home/work/ssd1/workspace/MiRTOS-062-dev-system-CI/nuttx/fs/vfs/fs_write.c:89 rpmsgdev_write_handler /home/work/ssd1/workspace/MiRTOS-062-dev-system-CI/nuttx/drivers/misc/rpmsgdev_server.c:354 rpmsg_virtio_process_rx_buffer /home/work/ssd1/workspace/MiRTOS-062-dev-system-CI/nuttx/drivers/rpmsg/rpmsg_virtio.c:256 rpmsg_virtio_rx_worker /home/work/ssd1/workspace/MiRTOS-062-dev-system-CI/nuttx/drivers/rpmsg/rpmsg_virtio.c:291 work_dispatch /home/work/ssd1/workspace/MiRTOS-062-dev-system-CI/nuttx/sched/wqueue/kwork_thread.c:233 work_thread /home/work/ssd1/workspace/MiRTOS-062-dev-system-CI/nuttx/sched/wqueue/kwork_thread.c:293 nxtask_start /home/work/ssd1/workspace/MiRTOS-062-dev-system-CI/nuttx/sched/task/task_start.c:99 Signed-off-by: zhanghongyu <[email protected]>
1 parent 4b7d26d commit f300a13

File tree

12 files changed

+17
-17
lines changed

12 files changed

+17
-17
lines changed

include/nuttx/net/net.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ struct socket_conn_s
211211
* This mutex is also used to protect the list of callbacks.
212212
*/
213213

214-
mutex_t s_lock; /* Protect the connection structure */
214+
rmutex_t s_lock; /* Protect the connection structure */
215215

216216
/* Socket options */
217217

net/can/can_conn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ void can_free(FAR struct can_conn_s *conn)
138138
/* Remove the connection from the active list */
139139

140140
dq_rem(&conn->sconn.node, &g_active_can_connections);
141-
nxmutex_destroy(&conn->sconn.s_lock);
141+
nxrmutex_destroy(&conn->sconn.s_lock);
142142

143143
#ifdef CONFIG_NET_CAN_WRITE_BUFFERS
144144
/* Free the write queue */

net/can/can_sockif.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ static int can_setup(FAR struct socket *psock)
236236
conn->sndbufs = CONFIG_NET_SEND_BUFSIZE;
237237
nxsem_init(&conn->sndsem, 0, 0);
238238
#endif
239-
nxmutex_init(&conn->sconn.s_lock);
239+
nxrmutex_init(&conn->sconn.s_lock);
240240

241241
/* Attach the connection instance to the socket */
242242

net/icmp/icmp_conn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ void icmp_free(FAR struct icmp_conn_s *conn)
128128
/* Remove the connection from the active list */
129129

130130
dq_rem(&conn->sconn.node, &g_active_icmp_connections);
131-
nxmutex_destroy(&conn->sconn.s_lock);
131+
nxrmutex_destroy(&conn->sconn.s_lock);
132132

133133
/* Free the connection. */
134134

net/icmp/icmp_sockif.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static int icmp_setup(FAR struct socket *psock)
145145
conn->filter = UINT32_MAX;
146146
}
147147

148-
nxmutex_init(&conn->sconn.s_lock);
148+
nxrmutex_init(&conn->sconn.s_lock);
149149

150150
/* Save the pre-allocated connection in the socket structure */
151151

net/icmpv6/icmpv6_conn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ void icmpv6_free(FAR struct icmpv6_conn_s *conn)
125125
/* Remove the connection from the active list */
126126

127127
dq_rem(&conn->sconn.node, &g_active_icmpv6_connections);
128-
nxmutex_destroy(&conn->sconn.s_lock);
128+
nxrmutex_destroy(&conn->sconn.s_lock);
129129

130130
/* Free the connection. */
131131

net/icmpv6/icmpv6_sockif.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static int icmpv6_setup(FAR struct socket *psock)
144144
memset(&conn->filter, 0xff, sizeof(conn->filter));
145145
}
146146

147-
nxmutex_init(&conn->sconn.s_lock);
147+
nxrmutex_init(&conn->sconn.s_lock);
148148

149149
/* Save the pre-allocated connection in the socket structure */
150150

net/pkt/pkt_conn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ void pkt_free(FAR struct pkt_conn_s *conn)
127127
/* Remove the connection from the active list */
128128

129129
dq_rem(&conn->sconn.node, &g_active_pkt_connections);
130-
nxmutex_destroy(&conn->sconn.s_lock);
130+
nxrmutex_destroy(&conn->sconn.s_lock);
131131

132132
#ifdef CONFIG_NET_PKT_WRITE_BUFFERS
133133
/* Free the write queue */

net/pkt/pkt_sockif.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ static int pkt_sockif_alloc(FAR struct socket *psock)
133133
nxsem_init(&conn->sndsem, 0, 0);
134134
#endif
135135

136-
nxmutex_init(&conn->sconn.s_lock);
136+
nxrmutex_init(&conn->sconn.s_lock);
137137

138138
/* Save the pre-allocated connection in the socket structure */
139139

net/tcp/tcp_conn.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ FAR struct tcp_conn_s *tcp_alloc(uint8_t domain)
729729

730730
nxsem_init(&conn->snd_sem, 0, 0);
731731
#endif
732-
nxmutex_init(&conn->sconn.s_lock);
732+
nxrmutex_init(&conn->sconn.s_lock);
733733

734734
/* Set the default value of mss to max, this field will changed when
735735
* receive SYN.
@@ -852,7 +852,7 @@ void tcp_free(FAR struct tcp_conn_s *conn)
852852
tcp_conn_list_unlock();
853853
}
854854

855-
nxmutex_destroy(&conn->sconn.s_lock);
855+
nxrmutex_destroy(&conn->sconn.s_lock);
856856
tcp_free_rx_buffers(conn);
857857

858858
#ifdef CONFIG_NET_TCP_WRITE_BUFFERS

0 commit comments

Comments
 (0)