Commit b108bf0
committed
Fix bad_weak_ptr when close a ClientConnection during construction
Fixes apache#348
Fixes apache#349
### Motivation
When `close` is called in `ClientConnection`'s constructor,
`shared_from_this()` will be called, which results in a
`std::bad_weak_ptr` error. This error does not happen before
apache#317 because
`shared_from_this()` could only be called when the `producers` or
`consumers` field is not empty.
### Modifications
Modify the 2nd parameter of `ClientConnection::close` to represent if
the construction completes. If not, just set the state to
`Disconnected` and complete the future to the result. Then
`ConnectionPool::getConnectionAsync` will return a future that completes
with the failed result.
In addition, check `authentication_` even for non-TLS URLs. Otherwise,
the null authentication will be used to construct `CommandConnect`.
Add `testInvalidPlugin` and `testTlsConfigError` to verify the changes.1 parent 8d32fd2 commit b108bf0
File tree
3 files changed
+31
-16
lines changed- lib
- tests
3 files changed
+31
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
189 | 194 | | |
190 | 195 | | |
191 | 196 | | |
| |||
214 | 219 | | |
215 | 220 | | |
216 | 221 | | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | 222 | | |
224 | 223 | | |
225 | 224 | | |
| |||
1259 | 1258 | | |
1260 | 1259 | | |
1261 | 1260 | | |
1262 | | - | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
1263 | 1268 | | |
1264 | 1269 | | |
1265 | 1270 | | |
| |||
1319 | 1324 | | |
1320 | 1325 | | |
1321 | 1326 | | |
1322 | | - | |
1323 | | - | |
1324 | | - | |
| 1327 | + | |
1325 | 1328 | | |
1326 | 1329 | | |
1327 | 1330 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
| 149 | + | |
154 | 150 | | |
155 | | - | |
| 151 | + | |
156 | 152 | | |
157 | 153 | | |
158 | 154 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
581 | 581 | | |
582 | 582 | | |
583 | 583 | | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
0 commit comments