Commit 40ea4ea
authored
manager: Fix connection limits tracking of rejected connections (#286)
This PR ensures that connection IDs are properly tracked to enforce
connection limits.
After ~1/2 days the substrate litep2p running node is starting to reject
multiple pending socket connections.
This is related to the fact that accepting of established connection is
a two-part process:
- step 1. Can we accept the connection based on number of connections?
- step 2. The transport manager transitions the peer state
- step 3. If the transition succeeds, the connection is tracked
(inserted in a hashmap).
If step 2 fails, we were previously leaking the connection ID. The
connection ID is also counting towards the maximum number of connections
the node can sustain.
This PR effectively modifies the connection limits API,
`on_connection_established` is split into two methods:
- `can_accept_connection()`
- `accept_established_connection()`
This fixes a subtle memory leak bounded at 10000 Connection IDs.
However, even more important, this fixes connection stability for
long-running nodes.
Discovered during the investigation of:
- #282
cc @paritytech/networking
---------
Signed-off-by: Alexandru Vasile <[email protected]>1 parent e7cb35e commit 40ea4ea
2 files changed
+33
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
117 | 119 | | |
118 | | - | |
119 | 120 | | |
120 | 121 | | |
121 | 122 | | |
| |||
131 | 132 | | |
132 | 133 | | |
133 | 134 | | |
134 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
135 | 149 | | |
136 | 150 | | |
137 | 151 | | |
138 | 152 | | |
139 | 153 | | |
140 | 154 | | |
141 | 155 | | |
142 | | - | |
143 | | - | |
144 | 156 | | |
145 | 157 | | |
146 | 158 | | |
| |||
167 | 179 | | |
168 | 180 | | |
169 | 181 | | |
170 | | - | |
171 | 182 | | |
172 | 183 | | |
173 | | - | |
| 184 | + | |
| 185 | + | |
174 | 186 | | |
175 | 187 | | |
176 | | - | |
| 188 | + | |
| 189 | + | |
177 | 190 | | |
178 | 191 | | |
179 | | - | |
| 192 | + | |
| 193 | + | |
180 | 194 | | |
181 | 195 | | |
182 | 196 | | |
183 | | - | |
| 197 | + | |
184 | 198 | | |
185 | 199 | | |
186 | 200 | | |
187 | 201 | | |
188 | 202 | | |
189 | | - | |
| 203 | + | |
| 204 | + | |
190 | 205 | | |
191 | 206 | | |
192 | 207 | | |
193 | | - | |
| 208 | + | |
| 209 | + | |
194 | 210 | | |
195 | 211 | | |
196 | 212 | | |
197 | 213 | | |
198 | | - | |
| 214 | + | |
199 | 215 | | |
200 | 216 | | |
201 | 217 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
774 | 774 | | |
775 | 775 | | |
776 | 776 | | |
777 | | - | |
778 | | - | |
779 | | - | |
780 | | - | |
| 777 | + | |
781 | 778 | | |
782 | 779 | | |
783 | 780 | | |
| |||
806 | 803 | | |
807 | 804 | | |
808 | 805 | | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
809 | 809 | | |
810 | 810 | | |
811 | 811 | | |
| |||
0 commit comments