You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by "Roy T. Fielding" <fi...@kiwi.ICS.UCI.EDU> on 1997/05/29 00:46:10 UTC

Re: [PATCH] PR#502: cleanup use of longjmp/setjmp for IdentityCheck

Woohoo!  The third attempt worked.

.....Roy


----- Forwarded message

Date: Wed, 28 May 1997 13:09:57 -0500 (CDT)
From: "Mark A. Bentley" <be...@cs.umn.edu>
To: "Roy T. Fielding" <fi...@kiwi.ICS.UCI.EDU>
Subject: Re: [PATCH] PR#502: cleanup use of longjmp/setjmp for IdentityCheck
In-Reply-To: <97...@paris.ics.uci.edu>
Message-ID: <Pi...@melange.cs.umn.edu>


Looks like this fixed the problem.  The server has been running with this
patch against a clean 1.2b10 for 15.5 hours with Ident lookups on, and it
appears to be working correctly now.

Thanks!

--Mark

On Tue, 27 May 1997, Roy T. Fielding wrote:

> >PR#502: timeout still a problem with IdentityCheck On.
> >Roy thinks it may be a problem with how longjmp and signal are
> >used in rfc1413.c (try replacing 
> >     static jmp_buf timebuf;
> >with
> >     JMP_BUF timebuf;
> >and replacing the longjmp/setjmp calls with the definitions
> >used within http_main.c
> 
> Below is a patch that will do this (against current 1.2b11-dev).
> I have no idea if it will fix the problem, since I don't have Irix
> and haven't been able to reproduce it.  However, it is a bad idea
> to use unreliable jumps with reliable signals, so it is worth testing.
> 
> ....Roy
> 
> 
> Index: conf.h
> ===================================================================
> RCS file: /export/home/cvs/apache/src/conf..h,v
> retrieving revision 1.97
> diff -c -r1.97 conf.h
> *** conf.h	1997/05/01 17:36:24	1.97
> --- conf.h	1997/05/28 01:20:17
> ***************
> *** 61,67 ****
>   
>   /* Define one of these according to your system. */
>   #if defined(MPE)
> - #include <setjmp.h>
>   #include <sys/times.h>
>   #define JMP_BUF sigjmp_buf
>   #define NO_SETSID
> --- 61,66 ----
> ***************
> *** 650,655 ****
> --- 649,664 ----
>   #endif
>   #define signal(s,f)	ap_signal(s,f)
>   Sigfunc *signal(int signo, Sigfunc *func);
> + #endif
> + 
> + #include <setjmp.h>
> + 
> + #if defined(USE_LONGJMP)
> + #define ap_longjmp(x, y)        longjmp((x), (y))
> + #define ap_setjmp(x)            setjmp(x)
> + #else
> + #define ap_longjmp(x, y)        siglongjmp((x), (y))
> + #define ap_setjmp(x)            sigsetjmp((x), 1)
>   #endif
>   
>   /* Finding offsets of elements within structures.
> Index: http_main.c
> ===================================================================
> RCS file: /export/home/cvs/apache/src/http_main.c,v
> retrieving revision 1.146
> diff -c -r1.146 http_main.c
> *** http_main.c	1997/05/27 04:41:50	1.146
> --- http_main.c	1997/05/28 01:20:17
> ***************
> *** 84,90 ****
>   #include "http_conf_globals.h"
>   #include "http_core.h"          /* for get_remote_host */
>   #include "scoreboard.h"
> - #include <setjmp.h>
>   #include <assert.h>
>   #include <sys/stat.h>
>   #ifdef HAVE_SHMGET
> --- 84,89 ----
> ***************
> *** 180,193 ****
>   #define ap_killpg(x, y)		(kill (-(x), (y)))
>   #else
>   #define ap_killpg(x, y)		(killpg ((x), (y)))
> - #endif
> - 
> - #if defined(USE_LONGJMP)
> - #define ap_longjmp(x, y)	(longjmp ((x), (y)))
> - #define ap_setjmp(x)		(setjmp (x))
> - #else
> - #define ap_longjmp(x, y)	(siglongjmp ((x), (y)))
> - #define ap_setjmp(x)		(sigsetjmp ((x), 1))
>   #endif
>   
>   #if defined(USE_FCNTL_SERIALIZED_ACCEPT)
> --- 179,184 ----
> Index: rfc1413.c
> ===================================================================
> RCS file: /export/home/cvs/apache/src/rfc1413.c,v
> retrieving revision 1.9
> diff -c -r1.9 rfc1413.c
> *** rfc1413.c	1997/03/07 17:43:36	1.9
> --- rfc1413.c	1997/05/28 01:20:17
> ***************
> *** 72,85 ****
>   
>   /* Rewritten by David Robinson */
>   
> ! #include "httpd.h"    /* for server_rec, conn_rec */
>   #include "http_log.h" /* for log_unixerr */
>   #include "rfc1413.h"
>   
> - /* System libraries. */
> - 
> - #include <setjmp.h>
> - 
>   #ifndef SCO
>   extern char *strchr();
>   extern char *inet_ntoa();
> --- 72,81 ----
>   
>   /* Rewritten by David Robinson */
>   
> ! #include "httpd.h"    /* for server_rec, conn_rec, ap_longjmp, etc. */
>   #include "http_log.h" /* for log_unixerr */
>   #include "rfc1413.h"
>   
>   #ifndef SCO
>   extern char *strchr();
>   extern char *inet_ntoa();
> ***************
> *** 93,105 ****
>   /* rough limit on the amount of data we accept. */
>   #define RFC1413_MAXDATA 1000
>   
>   #define RFC1413_TIMEOUT	30
>   #define	ANY_PORT	0		/* Any old port will do */
>   #define FROM_UNKNOWN  "unknown"
>   
> ! int rfc1413_timeout = RFC1413_TIMEOUT;/* Global so it can be changed */
> ! 
> ! static jmp_buf timebuf;
>   
>   /* bind_connect - bind both ends of a socket */
>   
> --- 89,101 ----
>   /* rough limit on the amount of data we accept. */
>   #define RFC1413_MAXDATA 1000
>   
> + #ifndef RFC1413_TIMEOUT
>   #define RFC1413_TIMEOUT	30
> + #endif
>   #define	ANY_PORT	0		/* Any old port will do */
>   #define FROM_UNKNOWN  "unknown"
>   
> ! JMP_BUF timebuf;
>   
>   /* bind_connect - bind both ends of a socket */
>   
> ***************
> *** 182,192 ****
>       return 0;
>   }
>   
> ! /* timeout - handle timeouts */
>   static void
> ! timeout(int sig)
>   {
> !     longjmp(timebuf, sig);
>   }
>   
>   /* rfc1413 - return remote user name, given socket structures */
> --- 178,188 ----
>       return 0;
>   }
>   
> ! /* ident_timeout - handle timeouts */
>   static void
> ! ident_timeout(int sig)
>   {
> !     ap_longjmp(timebuf, sig);
>   }
>   
>   /* rfc1413 - return remote user name, given socket structures */
> ***************
> *** 209,218 ****
>       /*
>        * Set up a timer so we won't get stuck while waiting for the server.
>        */
> !     if (setjmp(timebuf) == 0)
>       {
> ! 	signal(SIGALRM, timeout);
> ! 	alarm(rfc1413_timeout);
>   	
>   	if (get_rfc1413(sock, &conn->local_addr, &conn->remote_addr, user,
>   		      srv)
> --- 205,214 ----
>       /*
>        * Set up a timer so we won't get stuck while waiting for the server.
>        */
> !     if (ap_setjmp(timebuf) == 0)
>       {
> ! 	signal(SIGALRM, ident_timeout);
> ! 	alarm(RFC1413_TIMEOUT);
>   	
>   	if (get_rfc1413(sock, &conn->local_addr, &conn->remote_addr, user,
>   		      srv)
> 

==========================================================================
Mark A Bentley			Email:	bentlema@cs.umn.edu
Systems Staff, CSci Dept
University of Minnesota 	URL:	http://www.cs.umn.edu/~bentlema/


Re: [PATCH] PR#502: cleanup use of longjmp/setjmp for IdentityCheck

Posted by Dean Gaudet <dg...@arctic.org>.
On Wed, 28 May 1997, Roy T. Fielding wrote:
> > ! static jmp_buf timebuf;
> > --- 89,101 ----
> > ! JMP_BUF timebuf;

Why remove the static?

An untested +1 otherwise.  :)

Dean