summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/components/transport_manager/src/bluetooth/bluetooth_socket_connection.cc15
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;
}