linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/2] l2test: fix not setting priority of accepted socket
@ 2011-11-15 11:06 Luiz Augusto von Dentz
  2011-11-15 11:06 ` [PATCH BlueZ 2/2] rctest: " Luiz Augusto von Dentz
  2011-11-16 13:30 ` [PATCH BlueZ 1/2] l2test: " Johan Hedberg
  0 siblings, 2 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2011-11-15 11:06 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

SO_PRIORITY is not inherited upon accept so it has to be set manually in
the new socket.
---
 test/l2test.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/test/l2test.c b/test/l2test.c
index 438d21c..5034775 100644
--- a/test/l2test.c
+++ b/test/l2test.c
@@ -469,13 +469,6 @@ static void do_listen(void (*handler)(int sk))
 	}
 
 
-	if (priority > 0 && setsockopt(sk, SOL_SOCKET, SO_PRIORITY, &priority,
-						sizeof(priority)) < 0) {
-		syslog(LOG_ERR, "Can't set socket priority: %s (%d)",
-							strerror(errno), errno);
-		goto error;
-	}
-
 	/* Listen for connections */
 	if (listen(sk, 10)) {
 		syslog(LOG_ERR, "Can not listen on the socket: %s (%d)",
@@ -542,6 +535,14 @@ static void do_listen(void (*handler)(int sk))
 			}
 		}
 
+		if (priority > 0 && setsockopt(sk, SOL_SOCKET, SO_PRIORITY,
+					&priority, sizeof(priority)) < 0) {
+			syslog(LOG_ERR, "Can't set socket priority: %s (%d)",
+						strerror(errno), errno);
+			close(nsk);
+			goto error;
+		}
+
 		optlen = sizeof(priority);
 		if (getsockopt(nsk, SOL_SOCKET, SO_PRIORITY, &opt, &optlen) < 0) {
 			syslog(LOG_ERR, "Can't get socket priority: %s (%d)",
-- 
1.7.7.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH BlueZ 2/2] rctest: fix not setting priority of accepted socket
  2011-11-15 11:06 [PATCH BlueZ 1/2] l2test: fix not setting priority of accepted socket Luiz Augusto von Dentz
@ 2011-11-15 11:06 ` Luiz Augusto von Dentz
  2011-11-16 13:30 ` [PATCH BlueZ 1/2] l2test: " Johan Hedberg
  1 sibling, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2011-11-15 11:06 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

SO_PRIORITY is not inherited upon accept so it has to be set manually in
the new socket.
---
 test/rctest.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/test/rctest.c b/test/rctest.c
index b8acfb7..4d7c90a 100644
--- a/test/rctest.c
+++ b/test/rctest.c
@@ -312,13 +312,6 @@ static void do_listen(void (*handler)(int sk))
 		goto error;
 	}
 
-	if (priority > 0 && setsockopt(sk, SOL_SOCKET, SO_PRIORITY, &priority,
-						sizeof(priority)) < 0) {
-		syslog(LOG_ERR, "Can't set socket priority: %s (%d)",
-						strerror(errno), errno);
-		goto error;
-	}
-
 	/* Listen for connections */
 	if (listen(sk, 10)) {
 		syslog(LOG_ERR,"Can not listen on the socket: %s (%d)",
@@ -369,6 +362,14 @@ static void do_listen(void (*handler)(int sk))
 			//goto error;
 		}
 
+		if (priority > 0 && setsockopt(sk, SOL_SOCKET, SO_PRIORITY,
+					&priority, sizeof(priority)) < 0) {
+			syslog(LOG_ERR, "Can't set socket priority: %s (%d)",
+						strerror(errno), errno);
+			close(nsk);
+			goto error;
+		}
+
 		optlen = sizeof(priority);
 		if (getsockopt(nsk, SOL_SOCKET, SO_PRIORITY, &opt, &optlen) < 0) {
 			syslog(LOG_ERR, "Can't get socket priority: %s (%d)",
-- 
1.7.7.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH BlueZ 1/2] l2test: fix not setting priority of accepted socket
  2011-11-15 11:06 [PATCH BlueZ 1/2] l2test: fix not setting priority of accepted socket Luiz Augusto von Dentz
  2011-11-15 11:06 ` [PATCH BlueZ 2/2] rctest: " Luiz Augusto von Dentz
@ 2011-11-16 13:30 ` Johan Hedberg
  1 sibling, 0 replies; 3+ messages in thread
From: Johan Hedberg @ 2011-11-16 13:30 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hi Luiz,

On Tue, Nov 15, 2011, Luiz Augusto von Dentz wrote:
> SO_PRIORITY is not inherited upon accept so it has to be set manually in
> the new socket.
> ---
>  test/l2test.c |   15 ++++++++-------
>  1 files changed, 8 insertions(+), 7 deletions(-)

Both patches have been applied. Thanks.

Johan

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-11-16 13:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-15 11:06 [PATCH BlueZ 1/2] l2test: fix not setting priority of accepted socket Luiz Augusto von Dentz
2011-11-15 11:06 ` [PATCH BlueZ 2/2] rctest: " Luiz Augusto von Dentz
2011-11-16 13:30 ` [PATCH BlueZ 1/2] l2test: " Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).