lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] crash on a lot of outgoing packets


From: kyle treleaven
Subject: [lwip-users] crash on a lot of outgoing packets
Date: Tue, 13 Dec 2005 09:54:22 -0500

Hi all,

I'm using the RAW api, in a Xilinx port of lwip to their ppc405 in
virtex4 FPGA.  I mimicked the following process for sending out data
from a basic echo server example (there seems to be a real scarcity of
raw api examples out there).  The whole thing works ok, but if I start
trying to send packets faster than they can actually go out, I go into
an infinite loop of bad pbuf_alloc's.  My short term goal is to make
the thing not crash like that, because my application can easily wait
for buffers to clear up before proceeding.  But they don't seem to
want to clear themselves out.  In the long term, I'd also like to
increase my throughput, because I have a feeling that the code below
is less than optimum-- for one, I think the data changes pbuf hands a
number of times before it actually gets out.

Thanks in advance,
Kyle


***** SENDING SNIPPET *****
{
  p = pbuf_alloc( PBUF_TRANSPORT, out_idx, PBUF_POOL );
  if ( p == NULL )
  {
    xil_printf( "bad pbuf_alloc.\r\n" );
    tcp_send_buf( pcb, state );
    return;
  }

  b_ptr = out_buffer;
  /* assume that data and packet will be flush. */
  /* should be a good assumption. */
  for ( q = p; q != NULL; q = q->next )
  {
    for ( i=0; i < q->len; i++ )
      ((u8_t *)q->payload)[i] = *b_ptr++;
  }
        
  if ( state->p_out )
    pbuf_chain( state->p_out, p );
  else
    state->p_out = p;

  tcp_send_buf( pcb, state );
}

                
***** tcp_send_buf *****                
tcp_send_buf(struct tcp_pcb *pcb, struct tcp_server_state *state)
{
  struct pbuf *q;
  if ( state == NULL )
  {
    tcp_close( pcb );
    return;
  }

  while ( q = state->p_out )
  {
    state->p_out = pbuf_dechain(q);
    if( tcp_write( pcb, q->payload, q->len, 1 ) == ERR_MEM )
    {
      pbuf_chain(q, state->p_out);
      state->p_out = q;
      break;
    }
    pbuf_free(q);
  }
  tcp_output( pcb );
}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]