Archived

This forum has been archived. Please start a new discussion on GitHub.

resource disposal in shared servant

Hello, this is my first project with Ice. So I'm virtually retarded.
I've created a servant that will do a database lookup and return a simple struct of details, without maintaining any state other than a database connection. The main point being that the (expensive, IBM UniVerse on AIX) database connection will be shared. The main client at this point will be web pages, but other apps in the future. Where I am stuck is how to implement the disposal of the resource (database connection) when the clients share the servant, and none of them will explicitly destroy the servant?

If I fail to properly close the connection before the servant is disposed of, the driver throws an exception. To tide me over, I've added a 'destroy' operation on the servant which closes the conn, and closing it after each client is done, at the price that I've lost the main reason for sharing the servant.

Servant's in C#. The C# finalizer does not get called before the exception is thrown, so that's out. I'm using a locator, and I looked at ServantLocator.deactivate, but the only parameter is category. How do I id the servant in deactivate?

Am I going about this in the wrong way?

Thanks

signature added

Comments