public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] network problem more info
@ 2007-08-31  9:58 Rick Davis
  2007-08-31 12:27 ` Andrew Lunn
  0 siblings, 1 reply; 5+ messages in thread
From: Rick Davis @ 2007-08-31  9:58 UTC (permalink / raw)
  To: Ecos-Discuss

To try to narrow down my memory issue. I wrote a client program that just
creates a socket, connects to port 80 and then shuts down and closes the
socket. Every time I run it 32 bytes of memory is allocated. If I keep
running the application the memory is consumed. If I let thing sit for
minutes, some of the memory is returned.

I added more debug and what I am seeing is memory type M_SONAME is being
allocated twice and freed once. The sequence I am seeing is as follows.

Function        size  type  flags  address malloc'd  cyg_current_time
                                   address to free
---------------------------------------------------------------------
cyg_net_malloc:  148    5     1    0x001e0770        58571
cyg_net_malloc:   72    5     1    0x001e0710        58572
cyg_net_malloc:   20    5     1    0x001e06f0        58573
cyg_net_malloc:   16   98     1    0x001e06d0        58574
cyg_net_free:          98          0x001e06d0        58576
cyg_net_malloc:   16   98     8    0x001e06d0        58577
cyg_net_free:           5          0x001e06f0        91872
cyg_net_free:           5          0x001e0710        91872
cyg_net_free:           5          0x001e0770        91873

As you can see, 5 malloc, 4 free. The one not freed is type 98 (M_SONAME)


Rick Davis



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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [ECOS] network problem more info
  2007-08-31  9:58 [ECOS] network problem more info Rick Davis
@ 2007-08-31 12:27 ` Andrew Lunn
  2007-08-31 12:40   ` Rick Davis
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Lunn @ 2007-08-31 12:27 UTC (permalink / raw)
  To: Rick Davis; +Cc: Ecos-Discuss

On Fri, Aug 31, 2007 at 05:57:51AM -0400, Rick Davis wrote:
> To try to narrow down my memory issue. I wrote a client program that just
> creates a socket, connects to port 80 and then shuts down and closes the
> socket. Every time I run it 32 bytes of memory is allocated. If I keep
> running the application the memory is consumed. If I let thing sit for
> minutes, some of the memory is returned.

This part is normal behaviour. The server socket is not closed
immediately. It hangs around for a while so that it can eat any old
retry packets for the connection which are still flying around the
network. What you don't want is these old packets being injected into
a new connection stream.

What you need to do is run the test as before. Then stop the client
and watch the memory usage. It should slowly decrease as these old
sockets are freed after a timeout. Once it is stopped freeing, reached
a steady state, you can then investigate what looks like lost memory.

You probably want to go searching in the ecos mail archive, eg:

http://ecos.sourceware.org/ml/ecos-discuss/2003-10/msg00380.html

and

http://www.cygwin.com/ml/ecos-discuss/2003-12/msg00181.html

  Andrew

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [ECOS] network problem more info
  2007-08-31 12:27 ` Andrew Lunn
@ 2007-08-31 12:40   ` Rick Davis
  2007-08-31 12:47     ` Andrew Lunn
  2007-08-31 14:03     ` Alok Singh
  0 siblings, 2 replies; 5+ messages in thread
From: Rick Davis @ 2007-08-31 12:40 UTC (permalink / raw)
  To: 'Andrew Lunn'; +Cc: 'Ecos-Discuss'

Andrew,

I finally found the problem.

Bsd_accept in net\bsd_tcpip\current\src\sys\kern\sockio.c wasn't freeing sa.

Add the following at or around line 447. It has "done:" label on the "#else"
portion of an "#if 0"

	if (sa)
 		FREE (sa, M_SONAME);

Rick Davis


-----Original Message-----
From: Andrew Lunn [mailto:andrew@lunn.ch] 
Sent: Friday, August 31, 2007 8:27 AM
To: Rick Davis
Cc: Ecos-Discuss
Subject: Re: [ECOS] network problem more info

On Fri, Aug 31, 2007 at 05:57:51AM -0400, Rick Davis wrote:
> To try to narrow down my memory issue. I wrote a client program that just
> creates a socket, connects to port 80 and then shuts down and closes the
> socket. Every time I run it 32 bytes of memory is allocated. If I keep
> running the application the memory is consumed. If I let thing sit for
> minutes, some of the memory is returned.

This part is normal behaviour. The server socket is not closed
immediately. It hangs around for a while so that it can eat any old
retry packets for the connection which are still flying around the
network. What you don't want is these old packets being injected into
a new connection stream.

What you need to do is run the test as before. Then stop the client
and watch the memory usage. It should slowly decrease as these old
sockets are freed after a timeout. Once it is stopped freeing, reached
a steady state, you can then investigate what looks like lost memory.

You probably want to go searching in the ecos mail archive, eg:

http://ecos.sourceware.org/ml/ecos-discuss/2003-10/msg00380.html

and

http://www.cygwin.com/ml/ecos-discuss/2003-12/msg00181.html

  Andrew


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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [ECOS] network problem more info
  2007-08-31 12:40   ` Rick Davis
