On 5 June 2012 09:26, Hosanna Higher Technologies Support
<[email protected]> wrote:
> Then in destructor I call the close method
>
> m_session.close();
>
> But When I use the class few times (creating and destroying objects of this
> class) I find that soci fails to connects to MySQL server with error too
> many connections. I'm confused since I call the close method on destructor,
> I suppose that soci should release the connection.

The session::close destroys the concrete session object, namely
mysql_session_backend in your case.
Destructor of mysql_session_backend calls mysql_close and
releases the connection:

void mysql_session_backend::clean_up()
{
    if (conn_ != NULL)
    {
        mysql_close(conn_);
        conn_ = NULL;
    }
}

So, in theory it looks OK, but...

Could you check if you get the mysql_close called at all?
I don't have MySQL instance to test.

There is one more thing, the constructor of mysql_session_backend
calls mysql_init,
so every time you create new session object, mysql_init gets called.
I'm not experienced with MySQL, but according to this discussion
"init will create a new connection" thus mysql_init should be called once

http://forums.mysql.com/read.php?52,424083,424189#msg-424189

I may be misinterpreting here, so I hope Pawel will have accurate insights.

Best regards,
-- 
Mateusz Loskot, http://mateusz.loskot.net

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users

Reply via email to