develooper Front page | perl.perl5.porters | Postings from August 2001

[PATCH] Patch to patch for callbacks in core

Thread Next
From:
David M. Lloyd
Date:
August 21, 2001 13:35
Subject:
[PATCH] Patch to patch for callbacks in core
Message ID:
Pine.LNX.4.33.0108211533490.1027-100000@homebody.freemm.org
I should have tested this better before submitting it.  This patch is to
Perl 11722 after applying my previous patch.

Now callbacks will actually work. :-)

- D

<dmlloyd@tds.net>

--- mg.c-old	Tue Aug 21 13:26:52 2001
+++ perl-devel/mg.c	Tue Aug 21 15:09:16 2001
@@ -1068,7 +1068,18 @@
 void
 Perl_despatch_signals(pTHX)
 {
-    PL_event_pending = 0;
+    if (PL_callback_head != NULL) {
+	CALLBACK *cur, *next;
+
+        for (cur = PL_callback_head; cur != NULL; cur = next) {
+            next = cur->next;
+            (*cur->callback)(cur->data);
+        }
+    } else {
+	MUTEX_LOCK(&PL_callback_mutex);
+    	PL_event_pending = (PL_callback_head != NULL);
+	MUTEX_UNLOCK(&PL_callback_mutex);
+    }
     if (PL_sig_pending) {
 	int sig;
 	PL_sig_pending = 0;
@@ -1079,14 +1090,6 @@
 	    }
 	}
     }
-    if (PL_callback_head != NULL) {
-	CALLBACK *cur, *next;
-
-        for (cur = PL_callback_head; cur != NULL; cur = next) {
-            next = cur->next;
-            (*cur->callback)(cur->data);
-        }
-    }
 }

 /*
@@ -1133,6 +1136,7 @@
 	cbptr->prev = NULL;
 	PL_callback_head = cbptr;
 	cbptr->enabled = 1;
+	PL_event_pending = 1;
     }

     MUTEX_UNLOCK(&PL_callback_mutex);


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About