lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] LwIP TCP Server crashes after two accepted connections


From: Sergio R. Caprile
Subject: Re: [lwip-users] LwIP TCP Server crashes after two accepted connections simultaneously
Date: Mon, 18 Feb 2019 11:38:11 -0300
User-agent: Mozilla/5.0 (Windows NT 6.1; rv:60.0) Gecko/20100101 Thunderbird/60.5.1

lwIP202 v1.1 What is that ? That doesn't look like lwIP versioning scheme.
Where do you get that "message" about being unable to alloc pbuf in
recv_handler" ? There is no recv_handler in lwIP. That looks like a
driver that runs out of memory, as if you are not releasing your alloced
pbufs "somewhere".

Your tcp_accept call looks OK to me.

What do you mean by "when I receive FIN" ? You either get your error or
receive callback being called.
Your receive callback has to check for a null pbuf or (err != ERR_OK),
since it can be a disconnect indication. THEN, you will call tcp_close().
The argument to tcp_close() is the 'pcb' passed by lwIP to your function:
        static err_t myrecv(void *arg, struct tcp_pcb* pcb, struct pbuf *p,
err_t err)
AFAIK you only call tcp_abort() if you are not ready (for whatever
reason) to handle the data, and then you return ERR_ABRT; otherwise you
return ERR_OK even if you just called tcp_close(). You do not call both
functions, you either call one or the other.
Are you checking tcp_close return value ? quote: "The function may
return ERR_MEM if no memory was available for closing the connection. If
so, the application should wait and try again either by using the
acknowledgment callback or the polling functionality. If the close
succeeds, the function returns ERR_OK."

On your error callback, you will not call tcp_close() (you don't have
'pcb' as an argument, so I guess you are not doing it, are you ?)

And what about your sent callback ? You say you "send a hello message",
do you have a sent callback or are you relying on a default ? How is
your memory allocation ? Do you keep tx pool and rx pool separate
(recommended) ?



reply via email to

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