connIdleTimeout previously set per-direction deadlines independently. During media downloads the client→telegram direction can be idle at the application level while telegram→client is actively streaming data. After IdleTimeout (default 1 min) the idle direction's ReadDeadline fires, tearing down the entire relay and breaking media transfers. Replace the per-direction timeout with a shared atomic timestamp that both pump goroutines update on any successful Read or Write. When a ReadDeadline fires on the idle direction, we check the shared tracker: if the other direction was recently active, we retry instead of closing. The connection is only torn down when both directions are idle for the full timeout period. This matches the documented IdleTimeout contract: "if we have any message which will pass to either direction, a timer is reset." Overhead: one atomic.Int64 (8 bytes) per connection pair, one atomic.Store (~1 ns) per Read/Write with data, zero extra goroutines. Fixes #423tags/v2.2.6^2^2
|
|
||
| 6 |
|
6 |
|
| 7 |
|
7 |
|
| 8 |
|
8 |
|
|
9 |
|
|
| 9 |
|
10 |
|
| 10 |
|
11 |
|
| 11 |
|
12 |
|
|
|
||
| 97 |
|
98 |
|
| 98 |
|
99 |
|
| 99 |
|
100 |
|
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
|
105 |
|
|
|
106 |
|
|
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
|
114 |
|
|
|
115 |
|
|
|
116 |
|
|
|
117 |
|
|
|
118 |
|
|
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
|
122 |
|
|
|
123 |
|
|
|
124 |
|
|
|
125 |
|
|
| 100 |
|
126 |
|
| 101 |
|
127 |
|
| 102 |
|
128 |
|
| 103 |
|
|
|
|
129 |
|
|
| 104 |
|
130 |
|
| 105 |
|
131 |
|
| 106 |
|
132 |
|
| 107 |
|
|
|
|
133 |
|
|
|
134 |
|
|
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
|
138 |
|
|
| 108 |
|
139 |
|
| 109 |
|
|
|
|
140 |
|
|
|
141 |
|
|
|
142 |
|
|
|
143 |
|
|
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
|
147 |
|
|
|
148 |
|
|
|
149 |
|
|
|
150 |
|
|
|
151 |
|
|
|
152 |
|
|
| 110 |
|
153 |
|
| 111 |
|
154 |
|
| 112 |
|
155 |
|
| 113 |
|
|
|
|
156 |
|
|
| 114 |
|
157 |
|
| 115 |
|
|
|
|
158 |
|
|
|
159 |
|
|
|
160 |
|
|
|
161 |
|
|
|
162 |
|
|
|
163 |
|
|
| 116 |
|
164 |
|
|
|
||
| 102 |
|
102 |
|
| 103 |
|
103 |
|
| 104 |
|
104 |
|
|
105 |
|
|
|
106 |
|
|
| 105 |
|
107 |
|
| 106 |
|
108 |
|
| 107 |
|
109 |
|
| 108 |
|
|
|
| 109 |
|
|
|
|
110 |
|
|
|
111 |
|
|
| 110 |
|
112 |
|
| 111 |
|
113 |
|
| 112 |
|
114 |
|
|
|
||
| 305 |
|
307 |
|
| 306 |
|
308 |
|
| 307 |
|
309 |
|
|
310 |
|
|
|
311 |
|
|
| 308 |
|
312 |
|
| 309 |
|
313 |
|
| 310 |
|
314 |
|
| 311 |
|
|
|
| 312 |
|
|
|
|
315 |
|
|
|
316 |
|
|
| 313 |
|
317 |
|
| 314 |
|
318 |
|
| 315 |
|
319 |
|