You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Randy Terbush <ra...@Covalent.NET> on 1998/08/10 00:08:19 UTC

[PATCH] friendlier MODULE_MAGIC_NUMBER checks

We seem to need another versioning slot to allow us to mark the
addition of new features in the API while not requiring recompilation
of older modules. The current code is not very friendly to precompiled 
modules since the MMN invariably changes for every minor release.

The following patch attempts to split out a _MAJOR/_MINOR numbering
scheme. MMN_MINOR would mark the addition of new functions, etc. to
the API. MMN_MAJOR would reflect structure changes, etc. that cause
true incompatibility. I've also conditionalized the _MAJOR macro which 
could allow the ability to compile the server to match an older API
interface if we were careful about wrapping structure changes in the
_MAJOR macro that corresponds to it's change. Comments welcome.

I've also pulled the mmn.txt into http_config.h. Makes more sense to
me to have this distributed in the codebase. Sorry about the
tabs. I'll commit an expanded version if this goes into Apache.

-Randy

Index: src/include/http_config.h
===================================================================
RCS file: /usr/local/covalent/.CVS/apache/apache-1.3/src/include/http_config.h,v
retrieving revision 1.92
diff -u -r1.92 http_config.h
--- http_config.h	1998/08/09 06:37:15	1.92
+++ http_config.h	1998/08/09 22:01:51
@@ -190,6 +190,9 @@
 				 * check that module is compatible with this
 				 * version of the server.
 				 */
+    int minor_version;          /* API minor version. Provides API feature
+                                 * milestones. Not checked during module init
+				 */
     int module_index;		/* Index to this modules structures in
 				 * config vectors.
 				 */
