Changeset 20086


Ignore:
Timestamp:
04/20/21 23:25:43 (2 months ago)
Author:
tbretz
Message:
Trying to improve exception safety of closing a connection. Calling shutdown is suggested in the close documentation and using the error code should prevent exceptions.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/Connection.cc

    r20018 r20086  
    100100
    101101    // Close possible open connections
    102     close();
     102    if (is_open())
     103    {
     104        bs::error_code err;
     105        shutdown(boost::asio::ip::tcp::socket::shutdown_both, err);
     106        if (err)
     107        {
     108            ostringstream str;
     109            str << "Shutting down " << URL() << ": " << err.message() << " (" << err << ")";// << endl;
     110            Error(str);
     111        }
     112        close(err);
     113        if (err)
     114        {
     115            ostringstream str;
     116            str << "Closing " << URL() << ": " << err.message() << " (" << err << ")";// << endl;
     117            Error(str);
     118        }
     119    }
    103120
    104121    // Reset the connection status
Note: See TracChangeset for help on using the changeset viewer.