lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Problem with NULL pcb->callback_arg


From: Baptiste Chaboud-crousaz
Subject: [lwip-users] Problem with NULL pcb->callback_arg
Date: Tue, 4 Aug 2009 14:43:31 +0200
User-agent: Internet Messaging Program (IMP) H3 (4.1.6)

Hi all,


I use an HTTP server built over lwip. My server provides the following functions:

static err_t
http_accept(void *arg, struct tcp_pcb *pcb, err_t err)
{
    struct http_connect_state* hcs;

    tcp_setprio(pcb, TCP_PRIO_MIN);

    /* Allocate memory for the structure that holds the state of the connection. */
    hcs = mem_malloc(sizeof(struct http_connect_state));

    if (hcs == NULL) {
        return ERR_MEM;
    }

    /* Initialize the structure. */
    hcs->file            = NULL;
    hcs->resource_id    = 0;
    hcs->method_id        = 0;
    hcs->retries        = 0;

    /* Tell TCP that this is the structure we wish to be passed for our callbacks. */
    tcp_arg(pcb, hcs);

    /* Tell TCP that we wish to be informed of incoming data by a call to the http_recv() function. */
    tcp_recv(pcb, http_recv);

    tcp_err(pcb, conn_err);

    tcp_poll(pcb, http_poll, 4);

    return ERR_OK;
}

and

static err_t
http_sent(void *arg, struct tcp_pcb *pcb, u16_t len)
{
  struct http_connect_state* hcs;

  if(arg != NULL)
  {
      hcs = arg;
      hcs->retries = 0;
      send_data(pcb, hcs);
  }
   return ERR_OK;
}

Sometimes, the face trouble with my callback http_connect - called by the macro TCP_EVENT_SENT - because "arg" is null.

My understanding is that the http_accept function binds a pcb to an argument by a call to tcp_arg(...). I don't undersatnd why sometimes my callback is called with a NULL arg!!!

This issue seems to be avoided/limited by increasing the size of MEM_SIZE and PBUF_POOL_SIZE.


If anybody has an idea, let me knwo about it...

Baptiste


reply via email to

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