You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by bj...@locus.apache.org on 2000/03/27 05:18:20 UTC

cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c dso.h

bjh         00/03/26 19:18:20

  Modified:    src/lib/apr/dso/os2 Makefile.in dso.c dso.h
  Log:
  Clean up OS/2 DSO code so it at least compiles.
  
  Revision  Changes    Path
  1.2       +8 -11     apache-2.0/src/lib/apr/dso/os2/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/dso/os2/Makefile.in,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Makefile.in	2000/03/26 20:53:33	1.1
  +++ Makefile.in	2000/03/27 03:18:20	1.2
  @@ -3,6 +3,7 @@
   #INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES)
   #LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS)
   
  +SHELL=@SH@
   CC=@CC@
   RANLIB=@RANLIB@
   CFLAGS=@CFLAGS@ @OPTIM@
  @@ -41,20 +42,16 @@
   depend:
   	cp Makefile.in Makefile.in.bak \
   	    && sed -ne '1,/^# DO NOT REMOVE/p' Makefile.in > Makefile.new \
  -	    && gcc -MM $(INCLUDES) $(CFLAGS) *.c >> Makefile.new \
  +	    && gcc -MM $(INCLUDES) $(CFLAGS) *.c | sed -e "s%\\\\\(.\)%/\\1%g" >> Makefile.new \
   	    && sed -e '1,$$s: $(INCDIR)/: $$(INCDIR)/:g' \
   	           -e '1,$$s: $(OSDIR)/: $$(OSDIR)/:g' Makefile.new \
   		> Makefile.in \
   	    && rm Makefile.new
   
   # DO NOT REMOVE
  -getopt.o: getopt.c misc.h ../../include/apr_config.h \
  - ../../include/apr_general.h ../../include/apr.h \
  - ../../include/apr_errno.h ../../include/apr_pools.h \
  - ../../include/apr_lib.h ../../include/apr_file_io.h \
  - ../../include/apr_getopt.h
  -start.o: start.c misc.h ../../include/apr_config.h \
  - ../../include/apr_general.h ../../include/apr.h \
  - ../../include/apr_errno.h ../../include/apr_pools.h \
  - ../../include/apr_lib.h ../../include/apr_file_io.h \
  - ../../include/apr_getopt.h
  +dso.o: dso.c dso.h $(INCDIR)/apr_config.h \
  + $(INCDIR)/apr_general.h $(INCDIR)/apr.h \
  + $(INCDIR)/apr_errno.h $(INCDIR)/apr_pools.h \
  + $(INCDIR)/apr_lib.h $(INCDIR)/apr_file_io.h \
  + $(INCDIR)/apr_time.h $(INCDIR)/apr_thread_proc.h \
  + $(INCDIR)/apr_dso.h
  
  
  
  1.2       +2 -2      apache-2.0/src/lib/apr/dso/os2/dso.c
  
  Index: dso.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/dso/os2/dso.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- dso.c	2000/03/26 20:53:33	1.1
  +++ dso.c	2000/03/27 03:18:20	1.2
  @@ -54,7 +54,7 @@
    *
    */
   
  -#include "misc.h"
  +#include "dso.h"
   #define INCL_DOS
   #include <os2.h>
   #include <stdio.h>
  @@ -71,7 +71,7 @@
       HMODULE handle;
       int rc;
   
  -    if((rc = DosLoadModule(somebuf, sizeof(somebuf), path, &handle)) != 0)
  +    if ((rc = DosLoadModule(somebuf, sizeof(somebuf), path, &handle)) != 0)
         return APR_EINIT;
   
       *res_handle = ap_pcalloc(ctx, sizeof(*res_handle));
  
  
  
  1.2       +5 -2      apache-2.0/src/lib/apr/dso/os2/dso.h
  
  Index: dso.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/dso/os2/dso.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- dso.h	2000/03/26 20:53:33	1.1
  +++ dso.h	2000/03/27 03:18:20	1.2
  @@ -57,6 +57,9 @@
   #ifndef DSO_H
   #define DSO_H
   
  +#define INCL_DOS
  +#include <os2.h>
  +
   #include "apr_config.h"
   #include "apr_general.h"
   #include "apr_pools.h"
  @@ -64,7 +67,7 @@
   
   struct ap_dso_handle_st {
       HMODULE       handle;     /* Handle to the DSO loaded            */
  -    ap_context_t  cont;       /* Context for returning error strings */
  +    ap_context_t  *cont;       /* Context for returning error strings */
   };
   
  -#endif
  \ No newline at end of file
  +#endif
  
  
  

Re: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c dso.h

Posted by rb...@apache.org.
I would much prefer to keep the docs with the code.  What we really need
is a simple script to extract the docs and put them into HTML.  People
talked about just using javadoc to do this, but I never got arround to
looking into it.

The reason I would like to keep the docs where they are, is it is much
more likely to keep the docs in synch with the code.Whenever I edit the
unix code, I check the docs and update them if needed.  If the docs aren't
with the code, I tend to forget to do this.

Ryan

On Mon, 27 Mar 2000, Tony Finch wrote:

