Commit 2e2f90b
authored
Avoid double attempt at reconnecting (apache#310)
### Motivation
There is a sequence of conditions that can trigger a client to schedule multiple reconnections to the broker. This is due to fact that we're not checking whether such an attempt is already in progress.
example:
1. Receive `CloseConsumer` command from broker
1a. Schedule for reconnection in 100ms
2. Connection is closed (eg: broker shutdown has initiated)
2a. Schedule for reconnection in 200ms (since the backoff was already incremented)
Result is that we're going to call `grabCnx()` twice
### Modifications
Use atomic flag to ignore the 2nd attempt, just waiting for the 1st attempt to finish.1 parent 6ebea5c commit 2e2f90b
2 files changed
+14
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| |||
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
72 | 80 | | |
73 | 81 | | |
74 | 82 | | |
| |||
83 | 91 | | |
84 | 92 | | |
85 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
86 | 97 | | |
87 | 98 | | |
88 | 99 | | |
| |||
140 | 151 | | |
141 | 152 | | |
142 | 153 | | |
| 154 | + | |
143 | 155 | | |
144 | 156 | | |
145 | 157 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| 131 | + | |
131 | 132 | | |
132 | 133 | | |
133 | 134 | | |
| |||
0 commit comments