Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp910894ybz; Wed, 22 Apr 2020 10:05:27 -0700 (PDT) X-Google-Smtp-Source: APiQypIIEPviLqDavtwPqy2psSh9mCDebtLqazwPMeTkB9QG+7PXjnm9CwTTb9NxlAQ0dmhGGPvs X-Received: by 2002:aa7:d0c2:: with SMTP id u2mr9780664edo.78.1587575127681; Wed, 22 Apr 2020 10:05:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587575127; cv=none; d=google.com; s=arc-20160816; b=Prj3VrXoqpET11ilFB2z1LIhPp0ezzGhW+YTryqp+MoD3re1PPXpf2zyggEi3OvFXA l0a3hzssIs8Y7JZzvc7Humc3T5PupnVUelOd0wB9/dwlbDvSjhOoglEqguDxgmQhzGbh dedrNES8ZMzY8mq+AdNezubWfaYYJPitsPyes/LQAei6nlOnzpOhYNt26ZWsUmc9itJu fuOE5/q/oUYWQzAqRGvhjhQcfwTKS3YYDs9pq8eG0HhCLMp6G8urzlzWyQkY6HnnVBVW wWzyh/5GhIjQ2Osgip0QDHoY09TDAj3Z3v5AJLGDhonKyn+KGF23f0n3ObWhuCeTS4wQ f6bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=7IupAs3myU1ddWlWoJ90mAAFmMpH6eZUs04mrqDz77Y=; b=bpIeYdJp3XXxAF86shvhkP6NAcRSfB0yb7XTKCzqFYxHMnXz34hIe0C92m83pGZLpl JpVC4j03zQl34APcJsk+IMSkfoEbLiKpdOKcYjBQhZ1UVMqMmqQe0eqmQ3m8A5vf2uGJ fPCD5wgr7wY+h6BJVdSDOG+0uc4SM4sjoJF32KvyuJaK3V8sY4JP2+69bJq0q2RiYAKT CBtlK5rrVYxQxfZHgOdplKLgAAY77uLfJCgBKA4KQm1G5ClkHtgdsKLdwvcVCd+EPXCb VT6G2AK1vAQPvspRp90pZtDPy7v5kRH5K8AzElJJxfTNlLq9n6WjuncE+6NrzcxmuHzN JKQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RQd2uCJ1; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k26si3558315ejs.504.2020.04.22.10.05.02; Wed, 22 Apr 2020 10:05:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RQd2uCJ1; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726830AbgDVRBW (ORCPT + 99 others); Wed, 22 Apr 2020 13:01:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:57648 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726303AbgDVRBW (ORCPT ); Wed, 22 Apr 2020 13:01:22 -0400 Received: from pali.im (pali.im [31.31.79.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8C57A20776 for ; Wed, 22 Apr 2020 17:01:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587574881; bh=3+N2kLgOyTEEtxz+4c1rz6ODvL1KPynT5IZuQ37AJ6o=; h=From:To:Subject:Date:In-Reply-To:References:From; b=RQd2uCJ1JYA2WC8mlybio3MG22wLChs7J4EEGjeLNzT7yWL/sdlKScmnWOA1oYpD2 pvr6LGzNbkSV92XXs1fABV3Ua3+jWd3nXvkmz3P307/MC1KIqPuf575zaZ2n61lTPT mpTNdfjb52WyhCayyMkU4Jwzv3aSXF0C9mWhxBMM= Received: by pali.im (Postfix) id E76CA7E6; Wed, 22 Apr 2020 19:01:19 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: linux-bluetooth@vger.kernel.org Subject: [PATCH v2 2/2] profile: Fix reporting error message when connection failed Date: Wed, 22 Apr 2020 19:01:05 +0200 Message-Id: <20200422170105.29685-2-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200422170105.29685-1-pali@kernel.org> References: <20200422170105.29685-1-pali@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 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. --- Having correct error message in logs is important. Due to this mangled error message I was not able to easily debug why particular bluetooth headset sometimes connection with nonsense error that Transport endpoint was not connected. --- src/profile.c | 5 +++-- 1 file 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; -- 2.20.1