@ 2007-08-31 12:47     ` Andrew Lunn
  2007-08-31 14:03     ` Alok Singh
  1 sibling, 0 replies; 5+ messages in thread
From: Andrew Lunn @ 2007-08-31 12:47 UTC (permalink / raw)
  To: Rick Davis; +Cc: 'Ecos-Discuss'

On Fri, Aug 31, 2007 at 08:40:18AM -0400, Rick Davis wrote:
> Andrew,
> 
> I finally found the problem.
> 
> Bsd_accept in net\bsd_tcpip\current\src\sys\kern\sockio.c wasn't freeing sa.
> 
> Add the following at or around line 447. It has "done:" label on the "#else"
> portion of an "#if 0"
> 
> 	if (sa)
>  		FREE (sa, M_SONAME);
> 

Sorry, but that is not clear. Please produce a real patch.

       Andrew

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [ECOS] network problem more info
  2007-08-31 12:40   ` Rick Davis
  2007-08-31 12:47     ` Andrew Lunn
@ 2007-08-31 14:03     ` Alok Singh
  1 sibling, 0 replies; 5+ messages in thread
From: Alok Singh @ 2007-08-31 14:03 UTC (permalink / raw)
  To: Rick Davis, Andrew Lunn; +Cc: Ecos-Discuss

Rick,

This is already solved in current cvs code net package. Please have a
look at the CVS code.

regards,
Alok
-----Original Message-----
From: ecos-discuss-owner@ecos.sourceware.org
[mailto:ecos-discuss-owner@ecos.sourceware.org] On Behalf Of Rick Davis
Sent: Friday, August 31, 2007 6:10 PM
To: 'Andrew Lunn'
Cc: 'Ecos-Discuss'
Subject: RE: [ECOS] network problem more info

Andrew,

I finally found the problem.

Bsd_accept in net\bsd_tcpip\current\src\sys\kern\sockio.c wasn't freeing
sa.

Add the following at or around line 447. It has "done:" label on the
"#else"
portion of an "#if 0"

	if (sa)
 		FREE (sa, M_SONAME);

Rick Davis


-----Original Message-----
From: Andrew Lunn [mailto:andrew@lunn.ch] 
Sent: Friday, August 31, 2007 8:27 AM
To: Rick Davis
Cc: Ecos-Discuss
Subject: Re: [ECOS] network problem more info

On Fri, Aug 31, 2007 at 05:57:51AM -0400, Rick Davis wrote:
> To try to narrow down my memory issue. I wrote a client program that
just
> creates a socket, connects to port 80 and then shuts down and closes
the
> socket. Every time I run it 32 bytes of memory is allocated. If I keep
> running the application the memory is consumed. If I let thing sit for
> minutes, some of the memory is returned.

This part is normal behaviour. The server socket is not closed
immediately. It hangs around for a while so that it can eat any old
retry packets for the connection which are still flying around the
network. What you don't want is these old packets being injected into
a new connection stream.

What you need to do is run the test as before. Then stop the client
and watch the memory usage. It should slowly decrease as these old
sockets are freed after a timeout. Once it is stopped freeing, reached
a steady state, you can then investigate what looks like lost memory.

You probably want to go searching in the ecos mail archive, eg:

http://ecos.sourceware.org/ml/ecos-discuss/2003-10/msg00380.html

and

http://www.cygwin.com/ml/ecos-discuss/2003-12/msg00181.html

  Andrew


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




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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-08-31 14:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-31  9:58 [ECOS] network problem more info Rick Davis
2007-08-31 12:27 ` Andrew Lunn
2007-08-31 12:40   ` Rick Davis
2007-08-31 12:47     ` Andrew Lunn
2007-08-31 14:03     ` Alok Singh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).