You are viewing a plain text version of this content. The canonical link for it is here.
Posted to websh-cvs@tcl.apache.org by ro...@apache.org on 2002/03/07 15:41:25 UTC
cvs commit: tcl-websh/src/generic interpool.c interpool.h
ronnie 02/03/07 06:41:25
Modified: src/generic interpool.c interpool.h
Log:
- typecast logToAp (so it does not conflit with other plugins)
- added a numerical id to every webInterp (fo easier identification)
- always log the id and the class when logging about interps
- fixed some calls to apache log (diffs for ap 1.3 and ap 2.0)
Revision Changes Path
1.9 +47 -29 tcl-websh/src/generic/interpool.c
Index: interpool.c
===================================================================
RCS file: /home/cvs/tcl-websh/src/generic/interpool.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- interpool.c 6 Mar 2002 15:02:42 -0000 1.8
+++ interpool.c 7 Mar 2002 14:41:25 -0000 1.9
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and
* redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * @(#) $Id: interpool.c,v 1.8 2002/03/06 15:02:42 ronnie Exp $
+ * @(#) $Id: interpool.c,v 1.9 2002/03/07 14:41:25 ronnie Exp $
*
*/
@@ -25,6 +25,9 @@
#include "mod_websh.h"
#include "request.h"
#include <time.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
/* init script for main interpreter */
@@ -50,6 +53,8 @@
webInterpClass->mtime = mtime;
+ webInterpClass->nextid = 0;
+
webInterpClass->first = NULL;
webInterpClass->last = NULL;
@@ -103,8 +108,12 @@
if (webInterp->interp == NULL) {
Tcl_Free((char *) webInterp);
- ap_log_error(APLOG_MARK, APLOG_ERR, conf->server,
- "createWebInterp: Could not create interpreter\n");
+#ifndef APACHE2
+ ap_log_printf(conf->server, "createWebInterp: Could not create interpreter (id %ld, class %s)\n", webInterpClass->nextid, filename);
+#else /* APACHE2 */
+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, conf->server,
+ "createWebInterp: Could not create interpreter (id %ld, class %s)\n", webInterpClass->nextid, filename);
+#endif /* APACHE2 */
return NULL;
}
@@ -126,7 +135,7 @@
logtoap->constructor = createLogToAp;
logtoap->destructor = destroyLogToAp;
- logtoap->handler = logToAp;
+ logtoap->handler = (int (*)(Tcl_Interp *, ClientData, char *)) logToAp;
registerLogPlugIn(webInterp->interp, APCHANNEL, logtoap);
/* ------------------------------------------------------------------------
@@ -169,7 +178,8 @@
webInterp->starttime = (long) r->request_time;
webInterp->lastusedtime = (long) r->request_time;
webInterp->interpClass = webInterpClass;
-
+ webInterp->id = webInterpClass->nextid++;
+
/* add to beginning of list of webInterpClass */
webInterp->next = webInterpClass->first;
webInterpClass->first = webInterp;
@@ -193,9 +203,15 @@
}
else {
webInterp->code = NULL;
- ap_log_error(APLOG_MARK, APLOG_ERR, r->server,
- "Could not readWebInterpCode from '%s': %s\n",
- filename, Tcl_GetStringResult(webInterp->interp));
+#ifndef APACHE2
+ ap_log_printf(r->server,
+ "Could not readWebInterpCode (id %ld, class %s): %s\n",
+ webInterp->id, filename, Tcl_GetStringResult(webInterp->interp));
+#else /* APACHE2 */
+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+ "Could not readWebInterpCode (id %ld, class %s): %s\n",
+ webInterp->id, filename, Tcl_GetStringResult(webInterp->interp));
+#endif /* APACHE2 */
}
}
return webInterp;
@@ -216,9 +232,15 @@
if (result != TCL_OK) {
r = (request_rec *) Tcl_GetAssocData(webInterp->interp, WEB_AP_ASSOC_DATA, NULL);
- ap_log_error(APLOG_MARK, APLOG_ERR, r->server,
+#ifndef APACHE2
+ ap_log_printf(r->server,
"web::finalize error: %s\n",
Tcl_GetStringResult(webInterp->interp));
+#else /* APACHE2 */
+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+ "web::finalize error: %s\n",
+ Tcl_GetStringResult(webInterp->interp));
+#endif /* APACHE2 */
}
Tcl_ResetResult(webInterp->interp);
@@ -328,10 +350,8 @@
webInterp = webInterpClass->first;
while (webInterp != NULL) {
- /* fixme: make expiring message easy to understand (add
- * WebInterpClass.filename, times ...) */
logToAp(webInterp->interp, NULL,
- "interpreter expired (source changed)");
+ "interpreter expired: source changed (id %ld, class %s)", webInterp->id, webInterp->interpClass->filename);
if (webInterp->state == WIP_INUSE)
webInterp->state = WIP_EXPIREDINUSE;
else
@@ -351,14 +371,11 @@
while (webInterp != NULL) {
if ((webInterp->state) == WIP_FREE) {
- /* fixme: make expiring message easy to understand
- * (add WebInterpClass.filename, times ...) */
- /* check for expiry */
if (webInterpClass->maxidletime
&& (r->request_time - webInterp->lastusedtime) >
webInterpClass->maxidletime) {
logToAp(webInterp->interp, NULL,
- "interpreter expired (idle time reached)");
+ "interpreter expired: idle time reached (id %ld, claa %s)", webInterp->id, webInterp->interpClass->filename);
webInterp->state = WIP_EXPIRED;
}
@@ -367,7 +384,7 @@
&& (r->request_time - webInterp->starttime) >
webInterpClass->maxttl) {
logToAp(webInterp->interp, NULL,
- "interpreter expired (time to live reached)");
+ "interpreter expired: time to live reached (id %ld, class %s)", webInterp->id, webInterp->interpClass->filename);
webInterp->state = WIP_EXPIRED;
}
else {
@@ -398,9 +415,13 @@
Tcl_MutexUnlock(&(conf->webshPoolLock));
Tcl_DecrRefCount(idObj);
- /* fixme: log to apache *somehow* */
- /* logToAp(webInterp->interp,NULL,"panic - cannot create webInterpClass '%s'", id); */
-
+#ifndef APACHE2
+ ap_log_printf(conf->server,
+ "panic - cannot create webInterpClass '%s'\n", id);
+#else /* APACHE2 */
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, conf->server,
+ "panic - cannot create webInterpClass '%s'\n", id);
+#endif /* APACHE2 */
return NULL;
}
}
@@ -443,10 +464,9 @@
/* check for num requests */
- /* fixme: add interp id to log */
if (webInterpClass->maxrequests && (webInterp->numrequests >= webInterpClass->maxrequests)) {
logToAp(webInterp->interp, NULL,
- "interpreter expired (request count reached)");
+ "interpreter expired: request count reached (id %ld, class %s)", webInterp->id, webInterp->interpClass->filename);
webInterp->state = WIP_EXPIRED;
}
}
@@ -484,10 +504,10 @@
if (conf->mainInterp == NULL) {
errno = 0;
#ifndef APACHE2
- ap_log_printf(conf->server, "could'nt create main interp");
+ ap_log_printf(conf->server, "could'nt create main interp\n");
#else /* APACHE2 */
ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, 0, conf->server,
- "could'nt create main interp");
+ "could'nt create main interp\n");
#endif /* APACHE2 */
return 0;
}
@@ -563,7 +583,7 @@
}
logtoap->constructor = createLogToAp;
logtoap->destructor = destroyLogToAp;
- logtoap->handler = logToAp;
+ logtoap->handler = (int (*)(Tcl_Interp *, ClientData, char *)) logToAp;
registerLogPlugIn(mainInterp, APCHANNEL, logtoap);
/* eval init code */
@@ -637,14 +657,12 @@
/* NOTE: check on max requests is done by poolReleaseWebInterp */
if ((webInterp->state) == WIP_FREE) {
- /* fixme: put id in log (for easier debugging) */
-
/* check for expiry */
if (webInterpClass->maxidletime
&& (t - webInterp->lastusedtime) >
webInterpClass->maxidletime) {
logToAp(webInterp->interp, NULL,
- "interpreter expired (idle time reached)");
+ "interpreter expired: idle time reached (id %ld, class %s)", webInterp->id, webInterp->interpClass->filename);
webInterp->state = WIP_EXPIRED;
}
@@ -653,7 +671,7 @@
&& (t - webInterp->starttime) >
webInterpClass->maxttl) {
logToAp(webInterp->interp, NULL,
- "interpreter expired (time to live reached)");
+ "interpreter expired: time to live reached (id %ld, class %s)", webInterp->id, webInterp->interpClass->filename);
webInterp->state = WIP_EXPIRED;
}
}
1.5 +3 -1 tcl-websh/src/generic/interpool.h
Index: interpool.h
===================================================================
RCS file: /home/cvs/tcl-websh/src/generic/interpool.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- interpool.h 6 Mar 2002 13:59:21 -0000 1.4
+++ interpool.h 7 Mar 2002 14:41:25 -0000 1.5
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and
* redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * @(#) $Id: interpool.h,v 1.4 2002/03/06 13:59:21 davidw Exp $
+ * @(#) $Id: interpool.h,v 1.5 2002/03/07 14:41:25 ronnie Exp $
*
*/
@@ -57,6 +57,7 @@
long numrequests; /* number of current request */
long starttime; /* start time (Tcl does not handle time_t */
long lastusedtime; /* last used time */
+ long id; /* id of the interpreter */
/* we double-link this list so it's easier to remove elements */
struct WebInterp *next;
@@ -77,6 +78,7 @@
long maxttl;
long maxidletime;
long mtime;
+ long nextid; /* counter for ids of interpreters */
Tcl_Obj *code; /* per-request code (=file content) */
---------------------------------------------------------------------
To unsubscribe, e-mail: websh-cvs-unsubscribe@tcl.apache.org
For additional commands, e-mail: websh-cvs-help@tcl.apache.org