February 05, 2007

Socket Server code: AcceptEx server memory leak

The latest version of the licensed socket server framework contains a memory leak in the CSocketServerEx class. It's quite a good leak, it leaks an IO buffer on every connection attempt. The fix is as follows:

Change this code:

void CStreamSocketServerEx::PostAcceptRequest()
{
if (m_listeningSocket != INVALID_SOCKET)
{
if (m_connectionLimiter.CanCreateConnection())
{
IncrementPendingReceives();

const IFullAddress &address = GetAddress();

IStreamSocketEx *pSocket = AllocateSocket(CreateSocket(address.Type())).Detach();

IBuffer *pBuffer = AllocateBuffer();

pBuffer->SetUserPtr(m_socketIndex, pSocket);

PostIoOperation(pBuffer, IO_Accept_Request);
}
else

to this:

void CStreamSocketServerEx::PostAcceptRequest()
{
if (m_listeningSocket != INVALID_SOCKET)
{
if (m_connectionLimiter.CanCreateConnection())
{
IncrementPendingReceives();

const IFullAddress &address = GetAddress();

IStreamSocketEx *pSocket = AllocateSocket(CreateSocket(address.Type())).Detach();

CSmartBuffer buffer(AllocateBuffer());

buffer.Get()->SetUserPtr(m_socketIndex, pSocket);

PostIoOperation(buffer.Get(), IO_Accept_Request);
}
else



Share this entry: Email it! | bookmark it! | digg it! | reddit!

Posted by Len at February 5, 2007 10:21 AM | Comments (6) | Categories : Socket Servers
Comments

Hi!
How can I obtain the licensed version of the socketserver framework? I didn't find any detail in the blog.

Posted by: Dennis Hopper at February 7, 2007 07:52 AM

I'll email you details.

Posted by: Len at February 7, 2007 09:52 AM

Hi,

I am interested in your licensed sockerserver framework as well. Can you send me the details too?

Posted by: Ricky at February 9, 2007 11:23 AM

Could you email me the details of your licensed socket server and the price?

thank you!

Posted by: hiber at February 9, 2007 03:37 PM

Howa about the free version?Does the same bug exit?

Posted by: at March 1, 2007 11:30 AM

The free version of the acceptex server hasnt been updated from the original source code and I no longer support it. I've no idea if the bug exists in that version of the code.

Posted by: Len at March 2, 2007 12:37 AM
Post a comment









Remember personal info?




Enter this code in the box below to prove that you're not some kind of automated spam robot...