> rbb@apache.org wrote:
> >
> >BTW, are there are docs in the unix source yet?  (hint, hint, if they
> >aren't there).
> 
> Would the docs be better htmlized and kept in manual/developer, or do
> people prefer to keep them where they are now?
> 
> Tony.
> -- 
> f.a.n.finch    fanf@demon.net    dot@dotat.at
> 355 pinking shear tracheotomy
> 


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


Re: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c dso.h

Posted by Tony Finch <do...@dotat.at>.
rbb@apache.org wrote:
>
>BTW, are there are docs in the unix source yet?  (hint, hint, if they
>aren't there).

Would the docs be better htmlized and kept in manual/developer, or do
people prefer to keep them where they are now?

Tony.
-- 
f.a.n.finch    fanf@demon.net    dot@dotat.at
355 pinking shear tracheotomy

Re: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c dso.h

Posted by rb...@apache.org.
I'm fixing these right now.

Ryan

On Mon, 27 Mar 2000, David Reid wrote:

> That's true, and I'll fix it before too long.  Also I think some changes to
> the way the types are defined may be in order, but I'll let you know about
> that.
> 
> d.
> ----- Original Message -----
> From: "Brian Havard" <br...@kheldar.apana.org.au>
> To: <ne...@apache.org>
> Sent: Monday, March 27, 2000 1:19 PM
> Subject: Re: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c
> dso.h
> 
> 
> > On Mon, 27 Mar 2000 10:27:58 +0100, David Reid wrote:
> >
> > >Yes, I only cut/pasted to get the code in place.  Hope it wasn't too much
> > >grief!
> >
> > Nah, only took a few minutes. One thing I would like to point out
> > though is that the function args for ap_status_t ap_dso_load() don't
> > don't match the usual APR rules (result first, context last).
> >
> >
> >
> > >----- Original Message -----
> > >From: <bj...@locus.apache.org>
> > >To: <ap...@apache.org>
> > >Sent: Monday, March 27, 2000 4:18 AM
> > >Subject: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c
> dso.h
> > >
> > >
> > >> bjh         00/03/26 19:18:20
> > >>
> > >>   Modified:    src/lib/apr/dso/os2 Makefile.in dso.c dso.h
> > >>   Log:
> > >>   Clean up OS/2 DSO code so it at least compiles.
> >
> > --
> >
> ____________________________________________________________________________
> __
> >  |  Brian Havard                 |  "He is not the messiah!
> |
> >  |  brianh@kheldar.apana.org.au  |  He's a very naughty boy!" - Life of
> Brian |
> >  -------------------------------------------------------------------------
> -----
> >
> >
> 
> 


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


Re: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c dso.h

Posted by Manoj Kasichainula <ma...@io.com>.
On Tue, Mar 28, 2000 at 10:15:39AM +0100, David Reid wrote:
> I have to admit that when I was looking for a problem with opening a file
> having the error string would have been very helpful.  Perhaps Manoj's idea
> of a get_error routine for every type is the best one?  It should make
> finding the error easier and should be easy enough to implement.
> 
> I know Ryan doesn't like it though!

Just to be clear, I don't like it either (in this case, anyway). I
like ap_strerror(). I just like per-object errors better than global
or per-thread ones.


Re: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c dso.h

Posted by rb...@apache.org.
> The one true error code (errno/GetLastError()/whatever) is not always
> enough.  All that APR gives the caller is the one true error code, but
> sometimes there is additional valuable information which APR has no
> way to return.  A couple of examples of this extra information were given.

Ah, but there is no where for APR to do the logging.  You can't just log
to stderr, because on some systems (Windows), stderr doesn't exist in APR.

> > You still can't get access to this function from the one place in Apache
> > that it is useful.  
> 
> I didn't propose that Apache do anything other than give APR a
> function that APR could call when there is additional information.  I
> guess I don't understand.

But, where does the log go?  Do you also add a file pointer and Line
number to this function.

> I agree 100% that this has to be done, just as you describe.  I agree
> 99% that it handles 99% of the cases.  I even agree that it has to be
> done first.  But I've been concerned about the inability to trace all
> available diagnostic data, and when some mechanism is invented to save
> stuff like the name of the dll which caused DosLoadModule() to fail
> then I'd like to see it able to save other information as well.

Now you are designing for a problem you haven't had yet.  I would prefer
not to do this until we have actually run into this problem.

>   [Tue Mar 28 16:26:12 2000] [err] ap_bind(): bind()->13/737105AE
>   [Tue Mar 28 16:26:12 2000] [crit] (13)Permission denied: make_sock:
>   could not bind to address 0.0.0.0 port 80

This is an increbily OS/390 specific problem.  If this is what 390
wants/needs, then this needs to be put in a 390 specific directory, and
each function just logs this stuff on it's own.  Since it isn't feasible
for APR to have it's own error log, 390 could just write this stuff out to
stderr.  Regardless, this is non-portable code, and does not belong in the
unix directory.

Ryan

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



Re: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c dso.h

Posted by Jeff Trawick <tr...@bellsouth.net>.
> > Not knowing any better, I'd store a ptr in context_t.
> > 
> > i. ptr in context_t
> > 
> > context_t is available almost everywhere in APR.  
> 
> Context's aren't available when you want to output the message using
> ap_log(r)error in Apache.  All we have at that point is an error code.
> 

The ptr in context_t was a pointer to a trace function that APR could
call.  We don't care if there is no context in the trace function
itself.  There is a context in the APR function that calls the trace
function.

To restate the main problem this is trying to address:

The one true error code (errno/GetLastError()/whatever) is not always
enough.  All that APR gives the caller is the one true error code, but
sometimes there is additional valuable information which APR has no
way to return.  A couple of examples of this extra information were given.

> > 
> > struct context_t {
> >     struct ap_pool_t *pool;
> >     datastruct *prog_data;
> >     int (*apr_abort)(int retcode);
> > +   void (*apr_log_error)(int loglvl, const char *fmt, ...);
> > };     
> 
> This was discusses before, and dismissed by the group at large.  For a
> more thorough explanation of why people didn't like this (because I don't
> remember any more), look at the original design docs for APR in early
> 1999.  This was one of the original goals of the contexts BTW.
> 

I'll start looking for that discussion.

> > ii.  APR app must store ptr to log function in context_t
> > 
> > We could think about whether or not creating a new context should
> > inherit the value from the parent context (probably) so that initially
> > Apache only needs to store it once.  In the future, Apache could
> > easily choose to provide the log_error function only for certain
> > clients (CEO that can't load some obscure page?) simply by only
> > setting apr_log_error in context for certain connections (dynamic
> > reconfig and new trace specifications very helpful here).
> 
> You still can't get access to this function from the one place in Apache
> that it is useful.  

I didn't propose that Apache do anything other than give APR a
function that APR could call when there is additional information.  I
guess I don't understand.

>                        If you are planning to pass around the APR type to
> ap_log_(r)error, you will have a fight from me.  

I guess I don't understand your response.  I didn't want to change
ap_log_(r)error one iota; I guess I described poorly.  I 

>                                                  If you are planning on
> passing in the whole error string, I think you'll have a fight from some
> others.  :-)

This is kinda-sorta what I wanted to do.  I wanted APR to be able to
pass to a log function provided by the APR user (e.g., Apache) a
sprintf-style format string and its arguments.  The log function would
do the vsprintf or vsnprintf stuff, but wouldn't really care what string
was stored in the log.

> 
> > iii. selected APR code calls apr_log_error()
> > 
> > Typical APR code.  Assume this is in some os-specific file where we
> > "know" we have extra diagnostic data.
> > 
> > ap_status_t apr_do_something(struct ap_widget_t *widget, int parm, 
> > 		             struct context_t *cont)
> > {
> >     ...
> >     rc = some_kernel_call(widget->handle, parm);
> >     if (rc) {
> >         status = errno;
> >         if (cont->apr_log_error) {
> > 	    cont->apr_log_error(APR_LOG_ERROR,
> > 				"some_kernel_call() -> %d/%08X",
> > 				status, __errno2());
> > 	}
> > 	return status;
> >     }
> > 
> >     ...
> > }
> > 
> > This is extendable to any type of error.  No extra setup or checking
> > needed by the APR app.  
> > 
> > Once this is in place, it takes 2-3 lines of code to save extra
> > diagnostic information at almost any point in APR.
> 
> Now you are talking about saving the error string itself in the context.
> This was also discusses, and was sumamrily dismissed by the group last
> year.

Not at all.  I don't want that either.  

  cont->apr_log_error(APR_LOG_ERROR,"some_kernel_call() ->cont->%d/%08X",
                      status,__errno2())

doesn't store an error string in the context; instead it stores it
directly in the APR app's trace.

> 
> > 
> > iv. the APR app needs some simple trace function for APR to call
> > 
> > B. APR doesn't call a trace exit function, but instead builds a string
> >    and stores it in a widget for later retrieval
> 
> This whole idea was brought up last year, and dismissed summarily by the
> group.  Please, check the archives for early last year to get the
> reasons.

Good.  It should be obvious that I don't like that either.

> 
> > Good points of A:
> > 
> > . Once it has been made to work for one APR function, it takes very
> >   little effort to record diagnostic information in any other APR
> >   function that has context_t.  If something bad is happening*, within
> >   a minute or so the relevant APR function can be taught to do the
> >   right thing, with no changes to data structures or anything else
> >   that might have widespread effects.  There is no widget-by-widget
> >   implementation, where adding such information to functions which
> >   operate on widget X for the first time is more work.
> 
> Please remember, that APR apps cannot currently get to the context in any
> APR type.  

Nothing that I intended to say indicated that an APR app had to do
anything directly with context.  It has to do something so that APR
stores the address of a logging function in context.

>            I tried to change this last year, and it was shot down.  Until
> an APR app can get to the context, using the context for error logging is
> not possible.

Apache can't use the context for error logging, but APR can.

> 
> I will stress the solution that is most portable, IMHO, again.  Write
> ap_strerror.  IT handles 99% of these cases.  Here is the basic
> function.

I agree 100% that this has to be done, just as you describe.  I agree
99% that it handles 99% of the cases.  I even agree that it has to be
done first.  But I've been concerned about the inability to trace all
available diagnostic data, and when some mechanism is invented to save
stuff like the name of the dll which caused DosLoadModule() to fail
then I'd like to see it able to save other information as well.

> This handles 99% of the cases brought up above, AFAICT.  And, it does it
> by passing around an integer.  The one case it doesn't handle cleanly, is
> the case of a platform with extra error data, like 390.  I personally have
> a couple of thoughts about how to get around this, but I need to develop
> them more.
> 
> I would really appreciate it if somebody would explain where this solution
> falls down.  As near as I can tell the only problem is that nobody has
> implemented it yet.  Until I am convinced that this solution fails
> someplace, I am likely to give any other solution a -1.  This solution is
> small, fast, and doesn't ask APR to try to generate specific messages for
> an application.  I dislike the idea of APR generating specific messages,
> because it has no idea what the application is doing.
> 
> All of the suggestions in this e-mail make it sound like APR would be
> composing the actual error message.  In reality, this means that APR is
> generating an error message without any of the context to know what caused
> the error.  A specific error message without context in much more
> confusin, IMHO than a generic message with a bit of context added by the
> calling program.
> 
> Ryan

I'm not asking for APR to care what the application is doing.  APR
knows what it is doing; it knows that some interesting primitive
failed and that there is useful diagnostic data that it can't return
via ap_status_t.  Consider a bind() failure.

If you're on OS/390, you'd prefer to see this in the Apache log:

  [Tue Mar 28 16:26:12 2000] [err] ap_bind(): bind()->13/737105AE
  [Tue Mar 28 16:26:12 2000] [crit] (13)Permission denied: make_sock:
  could not bind to address 0.0.0.0 port 80

instead of just the second message.  I don't think there would be any
confusion about the meaning of the bind() failure.  There are
various reasons that you could get EPERM/EACCESS from bind() on
OS/390 (not as simple as whether or not UID is zero), and the reason
code (737105AE above, completely fabricated of course) can narrow down
or even pinpoint the exact reason for the failure.  I have spent a
fair amount of time trying to answer mailing list questions by OS/390
users, and knowing the system call and the errno and the reason code
is a great timesaver.  In many cases it means that the user doesn't
have to gather complex system or TCP/IP traces.  In such cases a more
formal support mechanism is required.

Note that for some errors logged by Apache, Apache doesn't even know
what system call failed.  It can only say that some ap_ function
failed.  To solve the problem you need to know the system call.  You
can usually determine that with a quick browse of the source code, but
that limits the number of people that can solve the problem themselves.

Thanks for your response!
-- 
Jeff Trawick | trawick@ibm.net | PGP public key at web site:
     http://www.geocities.com/SiliconValley/Park/9289/
          Born in Roswell... married an alien...

Re: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c dso.h

Posted by rb...@apache.org.
> 1) the diagnostic string exists only to be traced; the APR app doesn't
> have to use the extra diagnostic information in order to choose which
> path to take
> 2) ??
> 
> A. app gives APR a call-back function for recording error information
> 
> Not knowing any better, I'd store a ptr in context_t.
> 
> i. ptr in context_t
> 
> context_t is available almost everywhere in APR.  

