httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexei Kosut <ako...@organic.com>
Subject Globals and their non-use in Apache-NT
Date Tue, 08 Jul 1997 22:08:42 GMT
Following up on my previous email, where I discovered that if a module
makes use of an "API global" variable, it won't work as a DLL in Windows,
I examined all the modules in the Apache distribution, and came up with
four that use global variables:

1. mod_usertrack made use of a list of month names in util.c. I just
   commited (along with other Windows fixes to mod_usertrack) a patch
   that gets rid of it.

2. mod_status needs restart_time, set in http_main. I've enclosed a patch
   below that adds a get_restart_time() function.

3. mod_cgi checks suexec_enabled, a global variable. We should probably
   wrapper this one as well. However, this is not a high priority, as
   IMHO mod_cgi is a "standard" module, and will probably be compiled
   into the server no matter what.

4. mod_dld uses server_argv0. I'm even less worried about that, since
   mod_dld hardly works with Unix, let alone Windows. The mod_dll I
   posted earlier, which works fine, doesn't need to access that
   variable.

Here's the patch to make mod_status work. Note that it should be
accompanied by a bump to MODULE_MAGIC_NUMBER, as it adds a new API
function:

Index: http_main.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_main.c,v
retrieving revision 1.174
diff -u -r1.174 http_main.c
--- http_main.c	1997/07/07 14:34:26	1.174
+++ http_main.c	1997/07/08 22:02:57
@@ -1190,6 +1190,14 @@
 
 }
 
+/* This is in a global, but we can't always get to it, so we can use
+ * a function instead.
+ */
+
+time_t get_restart_time (void) {
+    return restart_time;
+}
+
 static void increment_counts (int child_num, request_rec *r)
 {
     long int bs=0;
Index: mod_status.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_status.c,v
retrieving revision 1.51
diff -u -r1.51 mod_status.c
--- mod_status.c	1997/07/07 14:34:28	1.51
+++ mod_status.c	1997/07/08 22:02:59
@@ -193,7 +193,7 @@
     };
     char *loc;
     time_t nowtime=time(NULL);
-    time_t up_time;
+    time_t up_time, rs_time;
     int i,res;
     int ready=0;
     int busy=0;
@@ -308,7 +308,8 @@
 #endif /* STATUS */
     }
 
-    up_time=nowtime-restart_time;
+    rs_time = get_restart_time();
+    up_time = nowtime-rs_time;
 
     hard_timeout("send status info", r);
 
@@ -318,7 +319,7 @@
         rputs("<H1>Apache Server Status for ",r);
 	rvputs(r,server->server_hostname,"</H1>\n\n",NULL);
 	rvputs(r,"Current Time: ",asctime(localtime(&nowtime)),"<br>\n",NULL);
-	rvputs(r,"Restart Time: ",asctime(localtime(&restart_time)),"<br>\n",
+	rvputs(r,"Restart Time: ",asctime(localtime(&rs_time)),"<br>\n",
 	       NULL);
 	rputs("Server uptime: ",r);
 	show_time(r,up_time);
Index: scoreboard.h
===================================================================
RCS file: /export/home/cvs/apache/src/scoreboard.h,v
retrieving revision 1.24
diff -u -r1.24 scoreboard.h
--- scoreboard.h	1997/07/07 14:34:28	1.24
+++ scoreboard.h	1997/07/08 22:02:59
@@ -118,6 +118,8 @@
 short_score get_scoreboard_info(int x);
 int exists_scoreboard_image ();
 
+time_t get_restart_time(void);
+
 /* for time_process_request() in http_main.c */
 #define START_PREQUEST 1
 #define STOP_PREQUEST  2


-- Alexei Kosut <akosut@organic.com>


Mime
View raw message