File tree 1 file changed +8
-5
lines changed
1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -166,21 +166,23 @@ type handler struct {
166
166
closed bool
167
167
}
168
168
169
- func (h * handler ) close () {
169
+ func (h * handler ) close (err error ) {
170
170
if ! h .closed {
171
171
h .conn .Close () // ignoring error: what can we do?
172
172
h .s .mtx .Lock ()
173
173
delete (h .s .listeners [h .listener ], h .conn )
174
174
h .s .mtx .Unlock ()
175
- logConnFailure ()
176
175
h .closed = true
176
+ if err != nil {
177
+ logConnFailure ()
178
+ }
177
179
}
178
180
}
179
181
180
182
func (h * handler ) closeWithWritingErr (err error ) {
181
183
if ! h .closed {
182
184
log .Errorf ("connection %v: error in writing response %v" , h .name , err )
183
- h .close ()
185
+ h .close (err )
184
186
}
185
187
}
186
188
@@ -251,7 +253,7 @@ func (h *handler) loop() error {
251
253
}
252
254
h .mtx .Lock ()
253
255
defer h .mtx .Unlock ()
254
- h .close ()
256
+ h .close (err )
255
257
return err
256
258
}
257
259
// In the event of a read timeout, gracefully close
@@ -260,7 +262,8 @@ func (h *handler) loop() error {
260
262
h .tokens .Acquire (ctx , int64 (h .s .config .maxConnPendingRequests ))
261
263
h .mtx .Lock ()
262
264
defer h .mtx .Unlock ()
263
- h .close ()
265
+ // Don't pass err here since this was a graceful close
266
+ h .close (nil )
264
267
return err
265
268
}
266
269
You can’t perform that action at this time.
0 commit comments