Context's aren't available when you want to output the message using
ap_log(r)error in Apache.  All we have at that point is an error code.

> 
> struct context_t {
>     struct ap_pool_t *pool;
>     datastruct *prog_data;
>     int (*apr_abort)(int retcode);
> +   void (*apr_log_error)(int loglvl, const char *fmt, ...);
> };     

This was discusses before, and dismissed by the group at large.  For a
more thorough explanation of why people didn't like this (because I don't
remember any more), look at the original design docs for APR in early
1999.  This was one of the original goals of the contexts BTW.

> 
> This needs a related function called ap_set_log_error() (analogous to
> ap_set_abort).  Very simple...  (Hmmm... ap_set_abort() only
> implemented for UNIX today; what about beos, win32, other versions of
> misc/start.c?)

ap_set_abort is only to be used for backwards compatability with Apache
1.3.  And it should not be used in most cases.  The reason it is only
implemented for Unix, is because nobody ever implemented it for Windows or
BeOS.  I am not sure what Windows does in 1.3 when it cannot allocate
memory.

> ii.  APR app must store ptr to log function in context_t
> 
> We could think about whether or not creating a new context should
> inherit the value from the parent context (probably) so that initially
> Apache only needs to store it once.  In the future, Apache could
> easily choose to provide the log_error function only for certain
> clients (CEO that can't load some obscure page?) simply by only
> setting apr_log_error in context for certain connections (dynamic
> reconfig and new trace specifications very helpful here).

You still can't get access to this function from the one place in Apache
that it is useful.  If you are planning to pass around the APR type to
ap_log_(r)error, you will have a fight from me.  If you are planning on
passing in the whole error string, I think you'll have a fight from some
others.  :-)

