fuimaz / spserver

Automatically exported from code.google.com/p/spserver
Other
0 stars 0 forks source link

Memory leak in Sp_httpServer #13

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. create sp_httpserver using the new method in main thread
2. Start the sp_httpserver in an another thread user method run
3. close the sp_hrrpserver in main thread

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?
windows XP ver spserver-0.9.2

Please provide any additional information below.

I have tested the sample program but there is no memory leak!
thank you!

Original issue reported on code.google.com by zl110...@163.com on 18 Feb 2009 at 3:26

GoogleCodeExporter commented 9 years ago
code:
DWORD  WINAPI StartServer(LPVOID para)
{
    SP_IocpServer* pServer = (SP_IocpServer*)para;
    pServer->run();
    while (pServer->isRunning())
    {
        Sleep(1000);
    }
    return 0;
}

void CHostListView::OnStartlisten() 
{
    int port = 80, maxThreads = 50;
    const char * serverType = "hahs";

    if( 0 != sp_initsock() ) ASSERT( 0 );
    m_pIocpServer = 
        new SP_IocpServer( "", port, new SP_HttpHandlerAdapterFactory( new
CHttpServerHandlerFactory(this->m_hWnd) ) );
    m_pIocpServer->setTimeout( 60 );
    m_pIocpServer->setMaxThreads( maxThreads );
    m_pIocpServer->setReqQueueSize( 100, "HTTP/1.1 500 Sorry, server is busy
now!\r\n" );
    DWORD dwThreadId1;
    m_hStartServerThread = CreateThread( NULL, 0, StartServer,
(LPVOID)(m_pIocpServer), 0, &dwThreadId1 );
    sp_closelog();
}
close:
    if (m_pIocpServer)
    {
        if (m_pIocpServer->isRunning())
        {
            m_pIocpServer->shutdown();
        }
        WaitForSingleObject(m_hStartServerThread,INFINITE);
        delete m_pIocpServer;
    }

Original comment by zl110...@163.com on 18 Feb 2009 at 3:31

GoogleCodeExporter commented 9 years ago
I used in mfc program there is memory leak,but in the console program there is 
none!

Original comment by zl110...@163.com on 20 Feb 2009 at 12:42

GoogleCodeExporter commented 9 years ago

Original comment by stephen....@gmail.com on 26 Feb 2009 at 7:25