Diff between e339d0b6e55b529fa2584cb217088b61c890e1ad and f72e4a40a202ca9326282fc7f9e1401e95bfb22e

Changed Files

File Additions Deletions Status
src/sdp-client.c +12 -1 modified

Full Patch

diff --git a/src/sdp-client.c b/src/sdp-client.c
index fdf2b01..2789db6 100644
--- a/src/sdp-client.c
+++ b/src/sdp-client.c
@@ -34,6 +34,7 @@
 #include <glib.h>
 
 #include <btio/btio.h>
+#include "log.h"
 #include "sdp-client.h"
 
 /* Number of seconds to keep a sdp_session_t in the cache */
@@ -285,6 +286,8 @@ static int create_search_context(struct search_context **ctxt,
 {
 	sdp_session_t *s;
 	GIOChannel *chan;
+	uint32_t prio = 1;
+	int sk;
 
 	if (!ctxt)
 		return -EINVAL;
@@ -304,7 +307,15 @@ static int create_search_context(struct search_context **ctxt,
 	(*ctxt)->session = s;
 	(*ctxt)->uuid = *uuid;
 
-	chan = g_io_channel_unix_new(sdp_get_socket(s));
+	sk = sdp_get_socket(s);
+	/* Set low priority for the SDP connection not to interfere with
+	 * other potential traffic.
+	 */
+	if (setsockopt(sk, SOL_SOCKET, SO_PRIORITY, &prio, sizeof(prio)) < 0)
+		warn("Setting SDP priority failed: %s (%d)",
+						strerror(errno), errno);
+
+	chan = g_io_channel_unix_new(sk);
 	(*ctxt)->io_id = g_io_add_watch(chan,
 				G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
 				connect_watch, *ctxt);