aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/LuaSL
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-05-14 15:52:46 +1000
committerDavid Walter Seikel2014-05-14 15:52:46 +1000
commitddf8fa7d2f3bdaaf2444acd33b69643433d043f2 (patch)
tree961aad69c308a235fb6d37b036306198af61ff50 /src/LuaSL
parentA little clean up. (diff)
downloadSledjHamr-ddf8fa7d2f3bdaaf2444acd33b69643433d043f2.zip
SledjHamr-ddf8fa7d2f3bdaaf2444acd33b69643433d043f2.tar.gz
SledjHamr-ddf8fa7d2f3bdaaf2444acd33b69643433d043f2.tar.bz2
SledjHamr-ddf8fa7d2f3bdaaf2444acd33b69643433d043f2.tar.xz
Trash the trash thingy that was trashing memory. Plus some debugging prints.
Diffstat (limited to 'src/LuaSL')
-rw-r--r--src/LuaSL/LuaSL_main.c7
-rw-r--r--src/LuaSL/LuaSL_threads.c19
2 files changed, 22 insertions, 4 deletions
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)
51 51
52 PD("RESETTING %s", victim->name); 52 PD("RESETTING %s", victim->name);
53 sendToChannel(ourGlobals, victim->SID, "quit()"); 53 sendToChannel(ourGlobals, victim->SID, "quit()");
54
54 eina_hash_del(ourGlobals->scripts, victim->SID, NULL); 55 eina_hash_del(ourGlobals->scripts, victim->SID, NULL);
55 eina_hash_del(ourGlobals->names, victim->fileName, NULL); 56 eina_hash_del(ourGlobals->names, victim->fileName, NULL);
56 57
@@ -73,6 +74,12 @@ void scriptSendBack(void * data)
73 scriptMessage *message = data; 74 scriptMessage *message = data;
74 gameGlobals *ourGlobals = message->script->game; 75 gameGlobals *ourGlobals = message->script->game;
75 76
77 if (!message->script)
78 {
79 PE("scriptSendBack script is NULL");
80 return;
81 }
82
76 if (0 == strncmp(message->message, "llSleep(", 8)) 83 if (0 == strncmp(message->message, "llSleep(", 8))
77 ecore_timer_add(atof(&(message->message)[8]), _sleep_timer_cb, message->script); 84 ecore_timer_add(atof(&(message->message)[8]), _sleep_timer_cb, message->script);
78 else if (0 == strncmp(message->message, "llSetTimerEvent(", 16)) 85 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 ) {
186 /* check if process finished its whole execution, then recycle it */ 186 /* check if process finished its whole execution, then recycle it */
187 if (procstat == 0) 187 if (procstat == 0)
188 { 188 {
189 recycled *trash = malloc(sizeof(recycled)); 189// recycled *trash = malloc(sizeof(recycled));
190 190
191 // TODO - Trash stuff trashes memory, fix it.
192 // Later, it's an optimization we don't need right now.
193/*
191 if (trash) 194 if (trash)
192 { 195 {
193 trash->L = lp->L; 196 trash->L = lp->L;
194 pthread_mutex_lock(&mutex_recycle_list); 197 pthread_mutex_lock(&mutex_recycle_list);
195 eina_clist_add_tail(&recyclelp, &(trash->node)); 198 eina_clist_add_tail(&recyclelp, &(trash->node));
196 pthread_mutex_unlock(&mutex_recycle_list); 199 pthread_mutex_unlock(&mutex_recycle_list);
197 sched_lpcount_dec();
198 } 200 }
201*/
202 sched_lpcount_dec();
199 lua_close(lp->L); 203 lua_close(lp->L);
200 if (lp->timer) 204 if (lp->timer)
201 ecore_timer_del(lp->timer); 205 ecore_timer_del(lp->timer);
202 free(lp); 206// free(lp);
203 } 207 }
204 208
205 /* check if process yielded */ 209 /* check if process yielded */
@@ -295,7 +299,7 @@ int sched_create_worker(void)
295void newProc(const char *code, int file, script *lp) 299void newProc(const char *code, int file, script *lp)
296{ 300{
297 int ret; 301 int ret;
298 recycled *trash; 302// recycled *trash;
299 303
300 // Try to recycle a Lua state, otherwise create one from scratch. 304 // Try to recycle a Lua state, otherwise create one from scratch.
301#if 0 // TODO - something about this causes a crash. 305#if 0 // TODO - something about this causes a crash.
@@ -401,6 +405,13 @@ const char *sendToChannel(gameGlobals *ourGlobals, const char *SID, const char *
401 const char *result = NULL; 405 const char *result = NULL;
402 script *dstlp; 406 script *dstlp;
403 407
408 if (!message)
409 {
410 PE("sendToChannel NULL message to %s", SID);
411 return NULL;
412 }
413// PD("sendToChannel message to %s -> %s", SID, message);
414
404 /* get exclusive access to operate on channels */ 415 /* get exclusive access to operate on channels */
405 pthread_mutex_lock(&mutex_channel); 416 pthread_mutex_lock(&mutex_channel);
406 417