[Top][All Lists]

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

Re: [lwip-devel] Closing connections with rawapi

From: pek
Subject: Re: [lwip-devel] Closing connections with rawapi
Date: Mon, 05 May 2014 09:11:56 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux)

address@hidden (Valery Ushakov) writes:

> Per Knytt <address@hidden> wrote:
>> What is the proper way to free an allocated pcb when tcp_connect()
>> fails? I tried to use tcp_abort() since if tcp_connect() fails due to
>> lack of memory then tcp_close() might fail for that reason as
>> well. However, when tcp_connect() fails it leaves the pcb on
>> tcp_bound_pcbs and tcp_abort() does not remove it from there, it just
>> frees it, leading to invalid memory accesses down the line.
>> Is it unreasonable to use tcp_abort() to clean up from tcp_connect()
>> failures or is this a bug?
> From source inspection, calling tcp_close() on a pcb that failed
> tcp_connect() should be ok, since pcb remains in CLOSED state and
> tcp_close() just drops the pcb from the bound list and frees the pcb.

So is your recommendation that the documentation should state that
tcp_close() should be used in this case?  Once rawapi.txt states that
tcp_close() cannot fail on an unconnected pcb it's a contract that
tcp_close() must follow in the future as well.  If this is unproblematic
it seems like a reasonable solution IMO.

Per Knytt

reply via email to

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