@@ -269,14 +272,129 @@
 } module;
 
 /* Initializer for the first few module slots, which are only
- * really set up once we start running.  Note that the first word
- * is a version check; this should allow us to deal with changes to
- * the API (the server can detect an old-format module, and either
- * handle it back-compatibly, or at least signal an error).
+ * really set up once we start running.  Note that the first two slots
+ * provide a version check; this should allow us to deal with changes to
+ * the API. The major number should reflect changes to the API handler table
+ * itself or removal of functionality. The minor number should reflect
+ * additions of functionality to the existing API. (the server can detect
+ * an old-format module, and either handle it back-compatibly, or at least
+ * signal an error).
+ */
+
+
+/*
+ * MODULE_MAGIC_NUMBER_MAJOR
+ * major API changes that could cause compatibility problems for older modules
+ *
+ * 19950525		- original value
+ * 19960512 (1.1b2)	- updated, 1.1, version.
+ * 19960526 (1.1b3)	- get_token(), table_unset(), pstrndup()
+ *			  functions added
+ * 19960725 (1.2-dev)	- HTTP/1.1 compliance
+ *			  (new version of read_client_block)
+ * 19960806 (1.2-dev)	- scan_script_header_err() added
+ * 19961007 (1.2-dev)	- replace read_client_block() with get_client_block()
+ * 19961125 (1.2b1)	- change setup_client_block() to Roy's version
+ * 19961211 (1.2b3)	- rwrite() added
+ * 19970103 (1.2b5-dev)	- header parse API
+ * 19970427 (1.2b9-dev)	- port references made unsigned
+ * 19970526 (1.2)	- correct vhost walk for multiple requests on a single
+ *			  connect
+ * 19970623 (1.3-dev)	- NT changes
+ * 19970628 (1.3-dev)	- ap_slack (fd fixes) added
+ * 19970717 (1.3-dev)	- child_init API hook added
+ * 19970719 (1.3-dev)	- discard_request_body() added (to clear the decks
+ *			  as needed)
+ * 19970728 (1.3a2-dev)	- child_exit API hook added
+ * 19970818 (1.3a2-dev)	- post read-request phase added
+ * 19970825 (1.3a2-dev)	- r->mtime cell added
+ * 19970831 (1.3a2-dev)	- error logging changed to use aplog_error()
+ * 19970902 (1.3a2-dev)	- MD5 routines and structures renamed to ap_*
+ * 19970912 (1.3b1-dev)	- set_last_modified split into set_last_modified,
+ * 			  set_etag and meets_conditions
+ *			  register_other_child API
+ *			  piped_log API
+ *			  short_score split into parent and child pieces
+ *			  os_is_absolute_path
+ * 19971026 (1.3b3-dev)	- custom config hooks in place
+ * 19980126 (1.3b4-dev)	- ap_cpystrn(), table_addn(), table_setn(),
+ *			  table_mergen()
+ * 19980201 (1.3b4-dev)	- construct_url()
+ *			  prototype server_rec * -> request_rec *
+ *			  add get_server_name() and get_server_port()
+ * 19980207 (1.3b4-dev)	- add dynamic_load_handle to module structure as part
+ *			  of the STANDARD_MODULE_STUFF header
+ * 19980304 (1.3b6-dev)	- abstraction of SERVER_BUILT and SERVER_VERSION
+ * 19980305 (1.3b6-dev)	- ap_config.h added for use by external modules
+ * 19980312 (1.3b6-dev)	- parse_uri_components() and its ilk
+ *			  remove r->hostlen, add r->unparsed_uri
+ *			  set_string_slot_lower()
+ *			  clarification: non-RAW_ARGS cmd handlers do not
+ *			  need to pstrdup() their arguments
+ *			  clarification: request_rec members content_type,
+ *			  handler, content_encoding, content_language,
+ *			  content_languages MUST all be lowercase strings,
+ *			  and MAY NOT be modified in place -- modifications
+ *			  require pstrdup().
+ * 19980317 (1.3b6-dev)	- CORE_EXPORTs for win32 and <Perl>
+ *			  API export basic_http_header, send_header_field,
+ *			  set_keepalive, srm_command_loop, check_cmd_context,
+ *			  tm2sec
+ *			  spacetoplus(), plustospace(), client_to_stdout()
+ *			  removed
+ * 19980324 (1.3b6-dev)	- API_EXPORT(index_of_response)
+ * 19980413 (1.3b6-dev)	- The BIG SYMBOL RENAMING: general ap_ prefix
+ *			  (see src/include/compat.h for more details)
+ *			  ap_vformatter() API, see src/include/ap.h
+ * 19980507 (1.3b7-dev)	- addition of ap_add_version_component() and
+ *			  discontinuation of -DSERVER_SUBVERSION support
+ * 19980519 (1.3b7-dev)	- add child_info * to spawn function (as passed to
+ *			  ap_spawn_child_err_buff) and to ap_call_exec to make
+ *			  children work correctly on Win32.
+ * 19980527 (1.3b8-dev)	- renamed some more functions to ap_ prefix which were
+ *			  missed at the big renaming (they are defines):
+ *			  is_default_port, default_port and http_method.
+ *			  A new communication method for modules was added:
+ *			  they can create customized error messages under the
+ *			  "error-notes" key in the request_rec->notes table.
+ *			  This string will be printed in place of the canned
+ *			  error responses, and will be propagated to
+ *			  ErrorDocuments or cgi scripts in the
+ *			  (REDIRECT_)ERROR_NOTES variable.
+ * 19980627 (1.3.1-dev)	- More renaming that we forgot/bypassed. In particular:
+ *			  table_elts --> ap_table_elts
+ *			  is_table_empty --> ap_is_table_empty
+ * 19980708 (1.3.1-dev)	- ap_isalnum(), ap_isalpha(), ... "8-bit safe" ctype
+ *			  macros and apctype.h added
+ * 19980713 (1.3.1-dev)	- renaming of C header files:
+ *			  1. conf.h      -> ap_config.h
+ *			  2. conf_auto.h -> ap_config_auto.h - now merged
+ *			  3. ap_config.h -> ap_config_auto.h - now merged
+ *			  4. compat.h    -> ap_compat.h
+ *			  5. apctype.h   -> ap_ctype.h
+ * 19980808 (1.3.1-dev)	- Add limit_req_line, limit_req_fields,
+ *			  limit_req_fieldsize, and limit_req_body variables
+ *			  to server_rec
+ * 19980809 (1.3.1-dev)	- split of MODULE_MAGIC_NUMBER
  */
 
