diff options
author | pixel <pixel> | 2008-01-23 17:41:10 +0000 |
---|---|---|
committer | pixel <pixel> | 2008-01-23 17:41:10 +0000 |
commit | b1e8c832653e00107a2b587df398a02999e21a9a (patch) | |
tree | 041ec488cfa682f8725eda812566f3b9137a8d28 | |
parent | 886ad8e7a9606bbdbac9d45d1398951d6b6a1910 (diff) |
Trying to reduce VM leaks.
-rw-r--r-- | include/LuaTask.h | 7 | ||||
-rw-r--r-- | lib/LuaHttp.cc | 4 | ||||
-rw-r--r-- | lib/LuaTask.cc | 8 |
3 files changed, 11 insertions, 8 deletions
diff --git a/include/LuaTask.h b/include/LuaTask.h index cd97900..af88059 100644 --- a/include/LuaTask.h +++ b/include/LuaTask.h @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: LuaTask.h,v 1.7 2007-12-25 15:06:12 pixel Exp $ */ +/* $Id: LuaTask.h,v 1.8 2008-01-23 17:41:10 pixel Exp $ */ #ifndef __LUATASK_H__ #define __LUATASK_H__ @@ -32,8 +32,8 @@ class LuaTask : public Task { public: - LuaTask(Lua *, const String &); - LuaTask(Lua *, int) throw (GeneralException); + LuaTask(Lua *, const String &, bool = false); + LuaTask(Lua *, int, bool = false) throw (GeneralException); virtual ~LuaTask(); virtual String GetName(); protected: @@ -50,6 +50,7 @@ class LuaTask : public Task { InPipe * p; String task; + bool destroy_VM; static htab * h; }; diff --git a/lib/LuaHttp.cc b/lib/LuaHttp.cc index 2cd13f9..fde40c3 100644 --- a/lib/LuaHttp.cc +++ b/lib/LuaHttp.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: LuaHttp.cc,v 1.24 2008-01-21 17:22:41 pixel Exp $ */ +/* $Id: LuaHttp.cc,v 1.25 2008-01-23 17:41:10 pixel Exp $ */ #include "Domain.h" #include "LuaHttp.h" @@ -415,7 +415,7 @@ void LuaDomain::Do(const HttpRequest & req, HttpResponse * res) throw (GeneralEx LuaHttpResponse r(res); r.push(L); - res->builder = new LuaTask(L, 2); + res->builder = new LuaTask(L, 2, true); } int LuaDomain::max_id = 1; diff --git a/lib/LuaTask.cc b/lib/LuaTask.cc index 0acd392..12f1db5 100644 --- a/lib/LuaTask.cc +++ b/lib/LuaTask.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: LuaTask.cc,v 1.25 2008-01-22 10:51:18 pixel Exp $ */ +/* $Id: LuaTask.cc,v 1.26 2008-01-23 17:41:10 pixel Exp $ */ #include <LuaTask.h> #include <LuaHandle.h> @@ -34,7 +34,7 @@ htab * LuaTask::h = hcreate(1); -LuaTask::LuaTask(Lua * __L, const String & _cmd) : L(__L), cmd(_cmd), nargs(0), c(0), b(0) { +LuaTask::LuaTask(Lua * __L, const String & _cmd, bool _destroy_VM) : L(__L), cmd(_cmd), nargs(0), c(0), b(0), destroy_VM(_destroy_VM) { LuaTask * top = gettop(); if (top) { @@ -46,7 +46,7 @@ LuaTask::LuaTask(Lua * __L, const String & _cmd) : L(__L), cmd(_cmd), nargs(0), stacktop = L->gettop() + 1; } -LuaTask::LuaTask(Lua * __L, int _nargs) throw (GeneralException) : L(__L), cmd(""), nargs(_nargs), c(0), b(0) { +LuaTask::LuaTask(Lua * __L, int _nargs, bool _destroy_VM) throw (GeneralException) : L(__L), cmd(""), nargs(_nargs), c(0), b(0), destroy_VM(_destroy_VM) { if (gettop()) throw GeneralException("Can't run a stack-based LuaTask when there are other tasks waiting."); @@ -59,6 +59,8 @@ LuaTask::~LuaTask() { if (gettop() == this) { settop(0); } + if (destroy_VM) + delete L; } LuaTask * LuaTask::gettop() { |