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/07/25 00:29:24 UTC
cvs commit: tcl-websh/src/generic interpool.c
ronnie 2002/07/24 15:29:24
Modified: src/generic interpool.c
Log:
- added flag to Websh_Init (proper initialization to fix memory leak)
- fixed return w/o unlock (poolGetWebInterp)
- added \'proper\' initialization of Websh_init (initPool) I know it\'s a hack, but there is no other way, is there?
Revision Changes Path
1.14 +32 -4 tcl-websh/src/generic/interpool.c
Index: interpool.c
===================================================================
RCS file: /home/cvs/tcl-websh/src/generic/interpool.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- interpool.c 5 Apr 2002 08:13:27 -0000 1.13
+++ interpool.c 24 Jul 2002 22:29:23 -0000 1.14
@@ -121,7 +121,8 @@
/* now register here all websh modules */
result = Tcl_Init(webInterp->interp);
/* checkme: test result */
- result = Websh_Init(webInterp->interp);
+
+ result = Websh_Init(webInterp->interp, 0);
/* also register the destrcutor, etc. functions, passing webInterp as
client data */
@@ -214,6 +215,7 @@
#endif /* APACHE2 */
}
}
+
return webInterp;
}
@@ -297,10 +299,11 @@
/* get interpreter id for filename */
+ Tcl_MutexLock(&(conf->mainInterpLock));
+
mapCmd = Tcl_NewStringObj("web::interpmap ", -1);
- Tcl_AppendToObj(mapCmd, filename, -1);
Tcl_IncrRefCount(mapCmd);
- Tcl_MutexLock(&(conf->mainInterpLock));
+ Tcl_AppendToObj(mapCmd, filename, -1);
res = Tcl_EvalObjEx(conf->mainInterp, mapCmd, 0);
@@ -324,6 +327,8 @@
if (Tcl_Access(id, R_OK) != 0 ||
Tcl_Stat(id, &statPtr) != TCL_OK)
{
+ Tcl_MutexUnlock(&(conf->mainInterpLock));
+ Tcl_DecrRefCount(mapCmd);
return NULL;
}
mtime = statPtr.st_mtime;
@@ -345,6 +350,7 @@
webInterpClass = (WebInterpClass *) Tcl_GetHashValue(entry);
/* check if mtime is ok */
+
if (mtime > webInterpClass->mtime) {
/* invalidate all interpreters, code must be loaded from scratch */
webInterp = webInterpClass->first;
@@ -475,6 +481,7 @@
cleanupPool(webInterpClass->conf);
Tcl_MutexUnlock(&(webInterpClass->conf->webshPoolLock));
+
}
}
@@ -511,6 +518,27 @@
return 0;
}
+ /* create one interp to initialize the exit handlers properly */
+ {
+ Tcl_Interp* interp = NULL;
+ interp = Tcl_CreateInterp();
+ if (interp != NULL) {
+ /* checkme: we should really check the results here ... */
+ Tcl_Init(interp);
+ Websh_Init(interp, 1);
+ Tcl_DeleteInterp(interp);
+ } else {
+ errno = 0;
+#ifndef APACHE2
+ ap_log_printf(conf->server, "could'nt create initial interp\n");
+#else /* APACHE2 */
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, 0, conf->server,
+ "could'nt create initial interp\n");
+#endif /* APACHE2 */
+ return 0;
+ }
+ }
+
/* create our table of interp classes */
HashUtlAllocInit(conf->webshPool, TCL_STRING_KEYS);
---------------------------------------------------------------------
To unsubscribe, e-mail: websh-cvs-unsubscribe@tcl.apache.org
For additional commands, e-mail: websh-cvs-help@tcl.apache.org