~ubuntu-branches/ubuntu/trusty/screen/trusty-proposed

« back to all changes in this revision

Viewing changes to debian/patches/19flowcontrol_lockup.dpatch

  • Committer: Bazaar Package Importer
  • Author(s): Jan Christoph Nordholz
  • Date: 2008-06-12 19:33:30 UTC
  • mfrom: (1.1.13 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080612193330-1tt3qhpxonbgdmq2
Tags: 4.0.3-11
* Unbreak <End> and <^A Bksp> using a patch from Loïc Minier
  (thanks!) - introduced as new 45suppress_remap.dpatch.
  Closes: #484647.
* Bump Standards version to 3.8.0. No changes necessary.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh /usr/share/dpatch/dpatch-run
 
2
## 19flowcontrol_lockup.dpatch by  <hesso@pool.math.tu-berlin.de>
 
3
##
 
4
## DP: Make Flush() truly non-blocking by employing an extra select().
 
5
## DP: Thus D_userfd is assured to be in non-blocking mode on return
 
6
## DP: (even if the return was premature due to select() timing out),
 
7
## DP: so the SetTTY() call in FreeDisplay() doesn't have to be
 
8
## DP: safeguarded on its own.
 
9
## DP: 
 
10
## DP: Note - I'm not satisfied at all with this patch, but I consider
 
11
## DP: it an ugly but working kluge, meant only to stay around as long
 
12
## DP: as upstream hasn't come up with anything better.
 
13
 
 
14
@DPATCH@
 
15
diff -Naur screen-4.0.3.orig/display.c screen-4.0.3/display.c
 
16
--- screen-4.0.3.orig/display.c 2008-06-01 23:41:50.000000000 +0200
 
17
+++ screen-4.0.3/display.c      2008-06-01 23:44:57.000000000 +0200
 
18
@@ -3556,6 +3556,8 @@
 
19
 {
 
20
   register int l;
 
21
   register char *p;
 
22
+  fd_set fd_s;
 
23
+  struct timeval sO;
 
24
 
 
25
   ASSERT(display);
 
26
   l = D_obufp - D_obuf;
 
27
@@ -3570,15 +3572,29 @@
 
28
       return;
 
29
     }
 
30
   p = D_obuf;
 
31
-  if (fcntl(D_userfd, F_SETFL, 0))
 
32
-    debug1("Warning: BLOCK fcntl failed: %d\n", errno);
 
33
+  if (fcntl(D_userfd, F_SETFL, FNBLOCK))
 
34
+    debug1("Warning: NBLOCK fcntl failed: %d\n", errno);
 
35
+  if (D_blocked == 1)
 
36
+    D_blocked = 0;
 
37
+  D_blocked_fuzz = 0;
 
38
   while (l)
 
39
     {
 
40
-      register int wr;
 
41
+      register int wr = 0;
 
42
+      sO.tv_sec = 5; sO.tv_usec = 0;
 
43
+      while (1) {
 
44
+        int sR;
 
45
+        FD_ZERO(&fd_s);
 
46
+        FD_SET(D_userfd, &fd_s);
 
47
+        sR = select(D_userfd+1, NULL, &fd_s, NULL, &sO);
 
48
+        if (!sR) {
 
49
+          debug("Timeout while waiting for display write fd to unblock\n");
 
50
+          return;
 
51
+        } else if (sR > 0) break;
 
52
+      }
 
53
       wr = write(D_userfd, p, l);
 
54
       if (wr <= 0) 
 
55
        {
 
56
-         if (errno == EINTR) 
 
57
+         if (errno == EINTR || errno == EAGAIN) 
 
58
            continue;
 
59
          debug1("Writing to display: %d\n", errno);
 
60
          wr = l;
 
61
@@ -3591,11 +3607,6 @@
 
62
     }
 
63
   D_obuffree += l;
 
64
   D_obufp = D_obuf;
 
65
-  if (fcntl(D_userfd, F_SETFL, FNBLOCK))
 
66
-    debug1("Warning: NBLOCK fcntl failed: %d\n", errno);
 
67
-  if (D_blocked == 1)
 
68
-    D_blocked = 0;
 
69
-  D_blocked_fuzz = 0;
 
70
 }
 
71
 
 
72
 void