> iii. selected APR code calls apr_log_error()
> 
> Typical APR code.  Assume this is in some os-specific file where we
> "know" we have extra diagnostic data.
> 
> ap_status_t apr_do_something(struct ap_widget_t *widget, int parm, 
> 		             struct context_t *cont)
> {
>     ...
>     rc = some_kernel_call(widget->handle, parm);
>     if (rc) {
>         status = errno;
>         if (cont->apr_log_error) {
> 	    cont->apr_log_error(APR_LOG_ERROR,
> 				"some_kernel_call() -> %d/%08X",
> 				status, __errno2());
> 	}
> 	return status;
>     }
> 
>     ...
> }
> 
> This is extendable to any type of error.  No extra setup or checking
> needed by the APR app.  
> 
> Once this is in place, it takes 2-3 lines of code to save extra
> diagnostic information at almost any point in APR.

Now you are talking about saving the error string itself in the context.
This was also discusses, and was sumamrily dismissed by the group last
year.

> 
> iv. the APR app needs some simple trace function for APR to call
> 
> B. APR doesn't call a trace exit function, but instead builds a string
>    and stores it in a widget for later retrieval

This whole idea was brought up last year, and dismissed summarily by the
group.  Please, check the archives for early last year to get the reasons.

> Good points of A:
> 
> . Once it has been made to work for one APR function, it takes very
>   little effort to record diagnostic information in any other APR
>   function that has context_t.  If something bad is happening*, within
>   a minute or so the relevant APR function can be taught to do the
>   right thing, with no changes to data structures or anything else
>   that might have widespread effects.  There is no widget-by-widget
>   implementation, where adding such information to functions which
>   operate on widget X for the first time is more work.

Please remember, that APR apps cannot currently get to the context in any
APR type.  I tried to change this last year, and it was shot down.  Until
an APR app can get to the context, using the context for error logging is
not possible.

I will stress the solution that is most portable, IMHO, again.  Write
ap_strerror.  IT handles 99% of these cases.  Here is the basic function.

char *ap_strerror(ap_status_t status)
{
    if (1 < status < APR_OS_START_ERROR)
        return strerrer(status)
    if (status is in foo_range)
        /* This case handles things like libtool, where libtool's error
         * strings should be output by libtools error checker.
         */
        return foo_eror_call(status)
    if (APR_OS_START_ERROR < APR_OS_START_USEERR)
        return some APR generated string.
}

