From 4047ca606f1aa786e223e46bfcdf8511e035ae2b Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Fri, 28 Jan 2022 01:42:56 +0300 Subject: [PATCH] Add missing cancel_op(currently being read op) when stopping a client Fixes client hangs possible after stopping & restarting an osd. Hangs happened when a connection was closed in the middle of reading a READ operation reply from the network. In this case the operation being read was in read_op and the client didn't free it when closing the connection. Test case for msgr_read.cpp: - Partially read reply for a READ operation - stop_client() - Check that the READ operation returns EPIPE The bug was actually introduced in 0.5.11. --- src/msgr_stop.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/msgr_stop.cpp b/src/msgr_stop.cpp index 297766664..4e952a0e4 100644 --- a/src/msgr_stop.cpp +++ b/src/msgr_stop.cpp @@ -111,6 +111,10 @@ void osd_messenger_t::stop_client(int peer_fd, bool force, bool force_delete) { delete cl->read_op; } + else + { + cancel_op(cl->read_op); + } cl->read_op = NULL; } if (cl->osd_num)