From: Sean Chittenden Date: 2002-10-09T10:23:46+09:00 Subject: Re: mod_ruby post-request cleanup [moving to modruby@modruby.net, remove ruby-talk from the address on reply] > I'm trying to keep a pool of database connections persistent across > requests. > > I'm doing this via a class variable containing an hash of > datasources that are known about. Each hash entry contains an array > of connections (which are intended to be reused across requests). > This actually all sits inside another class, that handles the > determination of what datasources are loaded up, based on an XML > configuration file, in case that's important. Nope, shouldn't be. > Somehow, the hash seems to be losing the keys from session to > session, meaning I'm re-connecting to the database all the time. As > I say, this feels like some kind of silly bug, but ... Try using a global variable instead of a class variable. Are you using apache/reload.rb? If you reload the class, the old class's class variables should get nuked. > Just after sending the page back, via CGI.out(), I'm printing out > what keys are in the hash, and I can see the one I expect. However, > at the start of the next request, while the class variable still > exists (and has the same address), the keys seem to be gone. This smells like it could be bugish... I wonder if the hash is being marked with rb_gc_mark() instead of rb_gc_mark_children(). I wouldn't call this a bug quite yet, but it could be. > As I say, it's probably just a bug, but I figured I should check > whether mod_ruby does some kind of cleanup of non-class variables at > the end of each request, that I might be falling foul of. Nothing specifically for non-class variables that are outside of normal scope rules. > I'm going to do some tests with something simpler, but I'd prefer to > save myself some messing about if there's something mod_ruby is > doing that I don't know about. It's possible. -sc -- Sean Chittenden