-#define MODULE_MAGIC_NUMBER 19980808
-#define STANDARD_MODULE_STUFF MODULE_MAGIC_NUMBER, -1, __FILE__, NULL, NULL
+/*
+ * MODULE_MAGIC_NUMBER_MINOR
+ * minor API changes that won't cause compatibility problems for older modules
+ *
+ * 00000001	- Add ap_log_rerror()
+ */
+
+#ifndef MODULE_MAGIC_NUMBER_MAJOR
+#define MODULE_MAGIC_NUMBER_MAJOR 19980808
+#endif
+#define MODULE_MAGIC_NUMBER_MINOR 00000001
+#define STANDARD_MODULE_STUFF	MODULE_MAGIC_NUMBER_MAJOR, \
+				MODULE_MAGIC_NUMBER_MINOR, \
+				-1, \
+				__FILE__, \
+				NULL, \
+				NULL
 
 /* Generic accessors for other modules to get at their own module-specific
  * data
Index: src/main/http_config.c
===================================================================
RCS file: /usr/local/covalent/.CVS/apache/apache-1.3/src/main/http_config.c,v
retrieving revision 1.120
diff -u -r1.120 http_config.c
--- http_config.c	1998/08/09 06:37:17	1.120
+++ http_config.c	1998/08/09 21:24:31
@@ -538,15 +538,10 @@
      * teased out...
      */
 
-    /* At some point, we may want to offer back-compatibility for
-     * loading modules that are for older versions of Apache. For now,
-     * though, we don't.
-     */
-
-    if (m->version != MODULE_MAGIC_NUMBER) {
+    if (m->version != MODULE_MAGIC_NUMBER_MAJOR) {
 	fprintf(stderr, "httpd: module \"%s\" is not compatible with this "
 		"version of Apache.\n", m->name);
-	fprintf(stderr, "Please contact the author for the correct version.\n");
+	fprintf(stderr, "Please contact the vendor for the correct version.\n");
 	exit(1);
     }
 
Index: src/main/http_main.c
===================================================================
RCS file: /usr/local/covalent/.CVS/apache/apache-1.3/src/main/http_main.c,v
retrieving revision 1.380
diff -u -r1.380 http_main.c
--- http_main.c	1998/08/07 15:35:49	1.380
+++ http_main.c	1998/08/09 19:45:17
@@ -3228,7 +3228,8 @@
 {
     printf("Server version: %s\n", ap_get_server_version());
     printf("Server built:   %s\n", ap_get_server_built());
-    printf("Server's Module Magic Number: %u\n", MODULE_MAGIC_NUMBER);
+    printf("Server's Module Magic Number: %u:%u\n",
+	   MODULE_MAGIC_NUMBER_MAJOR, MODULE_MAGIC_NUMBER_MINOR);
     printf("Server compiled with....\n");
 #ifdef BIG_SECURITY_HOLE
     printf(" -D BIG_SECURITY_HOLE\n");
Index: src/modules/standard/mod_info.c
===================================================================
RCS file: /usr/local/covalent/.CVS/apache/apache-1.3/src/modules/standard/mod_info.c,v
retrieving revision 1.41
diff -u -r1.41 mod_info.c
--- mod_info.c	1998/08/06 17:30:59	1.41
+++ mod_info.c	1998/08/09 19:54:32
@@ -406,8 +406,8 @@
                         "<font size=+1><tt>%s</tt></a></font><br>\n",
                         ap_get_server_built());
             ap_rprintf(r, "<strong>API Version:</strong> "
-                        "<tt>%d</tt><br>\n",
-                        MODULE_MAGIC_NUMBER);
+                        "<tt>%d:%d</tt><br>\n",
+                        MODULE_MAGIC_NUMBER_MAJOR:MODULE_MAGIC_NUMBER_MINOR);
             ap_rprintf(r, "<strong>Run Mode:</strong> <tt>%s</tt><br>\n",
                         (ap_standalone ? "standalone" : "inetd"));
             ap_rprintf(r, "<strong>User/Group:</strong> "
Index: src/modules/standard/mod_rewrite.c
===================================================================
RCS file: /usr/local/covalent/.CVS/apache/apache-1.3/src/modules/standard/mod_rewrite.c,v
retrieving revision 1.128
diff -u -r1.128 mod_rewrite.c
--- mod_rewrite.c	1998/08/06 17:31:05	1.128
+++ mod_rewrite.c	1998/08/09 19:56:59
@@ -3585,7 +3585,8 @@
         result = ap_get_server_version();
     }
     else if (strcasecmp(var, "API_VERSION") == 0) { /* non-standard */
-        ap_snprintf(resultbuf, sizeof(resultbuf), "%d", MODULE_MAGIC_NUMBER);
+        ap_snprintf(resultbuf, sizeof(resultbuf), "%d:%d",
+		    MODULE_MAGIC_NUMBER_MAJOR, MODULE_MAGIC_NUMBER_MINOR);
         result = resultbuf;
     }
 

