Rev 4827: (andrew) Use siginterrupt to automatically restart syscalls after in file:///home/pqm/archives/thelove/bzr/2.1/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Mar 11 04:05:59 GMT 2010


At file:///home/pqm/archives/thelove/bzr/2.1/

------------------------------------------------------------
revno: 4827 [merge]
revision-id: pqm at pqm.ubuntu.com-20100311040555-2caxrq5goaltby3x
parent: pqm at pqm.ubuntu.com-20100310051001-xoxuio7z7sh27n1w
parent: andrew.bennetts at canonical.com-20100311011907-rhelqnxfqtpd587g
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: 2.1
timestamp: Thu 2010-03-11 04:05:55 +0000
message:
  (andrew) Use siginterrupt to automatically restart syscalls after
  	SIGWINCH, if we register a SIGWINCH handler. (#496813)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/osutils.py              osutils.py-20050309040759-eeaff12fbf77ac86
=== modified file 'NEWS'
--- a/NEWS	2010-03-07 13:35:42 +0000
+++ b/NEWS	2010-03-11 01:19:07 +0000
@@ -14,11 +14,22 @@
 Bug Fixes
 *********
 
+* Allow syscalls to automatically restart when ``TextUIFactory``'s
+  SIGWINCH handler is invoked, avoiding ``EINTR`` errors during blocking
+  IO, which are often poorly handled by Python's libraries and parts of
+  bzrlib.  (Andrew Bennetts, #496813)
+
+* Avoid ``malloc(0)`` in ``patiencediff``, which is non-portable.
+  (Martin Pool, #331095)
+
 * Fix plugin packaging on Windows. (Ian Clatworthy, #524162)
 
 * Fix stub sftp test server to call os.getcwdu().
   (Vincent Ladeuil, #526211, #526353)
 
+* Fixed CHM generation by moving the NEWS section template into
+  a separate file. (Ian Clatworthy, #524184)
+
 * Merge correctly when this_tree is not a WorkingTree.  (Aaron Bentley)
 
 * Register SIGWINCH handler only when creating a ``TextUIFactory``; avoids
@@ -43,6 +54,14 @@
 * Drop Google Analytics from the core docs as they caused problems
   in the CHM files. (Ian Clatworthy, #502010)
 
+API Changes
+***********
+
+* Added ``bzrlib.osutils.set_signal_handler``, a convenience function that
+  can set a signal handler and call ``signal.siginterrupt(signum,
+  False)`` for it, if the platform and Python version supports it.
+  (Andrew Bennetts, #496813)
+
 
 bzr 2.1.0
 #########
@@ -367,8 +386,8 @@
   (Martin Pool)
 
 
-bzr 2.0.5 (not released yet)
-############################
+bzr 2.0.5
+#########
 
 :Codename:
 :2.0.5: NOT RELEASED YET

=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py	2010-03-05 07:49:31 +0000
+++ b/bzrlib/osutils.py	2010-03-11 00:13:08 +0000
@@ -1347,6 +1347,27 @@
     normalized_filename = _inaccessible_normalized_filename
 
 
+def set_signal_handler(signum, handler, restart_syscall=True):
+    """A wrapper for signal.signal that also calls siginterrupt(signum, False)
+    on platforms that support that.
+
+    :param restart_syscall: if set, allow syscalls interrupted by a signal to
+        automatically restart (by calling `signal.siginterrupt(signum,
+        False)`).  May be ignored if the feature is not available on this
+        platform or Python version.
+    """
+    old_handler = signal.signal(signum, handler)
+    if restart_syscall:
+        try:
+            siginterrupt = signal.siginterrupt
+        except AttributeError: # siginterrupt doesn't exist on this platform, or for this version of
+            # Python.
+            pass
+        else:
+            siginterrupt(signum, False)
+    return old_handler
+
+
 default_terminal_width = 80
 """The default terminal width for ttys.
 
@@ -1454,7 +1475,7 @@
             # the current design -- vila 20091216
             pass
         else:
-            signal.signal(signal.SIGWINCH, _terminal_size_changed)
+            set_signal_handler(signal.SIGWINCH, _terminal_size_changed)
         _registered_sigwinch = True
 
 




More information about the bazaar-commits mailing list