TCP data can be safely referenced as PBUF_ROM instead of PBUF_REF.

This commit is contained in:
likewise 2003-04-07 21:28:16 +00:00
parent a3087737bd
commit a4a7a7a47e

View File

@ -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;