Re: [PATCH] friendlier MODULE_MAGIC_NUMBER checks

Posted by Randy Terbush <ra...@Covalent.NET>.
Martin Kraemer <Ma...@mch.sni.de> writes:
> I like the idea. I dislike (like Dean said, and like you say in the patch)
> the duplication of mmn.txt in the comments. One of the two is okay,
> but the other must go.

I agree. Seems that it needs to be in the code.

> If you create a ap_mmn.h perhaps, which consists of the mmn
> change tracking and the defines, that file could be a possible
> replacement for mmn.txt ... And it's easier to find the information
> than if embedded in the bigger http_config.h

I like that idea IF we include the macros for MODULE_MAGIC_NUMBER_* in 
the same .h file. Makes sense to me to have them in the same place.

> What do the others think?
> 
>     Martin [sweating in hot munich. Hey! I'll go to the beergarden tonite!]

Don't taunt me. :-)


> On Sun, Aug 09, 1998 at 06:08:19PM -0500, Randy Terbush wrote:
> > The following patch attempts to split out a _MAJOR/_MINOR numbering
> > scheme. MMN_MINOR would mark the addition of new functions, etc. to
> > the API. MMN_MAJOR would reflect structure changes, etc. that cause
> > true incompatibility. I've also conditionalized the _MAJOR macro which 
> > could allow the ability to compile the server to match an older API
> > interface if we were careful about wrapping structure changes in the
> > _MAJOR macro that corresponds to it's change. Comments welcome.
> > 
> > I've also pulled the mmn.txt into http_config.h. Makes more sense to
> > me to have this distributed in the codebase. Sorry about the
> > tabs. I'll commit an expanded version if this goes into Apache.
> -- 
> | S I E M E N S |  <Ma...@mch.sni.de>  |      Siemens Nixdorf
> | ------------- |   Voice: +49-89-636-46021     |  Informationssysteme AG
> | N I X D O R F |   FAX:   +49-89-636-44994     |   81730 Munich, Germany
> ~~~~~~~~~~~~~~~~My opinions only, of course; pgp key available on request

Re: [PATCH] friendlier MODULE_MAGIC_NUMBER checks

Posted by Martin Kraemer <Ma...@mch.sni.de>.
I like the idea. I dislike (like Dean said, and like you say in the patch)
the duplication of mmn.txt in the comments. One of the two is okay,
but the other must go.

If you create a ap_mmn.h perhaps, which consists of the mmn
change tracking and the defines, that file could be a possible
replacement for mmn.txt ... And it's easier to find the information
than if embedded in the bigger http_config.h

What do the others think?

    Martin [sweating in hot munich. Hey! I'll go to the beergarden tonite!]

On Sun, Aug 09, 1998 at 06:08:19PM -0500, Randy Terbush wrote:
> The following patch attempts to split out a _MAJOR/_MINOR numbering
> scheme. MMN_MINOR would mark the addition of new functions, etc. to
> the API. MMN_MAJOR would reflect structure changes, etc. that cause
> true incompatibility. I've also conditionalized the _MAJOR macro which 
> could allow the ability to compile the server to match an older API
> interface if we were careful about wrapping structure changes in the
> _MAJOR macro that corresponds to it's change. Comments welcome.
> 
> I've also pulled the mmn.txt into http_config.h. Makes more sense to
> me to have this distributed in the codebase. Sorry about the
> tabs. I'll commit an expanded version if this goes into Apache.
-- 
| S I E M E N S |  <Ma...@mch.sni.de>  |      Siemens Nixdorf
| ------------- |   Voice: +49-89-636-46021     |  Informationssysteme AG
| N I X D O R F |   FAX:   +49-89-636-44994     |   81730 Munich, Germany
~~~~~~~~~~~~~~~~My opinions only, of course; pgp key available on request