about summary refs log tree commit diff stats
path: root/src/buffer
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-06-07 13:15:17 +0200
committerbptato <nincsnevem662@gmail.com>2023-06-07 13:19:02 +0200
commitd78298ae3369374bf7bf31592513d112c75a9601 (patch)
treee8daf184adb0b09d48d53bf123f23a5d2a7b8d86 /src/buffer
parentc15d04041b1b8660000a1517b9d4bfc06f2cb490 (diff)
downloadchawan-d78298ae3369374bf7bf31592513d112c75a9601.tar.gz
Clean up stream error handling
* sread now raises EOFError if readData returns too few bytes
* buffer handleError ignores unregistered fds like client
* client handleError ignores unregistered fds like buffer
Diffstat (limited to 'src/buffer')
-rw-r--r--src/buffer/buffer.nim12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/buffer/buffer.nim b/src/buffer/buffer.nim
index dc41ba6c..77772532 100644
--- a/src/buffer/buffer.nim
+++ b/src/buffer/buffer.nim
@@ -75,7 +75,6 @@ type
   Buffer* = ref object
     rfd: int # file descriptor of command pipe
     fd: int # file descriptor of buffer source
-    oldfd: int # fd after being unregistered
     alive: bool
     readbufsize: int
     contenttype: string
@@ -663,7 +662,7 @@ proc finishLoad(buffer: Buffer): EmptyPromise =
     p = EmptyPromise()
     p.resolve()
   buffer.selector.unregister(buffer.fd)
-  buffer.oldfd = buffer.fd
+  buffer.loader.unregistered.add(buffer.fd)
   buffer.fd = -1
   buffer.istream.close()
   return p
@@ -1133,8 +1132,8 @@ proc handleRead(buffer: Buffer, fd: int) =
   elif fd in buffer.loader.ongoing:
     #TODO something with readablestream?
     discard
-  elif buffer.fd == -1 and buffer.oldfd == fd:
-    discard #TODO hack
+  elif fd in buffer.loader.unregistered:
+    discard # ignore
   else: assert false
 
 proc handleError(buffer: Buffer, fd: int, err: OSErrorCode) =
@@ -1149,8 +1148,8 @@ proc handleError(buffer: Buffer, fd: int, err: OSErrorCode) =
   elif fd in buffer.loader.ongoing:
     #TODO something with readablestream?
     discard
-  elif buffer.fd == -1 and fd == buffer.oldfd:
-    discard #TODO hack
+  elif fd in buffer.loader.unregistered:
+    discard # ignore
   else:
     assert false, $fd & ": " & $err
 
@@ -1169,6 +1168,7 @@ proc runBuffer(buffer: Buffer, rfd: int) =
         assert buffer.window != nil
         assert buffer.window.timeouts.runTimeoutFd(event.fd)
         buffer.window.runJSJobs()
+    buffer.loader.unregistered.setLen(0)
   buffer.pstream.close()
   buffer.loader.quit()
   quit(0)
s revision' href='/danisanti/cl-math/blame/cl-math.lisp?id=fc441a4bb98add59d111aae4de21f508d8fe38ee'>^
97fb7e9 ^
91fcf47 ^
ae07b3c ^






beef556 ^
a0025c8 ^
ac19e22

a0025c8 ^

ac19e22

9cf72e3 ^
a0025c8 ^

ac19e22




a0025c8 ^
ac19e22


a0025c8 ^
9cf72e3 ^

ac19e22



9cf72e3 ^
a0025c8 ^


ac19e22
a0025c8 ^

ac19e22

a0025c8 ^
9cf72e3 ^
ac19e22

a0025c8 ^

ac19e22

a0025c8 ^
74b1bb3 ^
ac19e22
beef556 ^



a0025c8 ^

81b97b0 ^
ac19e22
8be733f ^
04eb4cd ^
74b1bb3 ^
ac19e22
8be733f ^

74b1bb3 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94