Commit ce1c43e
committed
Fix echo server to use advance-then-check pattern
The session loop checked ec before using the read bytes, silently
dropping partial data delivered alongside an error (e.g. EOF).
Apply the canonical advance-then-check pattern from the ReadStream
contract: always write back the received bytes before inspecting ec.1 parent d58f3e6 commit ce1c43e
3 files changed
Lines changed: 15 additions & 34 deletions
File tree
- doc/modules/ROOT/pages/3.tutorials
- example/echo-server
- test/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
| 63 | + | |
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
71 | 70 | | |
72 | 71 | | |
73 | 72 | | |
| |||
101 | 100 | | |
102 | 101 | | |
103 | 102 | | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | 103 | | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
| 104 | + | |
114 | 105 | | |
115 | | - | |
116 | 106 | | |
117 | | - | |
| 107 | + | |
118 | 108 | | |
119 | | - | |
| 109 | + | |
120 | 110 | | |
121 | 111 | | |
122 | 112 | | |
| |||
127 | 117 | | |
128 | 118 | | |
129 | 119 | | |
130 | | - | |
| 120 | + | |
| 121 | + | |
131 | 122 | | |
132 | 123 | | |
133 | 124 | | |
| |||
218 | 209 | | |
219 | 210 | | |
220 | 211 | | |
221 | | - | |
| 212 | + | |
| 213 | + | |
222 | 214 | | |
223 | 215 | | |
224 | 216 | | |
225 | 217 | | |
226 | | - | |
| 218 | + | |
| 219 | + | |
227 | 220 | | |
228 | 221 | | |
229 | 222 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
| |||
23 | 22 | | |
24 | 23 | | |
25 | 24 | | |
26 | | - | |
| 25 | + | |
27 | 26 | | |
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
33 | | - | |
34 | 32 | | |
35 | 33 | | |
36 | 34 | | |
| |||
47 | 45 | | |
48 | 46 | | |
49 | 47 | | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | 48 | | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
| 49 | + | |
60 | 50 | | |
61 | | - | |
62 | 51 | | |
63 | | - | |
| 52 | + | |
64 | 53 | | |
65 | | - | |
| 54 | + | |
66 | 55 | | |
67 | 56 | | |
68 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | | - | |
| 48 | + | |
50 | 49 | | |
51 | 50 | | |
52 | 51 | | |
| |||
0 commit comments