This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Socket leak when accept() is aborted by TCP RST?


On 2010-07-28, Andrew Lunn <andrew@lunn.ch> wrote:
> On Wed, Jul 28, 2010 at 07:56:41PM +0000, Grant Edwards wrote:
>> On 2010-07-28, Grant Edwards <grant.b.edwards@gmail.com> wrote:
>> > On 2010-07-27, Grant Edwards <grant.b.edwards@gmail.com> wrote:
>> >
>> >> I'm seeing what appears to me to be a socket leak in the accept()
>> >> operation provided by the "new" BSD network stack.
>> >
>> > The stack is definitely leaking sockets.  I can now reliably reproduce
>> > the problem by opening a TCP connection and then immediately causing a
>> > TCP reset.
>> 
>> AFAICT, the leak occurs in kern/sockio.c in bsd_accept():
>
> This makes sense. This is eCos code, not code taken directly from
> FreeBSD.
>
>> When an error is returned, the accept() function in
>> io/fileio//socket.cxx frees the file pointer and file descriptor but
>> not the socket:
>
> I would not expect it to. It does not know anything about sockets,
> they are internal to the stack.
>
>> So, nowhere does the socket get freed.  
>
>> Where should the socket be freed?  In bsd_accept() where it is removed
>> from the queue?  Or in socket.cxx when the fd/fp are freed?
>
> I would say in bsd_accept(). However, it would be good to find the
> FreeBSD code equivalent

No luck on that so far....

> of this code and see where it frees the
> socket.

I've tried adding sofree(so) and soclose(so) in the noconnection path
of bsd_accept(), and neither fixes the problem.

-- 
Grant Edwards               grant.b.edwards        Yow! I'm having fun
                                  at               HITCHHIKING to CINCINNATI
                              gmail.com            or FAR ROCKAWAY!!


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]