This handles 99% of the cases brought up above, AFAICT.  And, it does it
by passing around an integer.  The one case it doesn't handle cleanly, is
the case of a platform with extra error data, like 390.  I personally have
a couple of thoughts about how to get around this, but I need to develop
them more.

I would really appreciate it if somebody would explain where this solution
falls down.  As near as I can tell the only problem is that nobody has
implemented it yet.  Until I am convinced that this solution fails
someplace, I am likely to give any other solution a -1.  This solution is
small, fast, and doesn't ask APR to try to generate specific messages for
an application.  I dislike the idea of APR generating specific messages,
because it has no idea what the application is doing.

All of the suggestions in this e-mail make it sound like APR would be
composing the actual error message.  In reality, this means that APR is
generating an error message without any of the context to know what caused
the error.  A specific error message without context in much more
confusin, IMHO than a generic message with a bit of context added by the
calling program.

Ryan

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




Re: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c dso.h

Posted by Jeff Trawick <tr...@bellsouth.net>.
> One more argument in favor of ap_strerror.  If you store the string in the
> code anywhere, the string is inherently "the wrong string" in most places.
> This is because by putting the string in the .c file, you make translation
> very difficult.  By putting the error string generation in APR, you make
> the error strings much easier to get at through a library system.
> 
> Ryan

more bad communication on my part... I didn't want to propose any sort
of alternative to the current ap_status_t design... I was talking about a way
to handle the infrequent cases where ap_status_t isn't enough...

-- 
Jeff Trawick | trawick@ibm.net | PGP public key at web site:
     http://www.geocities.com/SiliconValley/Park/9289/
          Born in Roswell... married an alien...

Re: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c dso.h

Posted by rb...@apache.org.
One more argument in favor of ap_strerror.  If you store the string in the
code anywhere, the string is inherently "the wrong string" in most places.
This is because by putting the string in the .c file, you make translation
very difficult.  By putting the error string generation in APR, you make
the error strings much easier to get at through a library system.

Ryan


Re: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c dso.h

Posted by Jeff Trawick <tr...@bellsouth.net>.
I'll try to compare what I think is the code required to record
an error string using a couple of alternative implementations.  Please
help me out where I falter or am unfair.

Assumptions: 

1) the diagnostic string exists only to be traced; the APR app doesn't
have to use the extra diagnostic information in order to choose which
path to take
2) ??

A. app gives APR a call-back function for recording error information

Not knowing any better, I'd store a ptr in context_t.

i. ptr in context_t

context_t is available almost everywhere in APR.  

struct context_t {
    struct ap_pool_t *pool;
    datastruct *prog_data;
    int (*apr_abort)(int retcode);
+   void (*apr_log_error)(int loglvl, const char *fmt, ...);
};     

This needs a related function called ap_set_log_error() (analogous to
ap_set_abort).  Very simple...  (Hmmm... ap_set_abort() only
implemented for UNIX today; what about beos, win32, other versions of
misc/start.c?)

ii.  APR app must store ptr to log function in context_t

