I would just suggest that if you have RTOS, tasks/threads, queues etc then
using netconn/socket API might be better choice (they use message passing,
queues and semaphores to make programming easier, and I think that using
tcpip_callback tcpip_callback_with_blocking to reimplement this
functionality should be considered after trying to use multithreaded APIs).

Regards,
Krzysztof Wesołowski,
tel. +48 721 337 238

On Thu, Jun 4, 2015 at 2:34 PM, Jan Menzel <[email protected]> wrote:

> Hi Noam!
>         From earlier discussion on this list, I learned that for this
> purpose
> one may schedule a callback into the LWIPs internal task using
> tcpip_callback() or tcpip_callback_with_blocking(). Both queue your
> function and its arguments for execution from within the main Lwip task
> context. I'm not sure if this is applicable here, but if so, I would
> favour the callback solution as yours might introduce dead locks in case
> tcp_sndbuf() blocks. This type of errors are comparably difficult to
> find and likely to happen if eg. an other task is used to free buffers
> after transmission completed.
>
>         Jan
>
> On 04.06.2015 14:18, Noam weissman wrote:
> > Hi,
> >
> > PROBLEM SOLVED :-)
> >
> > As mentioned earlier by Sergio we should not call LwIP code from within
> > other threads.
> >
> > I must call tcp_write and other functions from a separate thread. This
> > is the implementation.
> >
> > My TCP stack has the highest task priority in the system.  As a result
> > calling tcp_write or any other
> > LwIP function may cause unpredictable LwIP internal code problems.
> >
> > I added  taskENTER_CRITICAL(); and taskEXIT_CRITICAL();
> > Function calls to the portion of code that call tcp_write etc.. this
> > synchronizes the threads
> > Interaction and solved the problem I faced completely.
> >
> > For example:
> >
> >       taskENTER_CRITICAL();
> >       {
> >           AvailableSpace = tcp_sndbuf(ts->pcb);
> >       }
> >       taskEXIT_CRITICAL();
> >
> >
> > Thanks for your insight.
> >
> > BR,
> > Noam.
> >
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[email protected]] On Behalf Of
> > Sergio R. Caprile
> > Sent: Thursday, June 04, 2015 12:02 AM
> > To: [email protected]
> > Subject: Re: [lwip-users] memory leak ?
> >
> > Tx: yes
> > Rx: if you free them properly then they shouldn't be scarce. Have you
> > tested this ?
> >
> > I'm not familiar with lwIP under RTOS except that you must adhere to the
> > general rule of not calling the stack from different threads.
> > You should check your port with a known good application first. Try
> > echo, for example, or netio; both are available in the contrib tree (and
> > there is nice patch for netio sent by youknowho)
> >
> >
> > _______________________________________________
> > lwip-users mailing list
> > [email protected]
> > https://lists.nongnu.org/mailman/listinfo/lwip-users
> >
> >
> >
> > ************************************************************************
> > ************
> > This footnote confirms that this email message has been scanned by
> > PineApp Mail-SeCure for the presence of malicious code, vandals &
> > computer viruses.
> > ************************************************************************
> > ************
> >
> >
> >
> >
> >
> >
> >
> ************************************************************************************
> > This footnote confirms that this email message has been scanned by
> > PineApp Mail-SeCure for the presence of malicious code, vandals &
> computer viruses.
> >
> ************************************************************************************
> >
> >
> >
> >
> > _______________________________________________
> > lwip-users mailing list
> > [email protected]
> > https://lists.nongnu.org/mailman/listinfo/lwip-users
> >
>
> _______________________________________________
> lwip-users mailing list
> [email protected]
> https://lists.nongnu.org/mailman/listinfo/lwip-users
>
_______________________________________________
lwip-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to