Prechádzať zdrojové kódy

Fixed Exception: shutdown: Transport endpoint is not connected

When the server closes the connection, set connected=false.
That way, when the client closes, we don't try closing
the already closed server socket.
Steve Thielemann 3 rokov pred
rodič
commit
0be6e6bac2
1 zmenil súbory, kde vykonal 3 pridanie a 0 odobranie
  1. 3 0
      session.cpp

+ 3 - 0
session.cpp

@@ -430,6 +430,7 @@ void Session::server_read(void) {
           server_read();
           server_read();
         } else {
         } else {
           BUGZ_LOG(warning) << "S: read_failed: socket.shutdown()";
           BUGZ_LOG(warning) << "S: read_failed: socket.shutdown()";
+          connected = false;
           socket_.shutdown(boost::asio::ip::tcp::socket::shutdown_both);
           socket_.shutdown(boost::asio::ip::tcp::socket::shutdown_both);
         }
         }
       });
       });
@@ -652,6 +653,8 @@ void Session::to_server(const std::string &message) {
 
 
         } else {
         } else {
           BUGZ_LOG(warning) << "S: write failed? closed? socket.shutdown()";
           BUGZ_LOG(warning) << "S: write failed? closed? socket.shutdown()";
+          // we're no longer connected.
+          connected = false;
           socket_.shutdown(boost::asio::ip::tcp::socket::shutdown_both);
           socket_.shutdown(boost::asio::ip::tcp::socket::shutdown_both);
         }
         }
       });
       });