We could think about whether or not creating a new context should
inherit the value from the parent context (probably) so that initially
Apache only needs to store it once.  In the future, Apache could
easily choose to provide the log_error function only for certain
clients (CEO that can't load some obscure page?) simply by only
setting apr_log_error in context for certain connections (dynamic
reconfig and new trace specifications very helpful here).

iii. selected APR code calls apr_log_error()

Typical APR code.  Assume this is in some os-specific file where we
"know" we have extra diagnostic data.

ap_status_t apr_do_something(struct ap_widget_t *widget, int parm, 
		             struct context_t *cont)
{
    ...
    rc = some_kernel_call(widget->handle, parm);
    if (rc) {
        status = errno;
        if (cont->apr_log_error) {
	    cont->apr_log_error(APR_LOG_ERROR,
				"some_kernel_call() -> %d/%08X",
				status, __errno2());
	}
	return status;
    }

    ...
}

This is extendable to any type of error.  No extra setup or checking
needed by the APR app.  

Once this is in place, it takes 2-3 lines of code to save extra
diagnostic information at almost any point in APR.

iv. the APR app needs some simple trace function for APR to call

B. APR doesn't call a trace exit function, but instead builds a string
   and stores it in a widget for later retrieval

i. ptr to string in each widget; multiply this by number of widgets

struct ap_widget_t {
  ...
+  const char *diag_data; /* I guess this should be hidden behind interface
+  and a get-last-error function is provided */
  ...
};

ii. APR app must check for extra information after a call and trace it

This could end up being a very large amount of clutter.  Note that on
most systems, apr_do_something() has no extra diagnostic information
anyway.

stat = apr_do_something(&mywidget, SOME_CONST, cont);
if (stat != APR_SUCCESS)
{
  ap_log_error(..., stat, ..., "apr_do_something(): extra info: %s",
               my_widget.get_last_error_str() ? 
	       my_widget.get_last_error_str() : "(none)");
}

iii. selected APR code saves the information

ap_status_t apr_do_something(struct ap_widget_t *widget, int parm, 
		             struct context_t *cont)
{
    ...
    rc = some_kernel_call(widget->handle, parm);
    if (rc) {
        status = errno;
	widget->diag_data = ap_psprintf(cont, 
	                     "some_kernel_call() -> %d/%08X",
                             status, __errno2());
	return status;
    }

    ...
}

Good points of A:

. Once it has been made to work for one APR function, it takes very
  little effort to record diagnostic information in any other APR
  function that has context_t.  If something bad is happening*, within
  a minute or so the relevant APR function can be taught to do the
  right thing, with no changes to data structures or anything else
  that might have widespread effects.  There is no widget-by-widget
  implementation, where adding such information to functions which
  operate on widget X for the first time is more work.

. The APR app is not cluttered up with checks to see if diagnostic
  data is available and to possibly record it.  With B, the APR app
  must have such logic if diagnostic data is available on *any*
  platform.  When APR does all the work (A), the only check that is
  done is to see whether or not a trace function has been stored, and
  that check is only done when we know we have diagnostic data to
  record.

. Very little pathlength is spent when this tracing should not be
  performed.  With B, we carve up storage and fill it in even if the
  APR app doesn't care/has no logic to look for the diagnostic data
  for that particular call.  Multiple failures on the same ap_widget_t
  will use more and more of the pool.

Good points of B:

. Several folks like it.
. (fill this in)

*A or B:

I would stress the "*If something bad is happening*" part quite a
bit.  For example, I wouldn't make a pass over all APR code to do
something with the secondary error indicator if building for
OS/390.  There might be a handful of places where such information
is truly invaluable and timesaving and those will become obvious over
time; in general we don't need to clutter up any code any more than we
have to.

(I hope nobody sent me e-mail in the last couple of days.  I lost an
interesting file yesterday after some unknown power supply glitch:
~/RMAIL :( )
-- 
Jeff Trawick | trawick@ibm.net | PGP public key at web site:
     http://www.geocities.com/SiliconValley/Park/9289/
          Born in Roswell... married an alien...

Re: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c dso.h

Posted by rb...@apache.org.
On Tue, 28 Mar 2000, David Reid wrote:

> I have to admit that when I was looking for a problem with opening a file
> having the error string would have been very helpful.  Perhaps Manoj's idea
> of a get_error routine for every type is the best one?  It should make
> finding the error easier and should be easy enough to implement.
> 
> I know Ryan doesn't like it though!

It's not that I don't like the idea, it's that the idea wouldn't have
solved your problem.  The reason you weren't seeing an error message, I
think, is because in Apache, we are currently losing some error messages
whenever the parent re-opens the log file.  Martin Pool posted this bug,
and I posted a possible fix, but nobody has had the time to implement it
yet.

Besides, if ap_strerror is ever implemented on all platforms, your error
messages would have been BeOS specific.


Ryan


Re: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c dso.h

Posted by David Reid <dr...@jetnet.co.uk>.
I have to admit that when I was looking for a problem with opening a file
having the error string would have been very helpful.  Perhaps Manoj's idea
of a get_error routine for every type is the best one?  It should make
finding the error easier and should be easy enough to implement.

I know Ryan doesn't like it though!

d.
----- Original Message -----
From: "Jeff Trawick" <tr...@bellsouth.net>
To: <ne...@apache.org>
Sent: Tuesday, March 28, 2000 3:36 AM
Subject: Re: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c
dso.h


> > One other thing, the OS/2 API call DosLoadModule() returns a valuable
> > piece of information on failure, the name of the module that failed to
> > load. When loading a DLL, that DLL may depend on a whole chain of other
> > DLLs, any one of which may fail. Knowing which one did can save a whole
> > lotta time.
> >
> > In 1.3, this information is put in the static error string for later
> > retrieval by ap_os_dso_error(). For APR I'm thinking that it could be
> > stored in the dso_handle_t for later retrieval by a suitable accessor
> > function.
>
> There are plenty of other situations where a particular os has special
> information which, if available, greatly simplifies problem
> determination.  OS/390, for example, has a secondary error indicator
> for every system call which provides more information about the
> error.  In many cases it is able to pinpoint the error.  This is
> particularly helpful in the case of configuration problems.
>
> We could invent ways particular to different data types for saving
> this information; we could add code to our favorite APR app for
> checking to see if any such information was available.
>
> An alternate idea (shot down very quickly a few weeks ago) would be
> for an APR app to give APR a function to call to record error
> information.  This dispenses with some issues completely, such as how
> to store the error info in the object for later retrieval and when the
> APR app should query the object for such info (all this multiplied by
> the number of objects that should support this type of information).
>
> One platform-independent aspect of the trace is the use of a text
> string to record the diagnostic information.  The text string could be
> used on any platform.  If get-last-error functions are added to
> various objects, they could return a text string for passing to
> ap_log_error().
>
> --
> Jeff Trawick | trawick@ibm.net | PGP public key at web site:
>      http://www.geocities.com/SiliconValley/Park/9289/
>           Born in Roswell... married an alien...
>


Re: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c dso.h

Posted by Jeff Trawick <tr...@bellsouth.net>.
> One other thing, the OS/2 API call DosLoadModule() returns a valuable
> piece of information on failure, the name of the module that failed to
> load. When loading a DLL, that DLL may depend on a whole chain of other
> DLLs, any one of which may fail. Knowing which one did can save a whole
> lotta time. 
> 
> In 1.3, this information is put in the static error string for later
> retrieval by ap_os_dso_error(). For APR I'm thinking that it could be
> stored in the dso_handle_t for later retrieval by a suitable accessor
> function.

There are plenty of other situations where a particular os has special
information which, if available, greatly simplifies problem
determination.  OS/390, for example, has a secondary error indicator
for every system call which provides more information about the
error.  In many cases it is able to pinpoint the error.  This is
particularly helpful in the case of configuration problems.  

We could invent ways particular to different data types for saving
this information; we could add code to our favorite APR app for
checking to see if any such information was available.  

An alternate idea (shot down very quickly a few weeks ago) would be
for an APR app to give APR a function to call to record error
information.  This dispenses with some issues completely, such as how
to store the error info in the object for later retrieval and when the
APR app should query the object for such info (all this multiplied by
the number of objects that should support this type of information).

One platform-independent aspect of the trace is the use of a text
string to record the diagnostic information.  The text string could be
used on any platform.  If get-last-error functions are added to
various objects, they could return a text string for passing to
ap_log_error(). 

-- 
Jeff Trawick | trawick@ibm.net | PGP public key at web site:
     http://www.geocities.com/SiliconValley/Park/9289/
          Born in Roswell... married an alien...

Re: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c dso.h

Posted by rb...@apache.org.
On Tue, 28 Mar 2000, David Reid wrote:

> Yeah, something else on the shopping list!  Also do we want set/get data
> functions?  Probably.

Absolutely.  I was just waiting for things to calm down before I did that.

Ryan

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


Re: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c dso.h

Posted by David Reid <dr...@jetnet.co.uk>.
Yeah, something else on the shopping list!  Also do we want set/get data
functions?  Probably.

d.
----- Original Message -----
From: "Brian Havard" <br...@kheldar.apana.org.au>
To: <ne...@apache.org>
Sent: Tuesday, March 28, 2000 2:53 AM
Subject: Re: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c
dso.h


> On Mon, 27 Mar 2000 18:29:59 +0100, David Reid wrote:
>
> >That's true, and I'll fix it before too long.  Also I think some changes
to
> >the way the types are defined may be in order, but I'll let you know
about
> >that.
>
> Also, shouldn't there be a cleanup that unloads the module?
>
> One other thing, the OS/2 API call DosLoadModule() returns a valuable
> piece of information on failure, the name of the module that failed to
> load. When loading a DLL, that DLL may depend on a whole chain of other
> DLLs, any one of which may fail. Knowing which one did can save a whole
> lotta time.
>
> In 1.3, this information is put in the static error string for later
> retrieval by ap_os_dso_error(). For APR I'm thinking that it could be
> stored in the dso_handle_t for later retrieval by a suitable accessor
> function.
>
> Would this apply to any other platforms?
>
>
>
> >----- Original Message -----
> >From: "Brian Havard" <br...@kheldar.apana.org.au>
> >To: <ne...@apache.org>
> >Sent: Monday, March 27, 2000 1:19 PM
> >Subject: Re: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c
> >dso.h
> >
> >
> >> On Mon, 27 Mar 2000 10:27:58 +0100, David Reid wrote:
> >>
> >> >Yes, I only cut/pasted to get the code in place.  Hope it wasn't too
much
> >> >grief!
> >>
> >> Nah, only took a few minutes. One thing I would like to point out
> >> though is that the function args for ap_status_t ap_dso_load() don't
> >> don't match the usual APR rules (result first, context last).
>
> --
>
____________________________________________________________________________
__
>  |  Brian Havard                 |  "He is not the messiah!
|
>  |  brianh@kheldar.apana.org.au  |  He's a very naughty boy!" - Life of
Brian |
>  -------------------------------------------------------------------------
-----
>
>


Re: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c dso.h

Posted by rb...@apache.org.
> Also, shouldn't there be a cleanup that unloads the module?

+1.

> In 1.3, this information is put in the static error string for later
> retrieval by ap_os_dso_error(). For APR I'm thinking that it could be
> stored in the dso_handle_t for later retrieval by a suitable accessor
> function.
> 
> Would this apply to any other platforms?

+1

Ryan

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


Re: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c dso.h

Posted by Brian Havard <br...@kheldar.apana.org.au>.
On Mon, 27 Mar 2000 18:29:59 +0100, David Reid wrote:

>That's true, and I'll fix it before too long.  Also I think some changes to
>the way the types are defined may be in order, but I'll let you know about
>that.

Also, shouldn't there be a cleanup that unloads the module?

One other thing, the OS/2 API call DosLoadModule() returns a valuable
piece of information on failure, the name of the module that failed to
load. When loading a DLL, that DLL may depend on a whole chain of other
DLLs, any one of which may fail. Knowing which one did can save a whole
lotta time. 

In 1.3, this information is put in the static error string for later
retrieval by ap_os_dso_error(). For APR I'm thinking that it could be
stored in the dso_handle_t for later retrieval by a suitable accessor
function.

Would this apply to any other platforms?



>----- Original Message -----
>From: "Brian Havard" <br...@kheldar.apana.org.au>
>To: <ne...@apache.org>
>Sent: Monday, March 27, 2000 1:19 PM
>Subject: Re: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c
>dso.h
>
>
>> On Mon, 27 Mar 2000 10:27:58 +0100, David Reid wrote:
>>
>> >Yes, I only cut/pasted to get the code in place.  Hope it wasn't too much
>> >grief!
>>
>> Nah, only took a few minutes. One thing I would like to point out
>> though is that the function args for ap_status_t ap_dso_load() don't
>> don't match the usual APR rules (result first, context last).

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


Re: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c dso.h

Posted by David Reid <dr...@jetnet.co.uk>.
That's true, and I'll fix it before too long.  Also I think some changes to
the way the types are defined may be in order, but I'll let you know about
that.

d.
----- Original Message -----
From: "Brian Havard" <br...@kheldar.apana.org.au>
To: <ne...@apache.org>
Sent: Monday, March 27, 2000 1:19 PM
Subject: Re: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c
dso.h


> On Mon, 27 Mar 2000 10:27:58 +0100, David Reid wrote:
>
> >Yes, I only cut/pasted to get the code in place.  Hope it wasn't too much
> >grief!
>
> Nah, only took a few minutes. One thing I would like to point out
> though is that the function args for ap_status_t ap_dso_load() don't
> don't match the usual APR rules (result first, context last).
>
>
>
> >----- Original Message -----
> >From: <bj...@locus.apache.org>
> >To: <ap...@apache.org>
> >Sent: Monday, March 27, 2000 4:18 AM
> >Subject: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c
dso.h
> >
> >
> >> bjh         00/03/26 19:18:20
> >>
> >>   Modified:    src/lib/apr/dso/os2 Makefile.in dso.c dso.h
> >>   Log:
> >>   Clean up OS/2 DSO code so it at least compiles.
>
> --
>
____________________________________________________________________________
__
>  |  Brian Havard                 |  "He is not the messiah!
|
>  |  brianh@kheldar.apana.org.au  |  He's a very naughty boy!" - Life of
Brian |
>  -------------------------------------------------------------------------
-----
>
>


Re: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.cdso.h

Posted by David Reid <dr...@jetnet.co.uk>.
That is something else on my list of things to do!

I wanted to get the code committed and I knew it wasn't perfect!  At least
people have started looking at it already which was the intent.  Had I not
been so busy with cables, walls, sockets (real ones) and so on I would have
done it by now!

d.
----- Original Message -----
From: "Jon Travis" <jt...@covalent.net>
To: <ne...@apache.org>
Cc: "Brian Havard" <br...@kheldar.apana.org.au>
Sent: Monday, March 27, 2000 5:41 PM
Subject: Re: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in
dso.cdso.h


> rbb@apache.org wrote:
>
> > On Mon, 27 Mar 2000, Brian Havard wrote:
> >
> > > On Mon, 27 Mar 2000 10:27:58 +0100, David Reid wrote:
> > >
> > > >Yes, I only cut/pasted to get the code in place.  Hope it wasn't too
much
> > > >grief!
> > >
> > > Nah, only took a few minutes. One thing I would like to point out
> > > though is that the function args for ap_status_t ap_dso_load() don't
> > > don't match the usual APR rules (result first, context last).
> > >
> >
> > This needs to be changed, IMHO.  I spent far too much time getting the
> > arguments to match weel to have it changed now!  :-)
> >
> > BTW, are there are docs in the unix source yet?  (hint, hint, if they
> > aren't there).
> >
> > Ryan
>
> Well, there are comments in the unix DSO source, however they match up
with the
> original ones that I wrote up, so after all my errstr resvals got nuked
they are
> still in the dox.. ;-)
>
> -- Jon
>
>
>


Re: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.cdso.h

Posted by Jon Travis <jt...@covalent.net>.
rbb@apache.org wrote:

> On Mon, 27 Mar 2000, Brian Havard wrote:
>
> > On Mon, 27 Mar 2000 10:27:58 +0100, David Reid wrote:
> >
> > >Yes, I only cut/pasted to get the code in place.  Hope it wasn't too much
> > >grief!
> >
> > Nah, only took a few minutes. One thing I would like to point out
> > though is that the function args for ap_status_t ap_dso_load() don't
> > don't match the usual APR rules (result first, context last).
> >
>
> This needs to be changed, IMHO.  I spent far too much time getting the
> arguments to match weel to have it changed now!  :-)
>
> BTW, are there are docs in the unix source yet?  (hint, hint, if they
> aren't there).
>
> Ryan

Well, there are comments in the unix DSO source, however they match up with the
original ones that I wrote up, so after all my errstr resvals got nuked they are
still in the dox.. ;-)

