msLayerOpen and msLayerClose

Howard Butler hobu at IASTATE.EDU
Tue Jun 6 10:21:00 EDT 2006


With connection pooling in place for drivers with heavy connection 
costs, it is imperative that we make sure that each msLayerOpen has a 
matching msLayerClose.  I found one instance in mapogcfilter.c where 
this wasn't the case, and it was causing the pooling stuff to 
complain about freeing connections where there was still a reference 
in effect.

Looking through the code, I noticed many instances where we could 
have return paths that don't close the layer.  This idiom seems to be 
very common:

     status = msLayerOpen(tlp);
     if(status != MS_SUCCESS) return(MS_FAILURE);

     status = do_some_other_operation();
     if(status != MS_SUCCESS) return(MS_FAILURE);

In this instance, the layer would not be closed if 
do_some_other_operation() fails.  In some cases this appears to be a 
catastrophic failure and not closing the layer at this point isn't a 
problem.  In others, it appears this could be a signal to go 
somewhere else.  It is the second scenario that concerns me.

In addition, for some drivers, opening and closing the layer many 
times can have significant overhead.  Would it be beneficial to have 
a create/delete pair that actually does the construction/destruction 
of a layer?  Could we somehow ensure that this only happens once 
through the life cycle of a mapObj (or explicitly created/destroyed 
through MapScript)?  Would this improve the situation at all or just 
push the problem somewhere else?

Thoughts, concerns, cheers, and jeers welcomed.


More information about the mapserver-dev mailing list