httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@covalent.net
Subject Re: cleanups returning void
Date Sat, 20 May 2000 05:23:38 GMT
On Fri, 19 May 2000, Roy T. Fielding wrote:

> Oh yeah, this commit reminded me of what I was going to ask yesterday.
> 
> At some point all of the cleanup functions were modified to return
> an ap_status_t, even though we have never had any use for returning
> such a thing in a cleanup.  I would prefer that it be changed back
> to returning void everywhere (like in 1.3).  I can make the changes,
> but I wanted to ask first if their was a future plan for using the
> return value at some point, or if this is just a leftover from the
> days when it was believed that all APR functions should return ap_status_t?

Well, it is left over and it isn't.  Let me give an example.  ap_close(),
which closes a file, uses the function registered as the cleanup to
actually close the file.  This way, we don't duplicate code all over the
place.  Since it is possible for close to fail (it can return EBADF on
Linux), ap_close should take that into account.  Having cleanups return an
ap_status_t allowed me to actually return an error when closing a
file.   The same goes for the rest of the APR types.

I see four solutions.

1) ignore errors when cleaning up APR types.
2) duplicate code so that the functions to register cleanups don't return
an error value.
3) Use a layer of indirection for cleanups (explained below)
4) leave it alone.

Since I think all of these are self-evident, except for three, here's
psuedo-code for three.

ap_status_t ap_cleanup_file(ap_file_t *fd){
...
}

void ap_cleanup_func(ap_file_t fd) {
    ap_cleanup_func(fd);
}

ap_status_t ap_close(ap_file_t *fd) {
    return ap_cleanup_file(fd);
}

ap_status_t ap_open(...)

open(...)
ap_register_cleanup(fd, ap_cleanup_func, ap_cleanup_func);
}

Since most of the cleanup functions are really small, they should be
inlined anyway (we can suggest this to the compiler as well here), but it
this removes the code duplication.

Ryan

>*
> ....Roy
> 
> 
> >rbb         00/05/19 15:39:01
> >
> >  Modified:    src/modules/mpm/mpmt_pthread scoreboard.c
> >  Log:
> >  Remove a warning when build with USE_MAINTAINER_MODE.
> 


_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------


Mime
View raw message