[gupnp/gupnp-1.0] linux-cm: Avoid static receive buffer
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gupnp/gupnp-1.0] linux-cm: Avoid static receive buffer
- Date: Fri, 11 Jan 2019 09:34:10 +0000 (UTC)
commit f4414726a8b0f0c251b3d5cd578090b58a1c84d0
Author: Jakub Adam <jakub adam collabora com>
Date: Tue Jan 8 13:04:20 2019 +0100
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.
libgupnp/gupnp-linux-context-manager.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/libgupnp/gupnp-linux-context-manager.c b/libgupnp/gupnp-linux-context-manager.c
index 90fb56d..2bd53e2 100644
--- a/libgupnp/gupnp-linux-context-manager.c
+++ b/libgupnp/gupnp-linux-context-manager.c
@@ -84,6 +84,9 @@ struct _GUPnPLinuxContextManagerPrivate {
* structure */
GHashTable *interfaces;
+ /* Receive buffer for netlink messages. */
+ char recvbuf[8196];
+
gboolean dump_netlink_packets;
};
@@ -708,17 +711,17 @@ 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;
+ header = (struct nlmsghdr *) self->priv->recvbuf;
len = g_socket_receive (self->priv->netlink_socket,
- buf,
- sizeof (buf),
+
+ self->priv->recvbuf,
+ sizeof (self->priv->recvbuf),
NULL,
&inner_error);
if (len == -1) {
@@ -735,7 +738,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 *) self->priv->recvbuf,
+ len, hexdump);
g_debug ("Netlink packet dump:\n%s", hexdump->str);
g_string_free (hexdump, TRUE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]