lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Correct way to free pbufs after tcp_recv callback finis


From: Noam Weissman
Subject: Re: [lwip-users] Correct way to free pbufs after tcp_recv callback finished
Date: Tue, 28 Jun 2016 07:41:03 +0000

Dear Simon,


You are correct I confused tcp_received with tcp_accepted.... My mistake.


From the LwIP WIKI:

Passive connection (Listen)Edit

  1. Call tcp_new to create a pcb.
  2. Optionally call tcp_arg to associate an application-specific value with the pcb.
  3. Call tcp_bind to specify the local IP address and port.
  4. Call tcp_listen or tcp_listen_with_backlog. (note: these functions will free the pcb given as an argument and return a smaller listener pcb (e.g. tpcb = tcp_listen(tpcb)))
  5. Call tcp_accept to specify the function to be called when a new connection arrives. Note that there is no possibility of a socket being accepted before specifying the callback, because this is all run on the tcpip_thread.


tcp_new creates a temporary PCB

calling tcp_listen pasing the temporary PCB as argument.


tcp_listen returns a new PCB, server PCB.


every connection creates a temporary PCB until the connection is closed. the above server PCB

is never freed and stays live until the listening socket is closed.


The call to tcp_accepted with the server PCB !!



BR,

Noam.



From: lwip-users <lwip-users-bounces+address@hidden> on behalf of goldsimon <address@hidden>
Sent: Monday, June 27, 2016 8:22 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] Correct way to free pbufs after tcp_recv callback finished
 

Please read doc/rawapi.txt where this is documented.

Noam, I'm a bit confused. The PCB passed to the recv callback should be the one passed to tcp_recved. To handle the listen callback, this is different...

Simon

Gesendet mit AquaMail für Android
http://www.aqua-mail.com

www.aqua-mail.com
An app for personal and corporate email, Android 4.0.3+. Easy automatic setup for popular email services: Gmail, Yahoo, Hotmail, FastMail, Apple mail services (@me ...

Am 27. Juni 2016 5:31:01 nachm. schrieb Noam Weissman <address@hidden>:

Hi,


You need to call pbuf_free(pcb) after you finish processing the data.


Also you need to call tcp_recived after you handled the data. You call it NOT

with the pcb that you get inside the recv call back but rather your SERVER pcb.

The one created after calling listen.


I am not at my working PC so I cannot add an example but search around you

will see what I mean.


BR,

Noam.




From: lwip-users <lwip-users-bounces+address@hidden> on behalf of Gabriel Harrison <address@hidden>
Sent: Monday, June 27, 2016 1:41 PM
To: address@hidden
Subject: [lwip-users] Correct way to free pbufs after tcp_recv callback finished
 

Hi,

 

We’ve started our first lwIP project, following the instructions on http://lwip.wikia.com/wiki/Raw/TCP to create our high level functions and taking the device level IRQ functions and ethernetif.c from the SDK for our chip (Freescale Kinetis K60)

lwip.wikia.com
Initialization Edit. lwip_init() must be called before any tcp functions are called. void tcp_tmr(void) After lwip_init() is called, you must call tcp_tmr ...

 

Although we appear to have set things up correctly – we can send & receive requests – the TCP pbufs pool is not running out and it looks like they are not being freed after the receive has been processed.

 

I can see in tcp_recv_null in tcp.c that pbuf_free(p); is called after tcp_recved(pcb, p->tot_len); but I can’t find any info about freeing the pbufs in the wiki via either pbuf_free or pbuf_free_callback.

 

Should I be calling pbuf_free/ pbuf_free_callback in our receive callback or is this supposed to be handled elsewhere?

 

Thanks,

 

Gabriel


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________
_______________________________________________
lwip-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users

reply via email to

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