gregames 2002/06/03 14:06:52
Modified: specweb99/specweb99-2.0 mod_specweb99.c
Log:
Elimimate stat() and time() overhead caused by trying to detect if the
Custom.Ads file changed. It changes only when a command/Reset housekeeping
URI is processed, which also updates the User.Profile file. So if
User.Profile has changed, unconditionally get a new copy of Custom.Ads.
Revision Changes Path
1.5 +17 -33 httpd-test/specweb99/specweb99-2.0/mod_specweb99.c
Index: mod_specweb99.c
===================================================================
RCS file: /home/cvs/httpd-test/specweb99/specweb99-2.0/mod_specweb99.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- mod_specweb99.c 3 Jun 2002 19:29:56 -0000 1.4
+++ mod_specweb99.c 3 Jun 2002 21:06:52 -0000 1.5
@@ -108,7 +108,6 @@
char *upfgen99;
apr_time_t up_lastmod;
- apr_time_t cad_lastmod;
apr_time_t check;
@@ -131,6 +130,10 @@
static const char boilerplate_end[] = BOILERPLATE_END;
static const int boilerplate_end_len = sizeof(boilerplate_end) - 1;
+static apr_int16_t
+getCADFile(struct server_rec *sv, struct request_rec *r,
+ struct specweb99_module_data * _my);
+
/* Use interal locking - the main reason for doing
* so is error trapping and being able to warn/info
* when we spend a lot of time in camping on a lock.
@@ -432,21 +435,27 @@
apr_file_close(f);
/* Store last modified date assuming no errors. */
- if (e)
+ if (e) {
_my->up_lastmod = 0;
- else
- _my->up_lastmod = s.mtime;
+ return e;
+ }
+ _my->up_lastmod = s.mtime;
- return e;
+ /*
+ * Since User.Profile changed, we need to get a new copy of
+ * Custom.Ads as well
+ */
+
+ return getCADFile(sv, r, _my);
}
/***********************************************************************
- * checkCADFile *
+ * getCADFile *
***********************************************************************/
static apr_int16_t
-checkCADFile(struct server_rec *sv, struct request_rec *r,
+getCADFile(struct server_rec *sv, struct request_rec *r,
struct specweb99_module_data * _my)
{
apr_finfo_t s;
@@ -456,14 +465,6 @@
char cadline[CADRLENGTH];
apr_uint16_t cad_uid;
int e = 0;
- apr_time_t now;
-
- now = time(NULL);
- if(_my->check == now)
- return 0;
- _my->check == now;
-
- /* Stat it, compare to stored modification time */
if ((rv =
apr_stat(&s, _my->cad_path, APR_FINFO_SIZE | APR_FINFO_MTIME,
@@ -473,10 +474,6 @@
return 1;
};
- if (s.mtime == _my->cad_lastmod) {
- return 0;
- }
-
/*
* Need to read file into memory - and re-allocate the array if the
* size has changed.
@@ -554,11 +551,6 @@
apr_file_close(f);
- if (e)
- _my->cad_lastmod = 0;
- else
- _my->cad_lastmod = s.mtime;
-
return e;
}
@@ -569,7 +561,6 @@
apr_pcalloc(p, sizeof(struct specweb99_module_data));
_my->up_lastmod = (apr_time_t) 0L;
- _my->cad_lastmod = (apr_time_t) 0L;
_my->up = NULL;
_my->cad = NULL;
@@ -590,7 +581,7 @@
__TIME__);
ap_log_error(APLOG_MARK, APLOG_INFO | APLOG_NOERRNO, 0, s, "%s",
- "$Id: mod_specweb99.c,v 1.4 2002/06/03 19:29:56 gregames Exp $");
+ "$Id: mod_specweb99.c,v 1.5 2002/06/03 21:06:52 gregames Exp $");
return 0;
} /* specweb99_module_init */
@@ -1004,13 +995,6 @@
}
userdemographics = _my->up[userindex];
-
- if (checkCADFile(r->server, r, _my)) {
- returnHTMLPageWithMessage(r, "Error: Ad file check failed.");
- ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, 0, r->server,
- "Ad file check failed");
- return HTTP_INTERNAL_SERVER_ERROR;
- }
adindex = (last_ad + 1) % 360;
/*