-- Jon



Re: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c dso.h

Posted by rb...@apache.org.
On Mon, 27 Mar 2000, Brian Havard wrote:

> On Mon, 27 Mar 2000 10:27:58 +0100, David Reid wrote:
> 
> >Yes, I only cut/pasted to get the code in place.  Hope it wasn't too much
> >grief!
> 
> Nah, only took a few minutes. One thing I would like to point out
> though is that the function args for ap_status_t ap_dso_load() don't
> don't match the usual APR rules (result first, context last).
> 

This needs to be changed, IMHO.  I spent far too much time getting the
arguments to match weel to have it changed now!  :-)

BTW, are there are docs in the unix source yet?  (hint, hint, if they
aren't there).

Ryan



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


Re: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c dso.h

Posted by Brian Havard <br...@kheldar.apana.org.au>.
On Mon, 27 Mar 2000 10:27:58 +0100, David Reid wrote:

>Yes, I only cut/pasted to get the code in place.  Hope it wasn't too much
>grief!

Nah, only took a few minutes. One thing I would like to point out
though is that the function args for ap_status_t ap_dso_load() don't
don't match the usual APR rules (result first, context last).



>----- Original Message -----
>From: <bj...@locus.apache.org>
>To: <ap...@apache.org>
>Sent: Monday, March 27, 2000 4:18 AM
>Subject: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c dso.h
>
>
>> bjh         00/03/26 19:18:20
>>
>>   Modified:    src/lib/apr/dso/os2 Makefile.in dso.c dso.h
>>   Log:
>>   Clean up OS/2 DSO code so it at least compiles.

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


Re: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c dso.h

Posted by David Reid <dr...@jetnet.co.uk>.
Yes, I only cut/pasted to get the code in place.  Hope it wasn't too much
grief!

d.
----- Original Message -----
From: <bj...@locus.apache.org>
To: <ap...@apache.org>
Sent: Monday, March 27, 2000 4:18 AM
Subject: cvs commit: apache-2.0/src/lib/apr/dso/os2 Makefile.in dso.c dso.h


> bjh         00/03/26 19:18:20
>
>   Modified:    src/lib/apr/dso/os2 Makefile.in dso.c dso.h
>   Log:
>   Clean up OS/2 DSO code so it at least compiles.
>