* [PATCH BlueZ 1/1] isotest: Add check after accepting connection
2023-06-23 7:44 [PATCH BlueZ 0/1] isotest: Add check after accepting connection Iulia Tanasescu
@ 2023-06-23 7:44 ` Iulia Tanasescu
2023-06-23 9:19 ` bluez.test.bot
2023-06-26 20:50 ` [PATCH BlueZ 0/1] " patchwork-bot+bluetooth
1 sibling, 1 reply; 4+ messages in thread
From: Iulia Tanasescu @ 2023-06-23 7:44 UTC (permalink / raw)
To: linux-bluetooth
Cc: claudia.rosu, mihai-octavian.urzica, silviu.barbulescu,
vlad.pruteanu, andrei.istodorescu, Iulia Tanasescu
This checks for the POLLERR event on a newly accepted connection,
to determine if the connection was successful or not.
---
tools/isotest.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/tools/isotest.c b/tools/isotest.c
index 0eae3cdc1..c71bc6fa0 100644
--- a/tools/isotest.c
+++ b/tools/isotest.c
@@ -33,6 +33,7 @@
#include <time.h>
#include <inttypes.h>
#include <sys/wait.h>
+#include <poll.h>
#include "lib/bluetooth.h"
#include "lib/hci.h"
@@ -440,6 +441,9 @@ static void do_listen(char *filename, void (*handler)(int fd, int sk),
socklen_t optlen;
int sk, nsk, fd = -1;
char ba[18];
+ struct pollfd fds;
+ int err, sk_err;
+ socklen_t len;
if (filename) {
fd = open(filename, O_WRONLY | O_CREAT | O_APPEND, 0644);
@@ -529,6 +533,28 @@ static void do_listen(char *filename, void (*handler)(int fd, int sk),
goto error;
}
+ /* Check if connection was successful */
+ memset(&fds, 0, sizeof(fds));
+ fds.fd = nsk;
+ fds.events = POLLERR;
+
+ if (poll(&fds, 1, 0) > 0 && (fds.revents & POLLERR)) {
+ len = sizeof(sk_err);
+
+ if (getsockopt(nsk, SOL_SOCKET, SO_ERROR,
+ &sk_err, &len) < 0)
+ err = -errno;
+ else
+ err = -sk_err;
+
+ if (err < 0)
+ syslog(LOG_ERR, "Connection failed: %s (%d)",
+ strerror(-err), -err);
+
+ close(nsk);
+ continue;
+ }
+
if (fork()) {
/* Parent */
close(nsk);
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH BlueZ 0/1] isotest: Add check after accepting connection
2023-06-23 7:44 [PATCH BlueZ 0/1] isotest: Add check after accepting connection Iulia Tanasescu
2023-06-23 7:44 ` [PATCH BlueZ 1/1] " Iulia Tanasescu
@ 2023-06-26 20:50 ` patchwork-bot+bluetooth
1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+bluetooth @ 2023-06-26 20:50 UTC (permalink / raw)
To: Iulia Tanasescu
Cc: linux-bluetooth, claudia.rosu, mihai-octavian.urzica,
silviu.barbulescu, vlad.pruteanu, andrei.istodorescu
Hello:
This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Fri, 23 Jun 2023 10:44:05 +0300 you wrote:
> This checks for the POLLERR event on a newly accepted connection,
> to determine if the connection was successful or not.
>
> This check is related to the kernel update introduced by,
> https://patchwork.kernel.org/project/bluetooth/cover/20230623073842.16466-1-iulia.tanasescu@nxp.com/
> where unsuccessful bis connections are also added to the accept queue
> of a listening socket, to indicate the fact that BIG sync failed.
>
> [...]
Here is the summary with links:
- [BlueZ,1/1] isotest: Add check after accepting connection
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=b00bc612fab8
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread