cvs commit: apache-1.3/src/modules/standard mod_unique_id.c
dgaudet 98/06/07 22:32:24 Modified:src CHANGES src/modules/standard mod_unique_id.c Log: fix mod_unique_id to work with 64-bit time_t Submitted by: Alvaro Martinez Echevarria [EMAIL PROTECTED] Revision ChangesPath 1.894 +4 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.893 retrieving revision 1.894 diff -u -r1.893 -r1.894 --- CHANGES 1998/06/07 13:16:40 1.893 +++ CHANGES 1998/06/08 05:32:22 1.894 @@ -1,5 +1,9 @@ Changes with Apache 1.3.1 + *) mod_unique_id did not work on alpha linux (in general on any + architecture that has 64-bit time_t). + [Alvaro Martinez Echevarria [EMAIL PROTECTED]] + *) PORT: Make SCO 5 (and probably 3) compile again. [Ben Laurie] *) PORT: NCR MPRAS systems have the same bug with SIGHUP restart that 1.16 +88 -45apache-1.3/src/modules/standard/mod_unique_id.c Index: mod_unique_id.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_unique_id.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- mod_unique_id.c 1998/04/11 12:00:53 1.15 +++ mod_unique_id.c 1998/06/08 05:32:24 1.16 @@ -59,6 +59,7 @@ * mod_unique_id.c: generate a unique identifier for each request * * Original author: Dean Gaudet [EMAIL PROTECTED] + * UUencoding modified by: Alvaro Martinez Echevarria [EMAIL PROTECTED] */ #include httpd.h @@ -71,11 +72,11 @@ #endif typedef struct { -time_t stamp; +unsigned int stamp; unsigned int in_addr; unsigned int pid; unsigned short counter; -} unique_id_rec; +} unique_id_rec; /* Comments: * @@ -125,11 +126,35 @@ * procedure will ensure that the new space of identifiers is completely unique * from the old space. (Since the first four unencoded bytes always differ.) */ +/* + * Sun Jun 7 05:43:49 CEST 1998 -- Alvaro + * More comments: + * 1) The UUencoding prodecure is now done in a general way, avoiding the problems + * with sizes and paddings that can arise depending on the architecture. Now the + * offsets and sizes of the elements of the unique_id_rec structure are calculated + * in unique_id_global_init; and then used to duplicate the structure without the + * paddings that might exist. The multithreaded server fix should be now very easy: + * just add a new tid field to the unique_id_rec structure, and increase by one + * UNIQUE_ID_REC_MAX. + * 2) unique_id_rec.stamp has been changed from time_t to unsigned int, because + * its size is 64bits on some platforms (linux/alpha), and this caused problems with + * htonl/ntohl. Well, this shouldn't be a problem till year 2106. + */ static unsigned global_in_addr; static APACHE_TLS unique_id_rec cur_unique_id; +/* + * Number of elements in the structure unique_id_rec. + */ +#define UNIQUE_ID_REC_MAX 4 + +static unsigned short unique_id_rec_offset[UNIQUE_ID_REC_MAX], + unique_id_rec_size[UNIQUE_ID_REC_MAX], + unique_id_rec_total_size, + unique_id_rec_size_uu; + static void unique_id_global_init(server_rec *s, pool *p) { #ifndef MAXHOSTNAMELEN @@ -142,18 +167,23 @@ #endif /* - * First of all, verify some assumptions that have been made about the - * contents of unique_id_rec. We do it this way because it isn't - * affected by trailing padding. + * Calculate the sizes and offsets in cur_unique_id. */ -if (XtOffsetOf(unique_id_rec, counter) + sizeof(cur_unique_id.counter) -!= 14) { -ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, s, -mod_unique_id: sorry the size assumptions are wrong -in mod_unique_id.c, please remove it from your server -or fix the code!); -exit(1); -} +unique_id_rec_offset[0] = XtOffsetOf(unique_id_rec, stamp); +unique_id_rec_size[0] = sizeof(cur_unique_id.stamp); +unique_id_rec_offset[1] = XtOffsetOf(unique_id_rec, in_addr); +unique_id_rec_size[1] = sizeof(cur_unique_id.in_addr); +unique_id_rec_offset[2] = XtOffsetOf(unique_id_rec, pid); +unique_id_rec_size[2] = sizeof(cur_unique_id.pid); +unique_id_rec_offset[3] = XtOffsetOf(unique_id_rec, counter); +unique_id_rec_size[3] = sizeof(cur_unique_id.counter); +unique_id_rec_total_size = unique_id_rec_size[0] + unique_id_rec_size[1] + + unique_id_rec_size[2] + unique_id_rec_size[3]; + +/* + * Calculate the size of the structure when uuencoded. +
cvs commit: apache-1.3/src/modules/standard mod_unique_id.c
dgaudet 98/02/22 16:05:41 Modified:src/include conf.h src/main buff.c http_core.c src/modules/experimental mod_mmap_static.c src/modules/standard mod_unique_id.c Log: We have NO_UNISTD_H, but we don't use it in conf.h ... surely this is a mistake. Clean up unistd.h usage elsewhere as well. Revision ChangesPath 1.184 +1 -1 apache-1.3/src/include/conf.h Index: conf.h === RCS file: /export/home/cvs/apache-1.3/src/include/conf.h,v retrieving revision 1.183 retrieving revision 1.184 diff -u -r1.183 -r1.184 --- conf.h1998/02/22 21:14:54 1.183 +++ conf.h1998/02/23 00:05:36 1.184 @@ -909,7 +909,7 @@ #define LOGNAME_MAX 25 #endif -#if !defined(NEXT) !defined(WIN32) +#ifndef NO_UNISTD_H #include unistd.h #endif 1.65 +0 -3 apache-1.3/src/main/buff.c Index: buff.c === RCS file: /export/home/cvs/apache-1.3/src/main/buff.c,v retrieving revision 1.64 retrieving revision 1.65 diff -u -r1.64 -r1.65 --- buff.c1998/02/12 21:13:18 1.64 +++ buff.c1998/02/23 00:05:37 1.65 @@ -59,9 +59,6 @@ #include stdio.h #include stdarg.h #include string.h -#ifndef NO_UNISTD_H -#include unistd.h -#endif #ifndef NO_WRITEV #include sys/types.h #include sys/uio.h 1.164 +0 -1 apache-1.3/src/main/http_core.c Index: http_core.c === RCS file: /export/home/cvs/apache-1.3/src/main/http_core.c,v retrieving revision 1.163 retrieving revision 1.164 diff -u -r1.163 -r1.164 --- http_core.c 1998/02/21 20:32:06 1.163 +++ http_core.c 1998/02/23 00:05:38 1.164 @@ -67,7 +67,6 @@ #include fnmatch.h #ifdef USE_MMAP_FILES -#include unistd.h #include sys/mman.h /* mmap support for static files based on ideas from John Heidemann's 1.2 +0 -1 apache-1.3/src/modules/experimental/mod_mmap_static.c Index: mod_mmap_static.c === RCS file: /export/home/cvs/apache-1.3/src/modules/experimental/mod_mmap_static.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- mod_mmap_static.c 1998/02/10 11:00:58 1.1 +++ mod_mmap_static.c 1998/02/23 00:05:40 1.2 @@ -107,7 +107,6 @@ #include fcntl.h #include errno.h #include string.h -#include unistd.h #include sys/mman.h #include httpd.h 1.13 +0 -1 apache-1.3/src/modules/standard/mod_unique_id.c Index: mod_unique_id.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_unique_id.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- mod_unique_id.c 1998/02/05 07:52:34 1.12 +++ mod_unique_id.c 1998/02/23 00:05:41 1.13 @@ -61,7 +61,6 @@ #include http_config.h #include http_log.h #include multithread.h -#include unistd.h #ifdef MULTITHREAD #error sorry this module does not support multithreaded servers yet
cvs commit: apache-1.3/src/modules/standard mod_unique_id.c
dgaudet 98/02/04 23:52:35 Modified:src/modules/standard mod_unique_id.c Log: gethostname doesn't necessarily \0-terminate Submitted by: Marc Slemko Revision ChangesPath 1.12 +1 -0 apache-1.3/src/modules/standard/mod_unique_id.c Index: mod_unique_id.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_unique_id.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- mod_unique_id.c 1998/01/27 10:28:33 1.11 +++ mod_unique_id.c 1998/02/05 07:52:34 1.12 @@ -162,6 +162,7 @@ gethostname: mod_unique_id requires the hostname of the server); exit(1); } +str[sizeof(str) - 1] = '\0'; if ((hent = gethostbyname(str)) == NULL) { aplog_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, s,
cvs commit: apache-1.3/src/modules/standard mod_unique_id.c
dgaudet 98/01/27 02:28:34 Modified:.STATUS src CHANGES src/modules/standard mod_unique_id.c Log: don't generate a second id on internal_redirects Revision ChangesPath 1.134 +1 -0 apache-1.3/STATUS Index: STATUS === RCS file: /export/home/cvs/apache-1.3/STATUS,v retrieving revision 1.133 retrieving revision 1.134 diff -u -r1.133 -r1.134 --- STATUS1998/01/27 08:38:45 1.133 +++ STATUS1998/01/27 10:28:29 1.134 @@ -137,6 +137,7 @@ * [Port] Fix CGI-Execution for EBCDIC hosts. * Martin's [PATCH] Signing server generated pages * Dmitry's table_*n API addition +* mod_unique_id didn't deal with internal_redirect properly Available Patches: 1.602 +4 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.601 retrieving revision 1.602 diff -u -r1.601 -r1.602 --- CHANGES 1998/01/27 05:35:27 1.601 +++ CHANGES 1998/01/27 10:28:31 1.602 @@ -1,5 +1,9 @@ Changes with Apache 1.3b4 + *) mod_unique_id was erroneously generating a second unique id when + an internal redirect occured. Such redirects occur, for example, + when processing a DirectoryIndex match. [Dean Gaudet] + *) table_add, table_merge, and table_set include implicit pstrdup() of the key and value. But in many cases this is not required because the key/value is a constant, or the value has been built 1.11 +9 -0 apache-1.3/src/modules/standard/mod_unique_id.c Index: mod_unique_id.c === RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_unique_id.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- mod_unique_id.c 1998/01/26 19:50:25 1.10 +++ mod_unique_id.c 1998/01/27 10:28:33 1.11 @@ -281,6 +281,15 @@ char str[19 + 1]; const unsigned char *x; unsigned short counter; +char *e; + +/* copy the unique_id if this is an internal redirect (we're never + * actually called for sub requests, so we don't need to test for + * them) */ +if (r-prev (e = table_get(r-subprocess_env, REDIRECT_UNIQUE_ID))) { + table_setn(r-subprocess_env, UNIQUE_ID, e); + return DECLINED; +} cur_unique_id.stamp = htonl(r-request_time);