From d076bec040618db19cecc05d952a90b78e248251 Mon Sep 17 00:00:00 2001
From: benoit-germain <bnt.germain@gmail.com>
Date: Mon, 25 Jun 2012 11:16:45 +0300
Subject: fix crash at application exit when encountering a blocked lane on
 which lane:cancel() has been called. (issue #28).

---
 src/lanes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'src')

diff --git a/src/lanes.c b/src/lanes.c
index b1c4018..eebe06a 100644
--- a/src/lanes.c
+++ b/src/lanes.c
@@ -1057,7 +1057,7 @@ static int selfdestruct_atexit( lua_State *L)
         while( s != SELFDESTRUCT_END )
         {
             // attempt a regular unforced cancel with a small timeout
-            bool_t cancelled = thread_cancel( s, 0.0001, FALSE);
+            bool_t cancelled = THREAD_ISNULL( s->thread) || thread_cancel( s, 0.0001, FALSE);
             // if we failed, and we know the thread is waiting on a linda
             if( cancelled == FALSE && s->status == WAITING && s->waiting_on != NULL)
             {
-- 
cgit v1.2.3-55-g6feb