mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 05:55:46 +08:00
net: use netdev_lock to protect netdev_txnotify_dev
since the type of sconn lock is rmutex, there is no need to release sconn lock before TX Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
+2
-2
@@ -359,8 +359,6 @@ int arp_send(in_addr_t ipaddr)
|
|||||||
state.snd_cb->event = arp_send_eventhandler;
|
state.snd_cb->event = arp_send_eventhandler;
|
||||||
state.finish_cb = NULL;
|
state.finish_cb = NULL;
|
||||||
|
|
||||||
netdev_unlock(dev);
|
|
||||||
|
|
||||||
/* MAC address marked with all zeros to limit concurrent task
|
/* MAC address marked with all zeros to limit concurrent task
|
||||||
* send ARP request for same destination.
|
* send ARP request for same destination.
|
||||||
*/
|
*/
|
||||||
@@ -379,6 +377,8 @@ int arp_send(in_addr_t ipaddr)
|
|||||||
* net_sem_wait will also terminate if a signal is received.
|
* net_sem_wait will also terminate if a signal is received.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
netdev_unlock(dev);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ret = net_sem_timedwait_uninterruptible(&state.snd_sem,
|
ret = net_sem_timedwait_uninterruptible(&state.snd_sem,
|
||||||
|
|||||||
@@ -259,8 +259,6 @@ ssize_t can_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg,
|
|||||||
state.snd_cb->priv = (FAR void *)&state;
|
state.snd_cb->priv = (FAR void *)&state;
|
||||||
state.snd_cb->event = psock_send_eventhandler;
|
state.snd_cb->event = psock_send_eventhandler;
|
||||||
|
|
||||||
conn_dev_unlock(&conn->sconn, dev);
|
|
||||||
|
|
||||||
/* Notify the device driver that new TX data is available. */
|
/* Notify the device driver that new TX data is available. */
|
||||||
|
|
||||||
netdev_txnotify_dev(dev);
|
netdev_txnotify_dev(dev);
|
||||||
@@ -269,6 +267,7 @@ ssize_t can_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg,
|
|||||||
* net_sem_timedwait will also terminate if a signal is received.
|
* net_sem_timedwait will also terminate if a signal is received.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
conn_dev_unlock(&conn->sconn, dev);
|
||||||
if (_SS_ISNONBLOCK(conn->sconn.s_flags) || (flags & MSG_DONTWAIT) != 0)
|
if (_SS_ISNONBLOCK(conn->sconn.s_flags) || (flags & MSG_DONTWAIT) != 0)
|
||||||
{
|
{
|
||||||
ret = net_sem_timedwait(&state.snd_sem, 0);
|
ret = net_sem_timedwait(&state.snd_sem, 0);
|
||||||
|
|||||||
@@ -381,20 +381,14 @@ ssize_t can_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg,
|
|||||||
conn->sndcb->priv = (FAR void *)conn;
|
conn->sndcb->priv = (FAR void *)conn;
|
||||||
conn->sndcb->event = psock_send_eventhandler;
|
conn->sndcb->event = psock_send_eventhandler;
|
||||||
|
|
||||||
/* unlock */
|
|
||||||
|
|
||||||
conn_dev_unlock(&conn->sconn, dev);
|
|
||||||
|
|
||||||
/* Notify the device driver that new TX data is available. */
|
/* Notify the device driver that new TX data is available. */
|
||||||
|
|
||||||
netdev_txnotify_dev(dev);
|
netdev_txnotify_dev(dev);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
/* unlock */
|
|
||||||
|
|
||||||
conn_dev_unlock(&conn->sconn, dev);
|
/* unlock */
|
||||||
}
|
|
||||||
|
conn_dev_unlock(&conn->sconn, dev);
|
||||||
|
|
||||||
return msg->msg_iov->iov_len;
|
return msg->msg_iov->iov_len;
|
||||||
|
|
||||||
|
|||||||
@@ -403,13 +403,13 @@ ssize_t icmp_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg,
|
|||||||
|
|
||||||
/* Notify the device driver of the availability of TX data */
|
/* Notify the device driver of the availability of TX data */
|
||||||
|
|
||||||
conn_dev_unlock(&conn->sconn, dev);
|
|
||||||
netdev_txnotify_dev(dev);
|
netdev_txnotify_dev(dev);
|
||||||
|
|
||||||
/* Wait for either the send to complete or for timeout to occur.
|
/* Wait for either the send to complete or for timeout to occur.
|
||||||
* net_sem_timedwait will also terminate if a signal is received.
|
* net_sem_timedwait will also terminate if a signal is received.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
conn_dev_unlock(&conn->sconn, dev);
|
||||||
ret = net_sem_timedwait(&state.snd_sem,
|
ret = net_sem_timedwait(&state.snd_sem,
|
||||||
_SO_TIMEOUT(conn->sconn.s_sndtimeo));
|
_SO_TIMEOUT(conn->sconn.s_sndtimeo));
|
||||||
conn_dev_lock(&conn->sconn, dev);
|
conn_dev_lock(&conn->sconn, dev);
|
||||||
|
|||||||
@@ -231,11 +231,13 @@ static int icmpv6_send_message(FAR struct net_driver_s *dev, bool advertise)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
netdev_unlock(dev);
|
netdev_unlock(dev);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
net_sem_wait(&state.snd_sem);
|
net_sem_wait(&state.snd_sem);
|
||||||
}
|
}
|
||||||
while (!state.snd_sent);
|
while (!state.snd_sent);
|
||||||
|
|
||||||
netdev_lock(dev);
|
netdev_lock(dev);
|
||||||
|
|
||||||
ret = state.snd_result;
|
ret = state.snd_result;
|
||||||
|
|||||||
@@ -342,6 +342,8 @@ int icmpv6_neighbor(FAR struct net_driver_s *dev,
|
|||||||
* net_sem_wait will also terminate if a signal is received.
|
* net_sem_wait will also terminate if a signal is received.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
netdev_unlock(dev);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
net_sem_wait(&state.snd_sem);
|
net_sem_wait(&state.snd_sem);
|
||||||
@@ -354,6 +356,8 @@ int icmpv6_neighbor(FAR struct net_driver_s *dev,
|
|||||||
|
|
||||||
ret = icmpv6_wait(¬ify, CONFIG_ICMPv6_NEIGHBOR_DELAYMSEC);
|
ret = icmpv6_wait(¬ify, CONFIG_ICMPv6_NEIGHBOR_DELAYMSEC);
|
||||||
|
|
||||||
|
netdev_lock(dev);
|
||||||
|
|
||||||
/* icmpv6_wait will return OK if and only if the matching Neighbor
|
/* icmpv6_wait will return OK if and only if the matching Neighbor
|
||||||
* Advertisement is received. Otherwise, it will return -ETIMEDOUT.
|
* Advertisement is received. Otherwise, it will return -ETIMEDOUT.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -105,7 +105,9 @@ int igmp_schedmsg(FAR struct igmp_group_s *group, uint8_t msgid)
|
|||||||
|
|
||||||
/* Notify the device that we have a packet to send */
|
/* Notify the device that we have a packet to send */
|
||||||
|
|
||||||
|
netdev_lock(dev);
|
||||||
netdev_txnotify_dev(dev);
|
netdev_txnotify_dev(dev);
|
||||||
|
netdev_unlock(dev);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -113,7 +113,6 @@ static void igmp_timeout_work(FAR void *arg)
|
|||||||
* the timer is cancelled before sending the IGMP_LEAVE_GROUP during leave.
|
* the timer is cancelled before sending the IGMP_LEAVE_GROUP during leave.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
net_lock();
|
|
||||||
if (!IS_IDLEMEMBER(group->flags))
|
if (!IS_IDLEMEMBER(group->flags))
|
||||||
{
|
{
|
||||||
/* Schedule (and forget) the Membership Report. NOTE:
|
/* Schedule (and forget) the Membership Report. NOTE:
|
||||||
@@ -136,8 +135,6 @@ static void igmp_timeout_work(FAR void *arg)
|
|||||||
* once or twice after short delays [Unsolicited Report Interval]..."
|
* once or twice after short delays [Unsolicited Report Interval]..."
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
net_unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -80,7 +80,9 @@ int mld_schedmsg(FAR struct mld_group_s *group, uint8_t msgtype)
|
|||||||
|
|
||||||
/* Notify the device that we have a packet to send */
|
/* Notify the device that we have a packet to send */
|
||||||
|
|
||||||
|
netdev_lock(dev);
|
||||||
netdev_txnotify_dev(dev);
|
netdev_txnotify_dev(dev);
|
||||||
|
netdev_unlock(dev);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-9
@@ -120,7 +120,6 @@ static void mld_gendog_work(FAR void *arg)
|
|||||||
ifindex = (intptr_t)arg;
|
ifindex = (intptr_t)arg;
|
||||||
DEBUGASSERT(ifindex > 0);
|
DEBUGASSERT(ifindex > 0);
|
||||||
|
|
||||||
net_lock();
|
|
||||||
dev = netdev_findbyindex(ifindex);
|
dev = netdev_findbyindex(ifindex);
|
||||||
if (dev == NULL)
|
if (dev == NULL)
|
||||||
{
|
{
|
||||||
@@ -133,6 +132,8 @@ static void mld_gendog_work(FAR void *arg)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
netdev_lock(dev);
|
||||||
|
|
||||||
/* Check for an Other Querier Present Timeout. This timer is set in non-
|
/* Check for an Other Querier Present Timeout. This timer is set in non-
|
||||||
* Querier mode to detect the case where we have lost the Querier.
|
* Querier mode to detect the case where we have lost the Querier.
|
||||||
*/
|
*/
|
||||||
@@ -171,7 +172,7 @@ static void mld_gendog_work(FAR void *arg)
|
|||||||
mld_start_gentimer(dev, MSEC2TICK(MLD_OQUERY_MSEC));
|
mld_start_gentimer(dev, MSEC2TICK(MLD_OQUERY_MSEC));
|
||||||
}
|
}
|
||||||
|
|
||||||
net_unlock();
|
netdev_unlock(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -239,7 +240,6 @@ static void mld_v1dog_work(FAR void *arg)
|
|||||||
ifindex = (intptr_t)arg;
|
ifindex = (intptr_t)arg;
|
||||||
DEBUGASSERT(ifindex > 0);
|
DEBUGASSERT(ifindex > 0);
|
||||||
|
|
||||||
net_lock();
|
|
||||||
dev = netdev_findbyindex(ifindex);
|
dev = netdev_findbyindex(ifindex);
|
||||||
if (dev == NULL)
|
if (dev == NULL)
|
||||||
{
|
{
|
||||||
@@ -253,14 +253,14 @@ static void mld_v1dog_work(FAR void *arg)
|
|||||||
{
|
{
|
||||||
/* Exit MLDv1 compatibility mode. */
|
/* Exit MLDv1 compatibility mode. */
|
||||||
|
|
||||||
|
netdev_lock(dev);
|
||||||
CLR_MLD_V1COMPAT(dev->d_mld.flags);
|
CLR_MLD_V1COMPAT(dev->d_mld.flags);
|
||||||
|
netdev_unlock(dev);
|
||||||
|
|
||||||
/* REVISIT: Whenever a host changes its compatibility mode, it cancels
|
/* REVISIT: Whenever a host changes its compatibility mode, it cancels
|
||||||
* all of its pending responses and retransmission timers.
|
* all of its pending responses and retransmission timers.
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
net_unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -329,7 +329,6 @@ static void mld_polldog_work(FAR void *arg)
|
|||||||
|
|
||||||
/* Check if this a new join to the multicast group. */
|
/* Check if this a new join to the multicast group. */
|
||||||
|
|
||||||
net_lock();
|
|
||||||
if (IS_MLD_STARTUP(group->flags))
|
if (IS_MLD_STARTUP(group->flags))
|
||||||
{
|
{
|
||||||
MLD_STATINCR(g_netstats.mld.report_sched);
|
MLD_STATINCR(g_netstats.mld.report_sched);
|
||||||
@@ -345,13 +344,14 @@ static void mld_polldog_work(FAR void *arg)
|
|||||||
|
|
||||||
fwarn("WARNING: No device associated with ifindex=%d\n",
|
fwarn("WARNING: No device associated with ifindex=%d\n",
|
||||||
group->ifindex);
|
group->ifindex);
|
||||||
net_unlock();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Schedule (and forget) the Report. */
|
/* Schedule (and forget) the Report. */
|
||||||
|
|
||||||
|
netdev_lock(dev);
|
||||||
ret = mld_schedmsg(group, mld_report_msgtype(dev));
|
ret = mld_schedmsg(group, mld_report_msgtype(dev));
|
||||||
|
netdev_unlock(dev);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
mlderr("ERROR: Failed to schedule message: %d\n", ret);
|
mlderr("ERROR: Failed to schedule message: %d\n", ret);
|
||||||
@@ -375,8 +375,6 @@ static void mld_polldog_work(FAR void *arg)
|
|||||||
CLR_MLD_STARTUP(group->flags);
|
CLR_MLD_STARTUP(group->flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
net_unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -372,11 +372,11 @@ ssize_t pkt_sendmsg(FAR struct socket *psock, FAR const struct msghdr *msg,
|
|||||||
conn->sndcb->flags = PKT_POLL;
|
conn->sndcb->flags = PKT_POLL;
|
||||||
conn->sndcb->priv = conn;
|
conn->sndcb->priv = conn;
|
||||||
conn->sndcb->event = psock_send_eventhandler;
|
conn->sndcb->event = psock_send_eventhandler;
|
||||||
conn_dev_unlock(&conn->sconn, dev);
|
|
||||||
|
|
||||||
/* Notify the device driver that new TX data is available. */
|
/* Notify the device driver that new TX data is available. */
|
||||||
|
|
||||||
netdev_txnotify_dev(dev);
|
netdev_txnotify_dev(dev);
|
||||||
|
conn_dev_unlock(&conn->sconn, dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
|
|||||||
@@ -237,8 +237,6 @@ ssize_t pkt_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg,
|
|||||||
state.snd_cb->priv = (FAR void *)&state;
|
state.snd_cb->priv = (FAR void *)&state;
|
||||||
state.snd_cb->event = psock_send_eventhandler;
|
state.snd_cb->event = psock_send_eventhandler;
|
||||||
|
|
||||||
conn_dev_unlock(&conn->sconn, dev);
|
|
||||||
|
|
||||||
/* Notify the device driver that new TX data is available. */
|
/* Notify the device driver that new TX data is available. */
|
||||||
|
|
||||||
netdev_txnotify_dev(dev);
|
netdev_txnotify_dev(dev);
|
||||||
@@ -247,6 +245,7 @@ ssize_t pkt_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg,
|
|||||||
* net_sem_wait will also terminate if a signal is received.
|
* net_sem_wait will also terminate if a signal is received.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
conn_dev_unlock(&conn->sconn, dev);
|
||||||
ret = net_sem_wait(&state.snd_sem);
|
ret = net_sem_wait(&state.snd_sem);
|
||||||
conn_dev_lock(&conn->sconn, dev);
|
conn_dev_lock(&conn->sconn, dev);
|
||||||
|
|
||||||
|
|||||||
@@ -376,8 +376,6 @@ int psock_tcp_connect(FAR struct socket *psock,
|
|||||||
info.tc_conn = conn;
|
info.tc_conn = conn;
|
||||||
info.tc_cb = &state.tc_cb;
|
info.tc_cb = &state.tc_cb;
|
||||||
info.tc_sem = &state.tc_sem;
|
info.tc_sem = &state.tc_sem;
|
||||||
conn_dev_unlock(&conn->sconn, conn->dev);
|
|
||||||
tls_cleanup_push(tls_get_info(), tcp_callback_cleanup, &info);
|
|
||||||
|
|
||||||
/* Notify the device driver that new connection is available. */
|
/* Notify the device driver that new connection is available. */
|
||||||
|
|
||||||
@@ -389,6 +387,8 @@ int psock_tcp_connect(FAR struct socket *psock,
|
|||||||
* signal is received.
|
* signal is received.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
conn_dev_unlock(&conn->sconn, conn->dev);
|
||||||
|
tls_cleanup_push(tls_get_info(), tcp_callback_cleanup, &info);
|
||||||
ret = net_sem_wait(&state.tc_sem);
|
ret = net_sem_wait(&state.tc_sem);
|
||||||
|
|
||||||
tls_cleanup_pop(tls_get_info(), 0);
|
tls_cleanup_pop(tls_get_info(), 0);
|
||||||
|
|||||||
@@ -838,7 +838,9 @@ static ssize_t tcp_recvfrom_one(FAR struct tcp_conn_s *conn, FAR void *buf,
|
|||||||
if (tcp_should_send_recvwindow(conn))
|
if (tcp_should_send_recvwindow(conn))
|
||||||
{
|
{
|
||||||
conn_unlock(&conn->sconn);
|
conn_unlock(&conn->sconn);
|
||||||
|
netdev_lock(conn->dev);
|
||||||
netdev_txnotify_dev(conn->dev);
|
netdev_txnotify_dev(conn->dev);
|
||||||
|
netdev_unlock(conn->dev);
|
||||||
conn_lock(&conn->sconn);
|
conn_lock(&conn->sconn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1665,8 +1665,8 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf,
|
|||||||
|
|
||||||
/* Notify the device driver of the availability of TX data */
|
/* Notify the device driver of the availability of TX data */
|
||||||
|
|
||||||
conn_dev_unlock(&conn->sconn, conn->dev);
|
|
||||||
tcp_send_txnotify(psock, conn);
|
tcp_send_txnotify(psock, conn);
|
||||||
|
conn_dev_unlock(&conn->sconn, conn->dev);
|
||||||
|
|
||||||
if (chunk_result == 0)
|
if (chunk_result == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -515,12 +515,12 @@ ssize_t tcp_sendfile(FAR struct socket *psock, FAR struct file *infile,
|
|||||||
TCP_DISCONN_EVENTS);
|
TCP_DISCONN_EVENTS);
|
||||||
state.snd_cb->priv = (FAR void *)&state;
|
state.snd_cb->priv = (FAR void *)&state;
|
||||||
state.snd_cb->event = sendfile_eventhandler;
|
state.snd_cb->event = sendfile_eventhandler;
|
||||||
conn_dev_unlock(&conn->sconn, conn->dev);
|
|
||||||
|
|
||||||
/* Notify the device driver of the availability of TX data */
|
/* Notify the device driver of the availability of TX data */
|
||||||
|
|
||||||
tcp_send_txnotify(psock, conn);
|
tcp_send_txnotify(psock, conn);
|
||||||
|
|
||||||
|
conn_dev_unlock(&conn->sconn, conn->dev);
|
||||||
for (; ; )
|
for (; ; )
|
||||||
{
|
{
|
||||||
uint32_t acked = state.snd_acked;
|
uint32_t acked = state.snd_acked;
|
||||||
|
|||||||
@@ -137,9 +137,7 @@ static inline int tcp_send_fin(FAR struct socket *psock)
|
|||||||
|
|
||||||
/* Notify the device driver of the availability of TX data */
|
/* Notify the device driver of the availability of TX data */
|
||||||
|
|
||||||
conn_dev_unlock(&conn->sconn, conn->dev);
|
|
||||||
tcp_send_txnotify(psock, conn);
|
tcp_send_txnotify(psock, conn);
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|||||||
@@ -154,7 +154,9 @@ static void tcp_timer_expiry(FAR void *arg)
|
|||||||
{
|
{
|
||||||
tcp_conn_list_unlock();
|
tcp_conn_list_unlock();
|
||||||
conn->timeout = true;
|
conn->timeout = true;
|
||||||
|
netdev_lock(conn->dev);
|
||||||
netdev_txnotify_dev(conn->dev);
|
netdev_txnotify_dev(conn->dev);
|
||||||
|
netdev_unlock(conn->dev);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -248,6 +248,7 @@ static int sendto_next_transfer(FAR struct udp_conn_s *conn)
|
|||||||
{
|
{
|
||||||
FAR struct udp_wrbuffer_s *wrb;
|
FAR struct udp_wrbuffer_s *wrb;
|
||||||
FAR struct net_driver_s *dev;
|
FAR struct net_driver_s *dev;
|
||||||
|
int ret = OK;
|
||||||
|
|
||||||
/* Set the UDP "connection" to the destination address of the write buffer
|
/* Set the UDP "connection" to the destination address of the write buffer
|
||||||
* at the head of the queue.
|
* at the head of the queue.
|
||||||
@@ -329,11 +330,10 @@ static int sendto_next_transfer(FAR struct udp_conn_s *conn)
|
|||||||
* callback is not already in place.
|
* callback is not already in place.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
conn_dev_lock(&conn->sconn, dev);
|
||||||
if (conn->sndcb == NULL)
|
if (conn->sndcb == NULL)
|
||||||
{
|
{
|
||||||
conn_dev_lock(&conn->sconn, dev);
|
|
||||||
conn->sndcb = udp_callback_alloc(dev, conn);
|
conn->sndcb = udp_callback_alloc(dev, conn);
|
||||||
conn_dev_unlock(&conn->sconn, dev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test if the callback has been allocated */
|
/* Test if the callback has been allocated */
|
||||||
@@ -343,8 +343,8 @@ static int sendto_next_transfer(FAR struct udp_conn_s *conn)
|
|||||||
/* A buffer allocation error occurred */
|
/* A buffer allocation error occurred */
|
||||||
|
|
||||||
nerr("ERROR: Failed to allocate callback\n");
|
nerr("ERROR: Failed to allocate callback\n");
|
||||||
conn_lock(&conn->sconn);
|
ret = -ENOMEM;
|
||||||
return -ENOMEM;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
conn->dev = dev;
|
conn->dev = dev;
|
||||||
@@ -359,9 +359,11 @@ static int sendto_next_transfer(FAR struct udp_conn_s *conn)
|
|||||||
|
|
||||||
netdev_txnotify_dev(dev);
|
netdev_txnotify_dev(dev);
|
||||||
|
|
||||||
|
out:
|
||||||
|
conn_dev_unlock(&conn->sconn, dev);
|
||||||
conn_lock(&conn->sconn);
|
conn_lock(&conn->sconn);
|
||||||
|
|
||||||
return OK;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -475,8 +475,6 @@ ssize_t psock_udp_sendto(FAR struct socket *psock, FAR const void *buf,
|
|||||||
state.st_cb->priv = (FAR void *)&state;
|
state.st_cb->priv = (FAR void *)&state;
|
||||||
state.st_cb->event = sendto_eventhandler;
|
state.st_cb->event = sendto_eventhandler;
|
||||||
|
|
||||||
conn_dev_unlock(&conn->sconn, state.st_dev);
|
|
||||||
|
|
||||||
/* Notify the device driver of the availability of TX data */
|
/* Notify the device driver of the availability of TX data */
|
||||||
|
|
||||||
netdev_txnotify_dev(state.st_dev);
|
netdev_txnotify_dev(state.st_dev);
|
||||||
@@ -486,6 +484,7 @@ ssize_t psock_udp_sendto(FAR struct socket *psock, FAR const void *buf,
|
|||||||
* is received.
|
* is received.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
conn_dev_unlock(&conn->sconn, state.st_dev);
|
||||||
ret = net_sem_timedwait(&state.st_sem,
|
ret = net_sem_timedwait(&state.st_sem,
|
||||||
_SO_TIMEOUT(conn->sconn.s_sndtimeo));
|
_SO_TIMEOUT(conn->sconn.s_sndtimeo));
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user