Commit 0123e574 authored by Jakub Adam's avatar Jakub Adam
Browse files

linux-cm: Avoid static receive buffer

The buffer in receive_netlink_message() is shared between all threads,
which poses a problem when several CM instances start accessing it at
the same time.

That can create issues e.g. with libnice where each NiceAgent instance
runs its own GUPnPContextManager in a separate thread.

Let each GUPnPLinuxContextManager have its own recvbuf.
parent 74748ffb
......@@ -81,6 +81,9 @@ struct _GUPnPLinuxContextManagerPrivate {
* structure */
GHashTable *interfaces;
/* Receive buffer for netlink messages. */
char recvbuf[8196];
gboolean dump_netlink_packets;
typedef struct _GUPnPLinuxContextManagerPrivate GUPnPLinuxContextManagerPrivate;
......@@ -777,20 +780,20 @@ remove_device (GUPnPLinuxContextManager *self,
static void
receive_netlink_message (GUPnPLinuxContextManager *self, GError **error)
static char buf[8196];
gssize len;
GError *inner_error = NULL;
struct nlmsghdr *header = (struct nlmsghdr *) buf;
struct nlmsghdr *header;
struct ifinfomsg *ifi;
struct ifaddrmsg *ifa;
GUPnPLinuxContextManagerPrivate *priv;
priv = gupnp_linux_context_manager_get_instance_private (self);
header = (struct nlmsghdr *) priv->recvbuf;
len = g_socket_receive (priv->netlink_socket,
sizeof (buf),
sizeof (priv->recvbuf),
if (len == -1) {
......@@ -807,7 +810,8 @@ receive_netlink_message (GUPnPLinuxContextManager *self, GError **error)
/* We should have at most len / 16 + 1 lines with 74 characters each */
hexdump = g_string_new_len (NULL, ((len / 16) + 1) * 73);
gupnp_linux_context_manager_hexdump ((guint8 *) buf, len, hexdump);
gupnp_linux_context_manager_hexdump ((guint8 *) priv->recvbuf,
len, hexdump);
g_debug ("Netlink packet dump:\n%s", hexdump->str);
g_string_free (hexdump, TRUE);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment