Quoting Paul Ramsey <pramsey@refractions.net>:

> The only thing I have not heard discussed is the mechanism for closing
> connections at the end of the day. Every time a new distinct connection
> string appears, a new connection is opened, fine, and this is a
> layer-by-layer operation, so the database-specific layer object simply
> opens the connection and populates the hash appropriately.
> But the layers do not know when the whole map drawing session is over,
> only the map object knows that, so there needs to be a callback at the
> end of the map session which has the correct database-specific closing
> operations called on all the open connections. See?

That's what the array of functions is for... when the connection is first 
opened, a pointer to the function that closes it is put in the array of 
functions. Then, after all the layers are done, at the end of the program, all 
of the conections get closed:

> >> // main program closes all connections at the end
> >>      for (i=0;i<50;i++) {
> >>          if (funcs[i]) (*funcs[i])(i);  //obfuscated but working!
> >>      }
> >> }

I'm not familiar with the mapserver code, but I didn't see anything about where 
to store the actual connection identifiers. Don't we need another array, which 
is set to zero until the connection is opened, then set to the connection 
identifier after it has been opened (so that all the connections can use it) 
and then used in the final closing function to close the connection?

Chris



