mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
Squashed commit of the following:
Author: Gregory Nutt <gnutt@nuttx.org> Run all .h and .c files modified in last PR through nxstyle. Author: Xiang Xiao <xiaoxiang@xiaomi.com> Net cleanup (#17) * Fix the semaphore usage issue found in tcp/udp 1. The count semaphore need disable priority inheritance 2. Loop again if net_lockedwait return -EINTR 3. Call nxsem_trywait to avoid the race condition 4. Call nxsem_post instead of sem_post * Put the work notifier into free list to avoid the heap fragment in the long run. Since the allocation strategy is encapsulated internally, we can even refine the implementation later. * Network stack shouldn't allocate memory in the poll implementation to avoid the heap fragment in the long run, other modification include: 1. Select MM_IOB automatically since ICMP[v6] socket can't work without the read ahead buffer 2. Remove the net lock since xxx_callback_free already do the same thing 3. TCP/UDP poll should work even the read ahead buffer isn't enabled at all * Add NET_ prefix for UDP_NOTIFIER and TCP_NOTIFIER option to align with other UDP/TCP option convention * Remove the unused _SF_[IDLE|ACCEPT|SEND|RECV|MASK] flags since there are code to set/clear these flags, but nobody check them.
This commit is contained in:
@@ -410,10 +410,6 @@ ssize_t pkt_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Set the socket state to receiving */
|
||||
|
||||
psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_RECV);
|
||||
|
||||
/* Set up the callback in the connection */
|
||||
|
||||
state.pr_cb = pkt_callback_alloc(dev, conn);
|
||||
@@ -441,10 +437,6 @@ ssize_t pkt_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
|
||||
ret = -EBUSY;
|
||||
}
|
||||
|
||||
/* Set the socket state to idle */
|
||||
|
||||
psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_IDLE);
|
||||
|
||||
errout_with_state:
|
||||
net_unlock();
|
||||
pkt_recvfrom_uninitialize(&state);
|
||||
|
||||
@@ -191,10 +191,6 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf,
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Set the socket state to sending */
|
||||
|
||||
psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_SEND);
|
||||
|
||||
/* Perform the send operation */
|
||||
|
||||
/* Initialize the state structure. This is done with the network locked
|
||||
@@ -249,10 +245,6 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf,
|
||||
nxsem_destroy(&state.snd_sem);
|
||||
net_unlock();
|
||||
|
||||
/* Set the socket state to idle */
|
||||
|
||||
psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_IDLE);
|
||||
|
||||
/* Check for a errors, Errors are signalled by negative errno values
|
||||
* for the send length
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user