2015-07-14 07:39:17

by Dohyun Pyun

[permalink] [raw]
Subject: [PATCH Bluez] tools/l2test: Fix potention double close

From: DoHyun Pyun <[email protected]>

If the test gets an error after close the socket, the socket sk
will be closed again. This patch prevents the double close case.
---
tools/l2test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/l2test.c b/tools/l2test.c
index abe09c1..1d458c4 100644
--- a/tools/l2test.c
+++ b/tools/l2test.c
@@ -644,7 +644,6 @@ static void do_listen(void (*handler)(int sk))
continue;
}
/* Child */
- close(sk);

/* Set receive buffer size */
if (rcvbuf && setsockopt(nsk, SOL_SOCKET, SO_RCVBUF, &rcvbuf,
@@ -769,6 +768,7 @@ static void do_listen(void (*handler)(int sk))
}

handler(nsk);
+ close(sk);

syslog(LOG_INFO, "Disconnect: %m");
exit(0);
--
1.8.1.2



2015-07-23 21:23:32

by Vinicius Costa Gomes

[permalink] [raw]
Subject: Re: [PATCH Bluez] tools/l2test: Fix potention double close

Hi,

Dohyun Pyun <[email protected]> writes:

> From: DoHyun Pyun <[email protected]>
>
> If the test gets an error after close the socket, the socket sk
> will be closed again. This patch prevents the double close case.

minor: typo on the subject: s/potention/potencial/.

The code looks good.


Cheers,
--
Vinicius

2015-07-23 14:02:09

by Dohyun Pyun

[permalink] [raw]
Subject: Re: [PATCH Bluez] tools/l2test: Fix potention double close

Ping

2015-07-14 16:39 GMT+09:00, Dohyun Pyun <[email protected]>:
> From: DoHyun Pyun <[email protected]>
>
> If the test gets an error after close the socket, the socket sk
> will be closed again. This patch prevents the double close case.
> ---
> tools/l2test.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/l2test.c b/tools/l2test.c
> index abe09c1..1d458c4 100644
> --- a/tools/l2test.c
> +++ b/tools/l2test.c
> @@ -644,7 +644,6 @@ static void do_listen(void (*handler)(int sk))
> continue;
> }
> /* Child */
> - close(sk);
>
> /* Set receive buffer size */
> if (rcvbuf && setsockopt(nsk, SOL_SOCKET, SO_RCVBUF, &rcvbuf,
> @@ -769,6 +768,7 @@ static void do_listen(void (*handler)(int sk))
> }
>
> handler(nsk);
> + close(sk);
>
> syslog(LOG_INFO, "Disconnect: %m");
> exit(0);
> --
> 1.8.1.2
>
>