Code

perl plugin: Fixed error in ithread shutdown loop.
authorSebastian Harl <sh@tokkee.org>
Sun, 18 Nov 2007 19:37:36 +0000 (20:37 +0100)
committerFlorian Forster <octo@noris.net>
Tue, 20 Nov 2007 08:30:26 +0000 (08:30 +0000)
Using the sfree() macro, the loop variable was accidentally set to NULL at the
end of the loop, causing the loop to terminate after the first iteration.

src/perl.c

index d6371dbacffa4e06166e229fb06184d8e74130b8..5cec1ed8bfcf04d06af57452234b891aa1527bfb 100644 (file)
@@ -945,9 +945,13 @@ static int perl_shutdown (void)
        t = perl_threads->tail;
 
        while (NULL != t) {
+               c_ithread_t *last = NULL;
+
                aTHX = t->interp;
                PERL_SET_CONTEXT (aTHX);
 
+               log_debug ("Shutting down Perl interpreter %p...", aTHX);
+
 #if COLLECT_DEBUG
                sv_report_used ();
 #endif /* COLLECT_DEBUG */
@@ -955,9 +959,10 @@ static int perl_shutdown (void)
                perl_destruct (aTHX);
                perl_free (aTHX);
 
+               last = t;
                t = t->prev;
 
-               sfree (t);
+               sfree (last);
        }
 
        pthread_mutex_unlock (&perl_threads->mutex);