[maemo-commits] [maemo-commits] r10178 - in projects/haf/trunk/python: Modules debian

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Thu Feb 22 16:11:17 EET 2007
Author: luciano
Date: 2007-02-22 16:11:11 +0200 (Thu, 22 Feb 2007)
New Revision: 10178

Modified:
   projects/haf/trunk/python/Modules/signalmodule.c
   projects/haf/trunk/python/debian/changelog
   projects/haf/trunk/python/debian/control
   projects/haf/trunk/python/debian/rules
Log:
fix on race conditions with signals and fix generating pyexpat module

Modified: projects/haf/trunk/python/Modules/signalmodule.c
===================================================================
--- projects/haf/trunk/python/Modules/signalmodule.c	2007-02-22 14:11:04 UTC (rev 10177)
+++ projects/haf/trunk/python/Modules/signalmodule.c	2007-02-22 14:11:11 UTC (rev 10178)
@@ -75,7 +75,8 @@
         PyObject *func;
 } Handlers[NSIG];
 
-static int is_tripped = 0; /* Speed up sigcheck() when none tripped */
+/* Speed up sigcheck() when none tripped */
+static volatile sig_atomic_t is_tripped = 0;
 
 static PyObject *DefaultHandler;
 static PyObject *IgnoreHandler;
@@ -122,7 +123,7 @@
 	/* See NOTES section above */
 	if (getpid() == main_pid) {
 #endif
-		is_tripped++;
+		is_tripped = 1;
 		Handlers[sig_num].tripped = 1;
 		Py_AddPendingCall(checksignals_witharg, NULL);
 #ifdef WITH_THREAD
@@ -597,13 +598,31 @@
 
 	if (!is_tripped)
 		return 0;
+
 #ifdef WITH_THREAD
 	if (PyThread_get_thread_ident() != main_thread)
 		return 0;
 #endif
+
+	/*
+	 * The is_stripped variable is meant to speed up the calls to
+	 * PyErr_CheckSignals (both directly or via pending calls) when no
+	 * signal has arrived. This variable is set to 1 when a signal arrives
+	 * and it is set to 0 here, when we know some signals arrived. This way
+	 * we can run the registered handlers with no signals blocked.
+	 *
+	 * NOTE: with this approach we can have a situation where is_tripped is
+	 *       1 but we have no more signals to handle (Handlers[i].tripped
+	 *       is 0 for every signal i). This won't do us any harm (except
+	 *       we're gonna spent some cycles for nothing). This happens when
+	 *       we receive a signal i after we zero is_tripped and before we
+	 *       check Handlers[i].tripped.
+	 */
+	is_tripped = 0;
+
 	if (!(f = (PyObject *)PyEval_GetFrame()))
 		f = Py_None;
-	
+
 	for (i = 1; i < NSIG; i++) {
 		if (Handlers[i].tripped) {
 			PyObject *result = NULL;
@@ -621,7 +640,7 @@
 			Py_DECREF(result);
 		}
 	}
-	is_tripped = 0;
+
 	return 0;
 }
 
@@ -632,8 +651,8 @@
 void
 PyErr_SetInterrupt(void)
 {
-	is_tripped++;
 	Handlers[SIGINT].tripped = 1;
+	is_tripped = 1;
 	Py_AddPendingCall((int (*)(void *))PyErr_CheckSignals, NULL);
 }
 

Modified: projects/haf/trunk/python/debian/changelog
===================================================================
--- projects/haf/trunk/python/debian/changelog	2007-02-22 14:11:04 UTC (rev 10177)
+++ projects/haf/trunk/python/debian/changelog	2007-02-22 14:11:11 UTC (rev 10178)
@@ -1,3 +1,10 @@
+python2.5 (2.5.0-1osso10) unstable; urgency=low
+
+  * leaves pyexpat module inside python package 
+  * bugfix on race condition with signals
+
+ -- Luciano Miguel Wolf <luciano.wolf at indt.org.br>  Thu, 22 Feb 2007 09:15:00 -0300
+
 python2.5 (2.5.0-1osso9) unstable; urgency=low
 
   * compiled with sqlite3 support

Modified: projects/haf/trunk/python/debian/control
===================================================================
--- projects/haf/trunk/python/debian/control	2007-02-22 14:11:04 UTC (rev 10177)
+++ projects/haf/trunk/python/debian/control	2007-02-22 14:11:11 UTC (rev 10178)
@@ -2,7 +2,7 @@
 Section: python
 Priority: optional
 Maintainer: Osvaldo Santana Neto <osvaldo.santana at indt.org.br>
-Build-Depends: debhelper (>= 4.2), autoconf, zlib1g-dev, libssl-dev, libbz2-dev, libsqlite3-dev (>= 3.3.5-0.2osso1)
+Build-Depends: debhelper (>= 4.2), autoconf, zlib1g-dev, libssl-dev, libbz2-dev, libsqlite3-dev (>= 3.3.5-0.2osso1), dpatch
 Standards-Version: 3.6.2
 
 Package: python2.5

Modified: projects/haf/trunk/python/debian/rules
===================================================================
--- projects/haf/trunk/python/debian/rules	2007-02-22 14:11:04 UTC (rev 10177)
+++ projects/haf/trunk/python/debian/rules	2007-02-22 14:11:11 UTC (rev 10178)
@@ -79,12 +79,13 @@
 	    $(d_dev)/$(scriptdir)/lib-dynload/audioop.so \
 	    $(d_dev)/$(scriptdir)/lib-dynload/_ctypes_test.so \
 	    $(d_dev)/$(scriptdir)/lib-dynload/_testcapi.so \
-	    $(d_dev)/$(scriptdir)/lib-dynload/pyexpat.so \
 	    $(d_dev)/$(scriptdir)/idlelib \
 	    $(d_dev)/$(scriptdir)/lib-tk \
 	    $(d_dev)/$(scriptdir)/bsddb \
 	    $(d_dev)/$(scriptdir)/xml/{dom,parsers,sax}
 
+#	$(d_dev)/$(scriptdir)/lib-dynload/pyexpat.so \
+
 	# base
 	# ====
 


More information about the maemo-commits mailing list