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/28 03:25:44 UTC
[PATCH] PR#502: cleanup use of longjmp/setjmp for IdentityCheck
>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)