mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-07-16 09:47:31 +00:00
TCP data can be safely referenced as PBUF_ROM instead of PBUF_REF.
This commit is contained in:
parent
a3087737bd
commit
a4a7a7a47e
|
@ -167,14 +167,14 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
|
||||||
and data copied into pbuf, otherwise data comes from
|
and data copied into pbuf, otherwise data comes from
|
||||||
ROM or other static memory, and need not be copied. If
|
ROM or other static memory, and need not be copied. If
|
||||||
optdata is != NULL, we have options instead of data. */
|
optdata is != NULL, we have options instead of data. */
|
||||||
if(optdata != NULL) {
|
if (optdata != NULL) {
|
||||||
if((seg->p = pbuf_alloc(PBUF_TRANSPORT, optlen, PBUF_RAM)) == NULL) {
|
if((seg->p = pbuf_alloc(PBUF_TRANSPORT, optlen, PBUF_RAM)) == NULL) {
|
||||||
goto memerr;
|
goto memerr;
|
||||||
}
|
}
|
||||||
++queuelen;
|
++queuelen;
|
||||||
seg->dataptr = seg->p->payload;
|
seg->dataptr = seg->p->payload;
|
||||||
}
|
}
|
||||||
else if(copy) {
|
else if (copy) {
|
||||||
if((seg->p = pbuf_alloc(PBUF_TRANSPORT, seglen, PBUF_RAM)) == NULL) {
|
if((seg->p = pbuf_alloc(PBUF_TRANSPORT, seglen, PBUF_RAM)) == NULL) {
|
||||||
DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_enqueue: could not allocate memory for pbuf copy size %u\n", seglen));
|
DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_enqueue: could not allocate memory for pbuf copy size %u\n", seglen));
|
||||||
goto memerr;
|
goto memerr;
|
||||||
|
@ -185,12 +185,16 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
|
||||||
}
|
}
|
||||||
seg->dataptr = seg->p->payload;
|
seg->dataptr = seg->p->payload;
|
||||||
}
|
}
|
||||||
|
/* do not copy data */
|
||||||
else {
|
else {
|
||||||
/* Do not copy the data. */
|
|
||||||
|
|
||||||
/* First, allocate a pbuf for holding the data. */
|
/* first, allocate a pbuf for holding the data.
|
||||||
if((p = pbuf_alloc(PBUF_TRANSPORT, seglen, PBUF_REF)) == NULL) {
|
* since the referenced data is available at least until it is sent out on the
|
||||||
DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_enqueue: could not allocate memory for pbuf non-copy\n"));
|
* link (as it has to be ACKed by the remote party) we can safely use PBUF_ROM
|
||||||
|
* instead of PBUF_REF here.
|
||||||
|
*/
|
||||||
|
if((p = pbuf_alloc(PBUF_TRANSPORT, seglen, PBUF_ROM)) == NULL) {
|
||||||
|
DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_enqueue: could not allocate memory for zero-copy pbuf\n"));
|
||||||
goto memerr;
|
goto memerr;
|
||||||
}
|
}
|
||||||
++queuelen;
|
++queuelen;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user