From ddf8fa7d2f3bdaaf2444acd33b69643433d043f2 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Wed, 14 May 2014 15:52:46 +1000 Subject: Trash the trash thingy that was trashing memory. Plus some debugging prints. --- src/LuaSL/LuaSL_main.c | 7 +++++++ src/LuaSL/LuaSL_threads.c | 19 +++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) (limited to 'src/LuaSL') diff --git a/src/LuaSL/LuaSL_main.c b/src/LuaSL/LuaSL_main.c index cb2726e..017c742 100644 --- a/src/LuaSL/LuaSL_main.c +++ b/src/LuaSL/LuaSL_main.c @@ -51,6 +51,7 @@ static void resetScript(script *victim) PD("RESETTING %s", victim->name); sendToChannel(ourGlobals, victim->SID, "quit()"); + eina_hash_del(ourGlobals->scripts, victim->SID, NULL); eina_hash_del(ourGlobals->names, victim->fileName, NULL); @@ -73,6 +74,12 @@ void scriptSendBack(void * data) scriptMessage *message = data; gameGlobals *ourGlobals = message->script->game; + if (!message->script) + { + PE("scriptSendBack script is NULL"); + return; + } + if (0 == strncmp(message->message, "llSleep(", 8)) ecore_timer_add(atof(&(message->message)[8]), _sleep_timer_cb, message->script); else if (0 == strncmp(message->message, "llSetTimerEvent(", 16)) diff --git a/src/LuaSL/LuaSL_threads.c b/src/LuaSL/LuaSL_threads.c index e326e14..4746808 100644 --- a/src/LuaSL/LuaSL_threads.c +++ b/src/LuaSL/LuaSL_threads.c @@ -186,20 +186,24 @@ static void *workermain( void *args ) { /* check if process finished its whole execution, then recycle it */ if (procstat == 0) { - recycled *trash = malloc(sizeof(recycled)); +// recycled *trash = malloc(sizeof(recycled)); + // TODO - Trash stuff trashes memory, fix it. + // Later, it's an optimization we don't need right now. +/* if (trash) { trash->L = lp->L; pthread_mutex_lock(&mutex_recycle_list); eina_clist_add_tail(&recyclelp, &(trash->node)); pthread_mutex_unlock(&mutex_recycle_list); - sched_lpcount_dec(); } +*/ + sched_lpcount_dec(); lua_close(lp->L); if (lp->timer) ecore_timer_del(lp->timer); - free(lp); +// free(lp); } /* check if process yielded */ @@ -295,7 +299,7 @@ int sched_create_worker(void) void newProc(const char *code, int file, script *lp) { int ret; - recycled *trash; +// recycled *trash; // Try to recycle a Lua state, otherwise create one from scratch. #if 0 // TODO - something about this causes a crash. @@ -401,6 +405,13 @@ const char *sendToChannel(gameGlobals *ourGlobals, const char *SID, const char * const char *result = NULL; script *dstlp; + if (!message) + { + PE("sendToChannel NULL message to %s", SID); + return NULL; + } +// PD("sendToChannel message to %s -> %s", SID, message); + /* get exclusive access to operate on channels */ pthread_mutex_lock(&mutex_channel); -- cgit v1.1