From f72e4a40a202ca9326282fc7f9e1401e95bfb22e Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 11 Jul 2013 11:26:23 +0300 Subject: [PATCH] core: Set low priority for SDP data In the case that there are other channels over the same ACL we want SDP transactions to interfere as little as possible. --- src/sdp-client.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/sdp-client.c b/src/sdp-client.c index fdf2b015f..2789db685 100644 --- a/src/sdp-client.c +++ b/src/sdp-client.c @@ -34,6 +34,7 @@ #include #include +#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); -- 2.11.0