Re: bonobo-activation; freeing base services ...



On 26Oct2001 09:57PM (-0400), Havoc Pennington wrote:
> 
> 
> > Anyway, we are missing the main point here. Aren't shutdown functions just
> > as bad as init functions? And you are always preaching against init
> > functions. Instead of looking at atexit itself, perhaps we should be looking
> > at atexit vs. shutdown functions.
> 
> Well, several of the issues I mentioned don't apply to shutdown
> functions. 

Is this list comparing shutdown functions to init functions or to
atexit handlers? I'm assuming the latter.
 
>  - they don't surprise the app programmer

But sometimes failing to call them does - as with gnome_vfs_shutdown.

>  - the app programmer can choose not to call them

This is only good if it's safe not to call the function when you exit.

>  - no one will have the illusion that they are reliably called

I don't think most people have this illusion about atexit handlers; I
assume they are reliably called on normal exits only.

>  - they are portable

Good point though possible to work around.

>  - they do not break fork/exec

I hope people don't start thinking they can call exit() instead of
_exit() on a failed exec just because gtk has no atext() handlers, see
the note at the bottom of this page for an example of why it's still
not safe:

http://www.ntua.gr/cgi-bin/man-cgi?fork+2

>  - they don't require an init function to set up ;-)

Neither do atexit() handlers if your library does on demand initialization.


Anyway, shutdown functions which need to be called for correct
operation have all the problems of init functions and then some,
because programs start execution at only one point but may exit at
many, meaning that forgotten init function bugs may not be found right
away.


> One sane use of a shutdown function IMO is on the application level,
> you need one to do the whole "quit" thing - "are you sure you want to
> quit," and so on.

I'm not sure how that relates - some applications do need to confirm a
user request to quit, but that doesn't necessarily mean the function
that does the confirmation should need to have knoledge of all app
resources that need to be freed.

> On the library level, it'd be pretty insane if you
> had to call a shutdown function for every lib though.

The logical conclusion is that libraries must avoid needing any kind
of shutdown processing for correct operation. 

> Note that I have no idea what Michael's shutdown functions actually
> do, I haven't read the patch. 

I don't really know either. Michael, are your changes avoid leaking
remote resources or to free memory?

 - Maciej




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]