TCP write buffering: Add buffer allocation check from Max (himax)
This commit is contained in:
parent
8266624d04
commit
e940245df9
@ -443,7 +443,7 @@ ssize_t psock_send(FAR struct socket *psock, FAR const void *buf, size_t len,
|
||||
int flags)
|
||||
{
|
||||
uip_lock_t save;
|
||||
size_t completed = 0;
|
||||
ssize_t completed = 0;
|
||||
int err;
|
||||
int ret = OK;
|
||||
|
||||
@ -469,19 +469,29 @@ ssize_t psock_send(FAR struct socket *psock, FAR const void *buf, size_t len,
|
||||
{
|
||||
struct uip_conn *conn = (struct uip_conn*)psock->s_conn;
|
||||
|
||||
/* Allocate resources to receive a callback */
|
||||
|
||||
if (!psock->s_sndcb)
|
||||
{
|
||||
psock->s_sndcb = uip_tcpcallbackalloc(conn);
|
||||
}
|
||||
|
||||
/* Test if the callback has been allocated*/
|
||||
|
||||
if (!psock->s_sndcb)
|
||||
{
|
||||
/* A buffer allocation error occurred */
|
||||
|
||||
completed = -ENOMEM;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Set up the callback in the connection */
|
||||
|
||||
psock->s_sndcb->flags = (UIP_ACKDATA | UIP_REXMIT |UIP_POLL | \
|
||||
UIP_CLOSE | UIP_ABORT | UIP_TIMEDOUT);
|
||||
psock->s_sndcb->priv = (void*)psock;
|
||||
psock->s_sndcb->event = send_interrupt;
|
||||
}
|
||||
|
||||
/* Allocate resources to receive a callback */
|
||||
|
||||
while (completed < len)
|
||||
{
|
||||
@ -516,6 +526,15 @@ ssize_t psock_send(FAR struct socket *psock, FAR const void *buf, size_t len,
|
||||
|
||||
netdev_txnotify(conn->ripaddr);
|
||||
}
|
||||
|
||||
/* A buffer allocation error occurred */
|
||||
|
||||
else
|
||||
{
|
||||
completed = -ENOMEM;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user