httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brian Havard" <bri...@kheldar.apana.org.au>
Subject Re: cvs commit: apache-2.0/src/lib/apr/misc/unix errorcodes.c
Date Sun, 28 May 2000 08:36:34 GMT
On 27 May 2000 21:40:18 -0000, rbb@locus.apache.org wrote:

>rbb         00/05/27 14:40:18
>
>  Modified:    src/lib/apr/dso/unix dso.c
>               src/lib/apr/include apr_dso.h
>               src/lib/apr/misc/unix errorcodes.c
>  Log:
>  Fix the dso error handling.

I don't really like this. It may make sense when using dl but as someone
else pointed out, dl is only one of many possible module loading APIs.
Because ap_dso_error() takes no parameters it has to rely entirely on
global data which has got to be bad in a multithreading library. If you
need to construct the string in ap_dso_error() it also forces you to return
a global buffer. Bleugh!

My proposal:

1) ap_dso_load() should always return the OS error code associated with the
failure. If there isn't one I guess AP_EDSOLOAD will have to do.

2) ap_dso_error() should take an ap_dso_handle_t which can have error
details stored in it. It should also take a buffer & buflen like
ap_strerror() does to avoid memory leakage/static buffers.

3) The application calls ap_dso_error() with the failed ap_dso_handle_t
instead of ap_strerror(). ap_strerror() will just say something like "DSO
load failed" if it gets passed AP_EDSOLOAD.

Of course the downside is that the application has to use a different
function to get the best error message but I think it's worth it given that
some platforms have useful string information associated with a module load
failure.


>  Revision  Changes    Path
>  1.14      +11 -0     apache-2.0/src/lib/apr/dso/unix/dso.c
>  
>  Index: dso.c
>  ===================================================================
>  RCS file: /home/cvs/apache-2.0/src/lib/apr/dso/unix/dso.c,v
>  retrieving revision 1.13
>  retrieving revision 1.14
>  diff -u -r1.13 -r1.14
>  --- dso.c	2000/05/26 16:24:07	1.13
>  +++ dso.c	2000/05/27 21:40:17	1.14
>  @@ -133,3 +133,14 @@
>       
>       return APR_SUCCESS;
>   }
>  +
>  +char *ap_dso_error(void)
>  +{
>  +#if defined(HPUX) || defined(HPUX10) || defined(HPUX11)
>  +    return strerror(errno);
>  +#elif defined(HAVE_DYLD)
>  +    return NULL;
>  +#else
>  +    return dlerror();
>  +#endif
>  +}





-- 
 ______________________________________________________________________________
 |  Brian Havard                 |  "He is not the messiah!                   |
 |  brianh@kheldar.apana.org.au  |  He's a very naughty boy!" - Life of Brian |
 ------------------------------------------------------------------------------


Mime
View raw message