OSDN Git Service

core: Set low priority for SDP data
authorJohan Hedberg <johan.hedberg@intel.com>
Thu, 11 Jul 2013 08:26:23 +0000 (11:26 +0300)
committerJohan Hedberg <johan.hedberg@intel.com>
Thu, 11 Jul 2013 08:26:23 +0000 (11:26 +0300)
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

index fdf2b01..2789db6 100644 (file)
@@ -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);