[Mono-devel-list] Releasing connections from pool

Francisco Figueiredo Jr. fxjrlists at yahoo.com.br
Wed Dec 31 09:46:04 EST 2003

Reggie Burnett wrote:
>>Hi all!
>>I'm working in getting connection pool in Npgsql.
>>But I'm facing a little problem I wasn't aware before:
>>When I close the connection, if it is being pooled, I return it back to
>>pool. Ok, but what happens when the client program exits? I mean, if it
>>specify Npgsql to use a pool, it opens a connection, close it and so
>>exits, who will release the connection from the pool?
>>I know that the Stream object handle the unmanaged tcp connection and on
>>its dispose(false) method it will release the unmanaged connection
>>cleanly, but even with this, Postgresql still logs about receiving eof
>>from the client connection.
>>I was checking the bytefx and sqlclient code about connection pool and I
>>couldn't see anything about this too. So I suppose that with their code
>>this also happens.
>>Pedro, guys, do you have any idea about that?
>>I was thinking about some way to register an eventhandler which would
>>notice me about the app domain unloading where I could check the
>>connection pool and release any connection there is in it.
>>Would this be possible? There may be some other clearer solution?
> I don't think I see the problem here.  The only unmanaged resource we are
> really concerned with is the connection to the database.  The database has
> to be able to cleanly handle a dropped connection so domain unloading will
> dispose the socket connections for us.    The rest of the pooling is
> completely managed and doesn't need disposing.
> Am I missing something obvious here?

Uhmmmm, what you said does really make sense.

I also thought this way: I could just leave the pool as it is and so the 
dispose(false) of the tcpclient object would release the unmanaged 
connection. The only problem is a side effect of this: The server logs a 
message about the EOF in the client connection. But I think this would 
be a side effect that we could live with. I think the other providers, 
like sql server does exactly this, but sql server doesn't logs about the 
eof in the client connection.

Thanks Reggie and sorry for late response.


Francisco Figueiredo Jr.

More information about the Mono-devel-list mailing list