summaryrefslogtreecommitdiff
path: root/src/profile.c
diff options
context:
space:
mode:
authorPali Rohár <pali@kernel.org>2020-04-22 19:01:05 +0200
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2020-04-22 11:20:23 -0700
commitb0ebdd778b06a71c1cbc2fcf30d7fe5842e749fb (patch)
tree5fa842d0c8bf1434a5aeb8a7ca1e58803d729a5f /src/profile.c
parentd20ee8273e61e16c78582344f274254973cdf00f (diff)
downloadbluez-b0ebdd778b06a71c1cbc2fcf30d7fe5842e749fb.tar.gz
profile: Fix reporting error message when connection failed
Some bluetooth headsets do not support connecting more then one bluetooth profile (e.g. in parallel A2DP and HSP, or HSP and HFP) and issuing connect() syscall for second profile returns just ECONNREFUSED. Prior this patch bluetooth daemon for such situation reported following message to log: Unable to get connect data for Headset Voice gateway: getpeername: Transport endpoint is not connected (107) Message is incorrect as connect() syscall failed, not getpeername(). This patch fixes this problem and logs correct error message: Headset Voice gateway failed connect to XX:XX:XX:XX:XX:XX: Connection refused (111) Main problem was in ext_connect() function which called bt_io_get() for retrieving remote address (BT_IO_OPT_DEST) and if it failed then original error from connect() syscall was masked. Because it is not possible to retrieve BT_IO_OPT_DEST for unconnected socket, original destination address for error message is propagated via connect_add() function in btio.
Diffstat (limited to 'src/profile.c')
-rw-r--r--src/profile.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/profile.c b/src/profile.c
index c2992e795..6961a107b 100644
--- a/src/profile.c
+++ b/src/profile.c
@@ -1085,12 +1085,13 @@ static void ext_connect(GIOChannel *io, GError *err, gpointer user_data)
if (!bt_io_get(io, &io_err,
BT_IO_OPT_DEST, addr,
BT_IO_OPT_INVALID)) {
- error("Unable to get connect data for %s: %s", ext->name,
- io_err->message);
if (err) {
+ error("%s failed %s", ext->name, err->message);
g_error_free(io_err);
io_err = NULL;
} else {
+ error("Unable to get connect data for %s: %s",
+ ext->name, io_err->message);
err = io_err;
}
goto drop;