diff options
author | Justin Dickow <jjdickow@gmail.com> | 2016-07-27 14:00:34 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-27 14:00:34 -0400 |
commit | d187edb6977b59fd4a6f92c9583522a500700d5e (patch) | |
tree | 2768d3e943619ba04d98d3b59c3b6803edbaa711 /src/components/transport_manager/src | |
parent | f0328a9e332f4d24631fada437548603ffe800c1 (diff) | |
parent | b01f3bafe6a74a21109355573328b2dd8c35a5b9 (diff) | |
download | sdl_core-d187edb6977b59fd4a6f92c9583522a500700d5e.tar.gz |
Merge pull request #727 from BTPankow/hotfix/coverity_resource_leaks
Change socket close logic to prevent double close (CID 137866)
Diffstat (limited to 'src/components/transport_manager/src')
-rw-r--r-- | src/components/transport_manager/src/bluetooth/bluetooth_socket_connection.cc | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/components/transport_manager/src/bluetooth/bluetooth_socket_connection.cc b/src/components/transport_manager/src/bluetooth/bluetooth_socket_connection.cc index 4240c9a3a4..4b092bcf50 100644 --- a/src/components/transport_manager/src/bluetooth/bluetooth_socket_connection.cc +++ b/src/components/transport_manager/src/bluetooth/bluetooth_socket_connection.cc @@ -103,14 +103,12 @@ bool BluetoothSocketConnection::Establish(ConnectError** error) { if (0 == connect_status) { LOG4CXX_DEBUG(logger_, "rfcomm Connect ok"); break; - } - if (errno != 111 && errno != 104) { - LOG4CXX_DEBUG(logger_, "rfcomm Connect errno " << errno); - break; - } - if (errno) { - LOG4CXX_DEBUG(logger_, "rfcomm Connect errno " << errno); - close(rfcomm_socket); + } else { // If connect_status is not 0, an errno is returned + LOG4CXX_WARN_WITH_ERRNO(logger_, "rfcomm Connect failed"); + close(rfcomm_socket); // Always close the socket upon error + if (errno != ECONNREFUSED && errno != ECONNRESET) { + break; + } } sleep(2); } while (--attempts > 0); @@ -120,7 +118,6 @@ bool BluetoothSocketConnection::Establish(ConnectError** error) { "Failed to Connect to remote device " << BluetoothDevice::GetUniqueDeviceId( remoteSocketAddress.rc_bdaddr) << " for session " << this); *error = new ConnectError(); - close(rfcomm_socket); LOG4CXX_TRACE(logger_, "exit with FALSE"); return false; } |