pipewire: add patch to fix random sendmsg errors
[AGL/meta-agl-devel.git] / meta-pipewire / recipes-multimedia / pipewire / pipewire / 0015-connection-move-remaining-data-and-fds.patch
diff --git a/meta-pipewire/recipes-multimedia/pipewire/pipewire/0015-connection-move-remaining-data-and-fds.patch b/meta-pipewire/recipes-multimedia/pipewire/pipewire/0015-connection-move-remaining-data-and-fds.patch
new file mode 100644 (file)
index 0000000..925dff7
--- /dev/null
@@ -0,0 +1,61 @@
+From 1b739247dcab62d1da45109cf805b8a840307ccc Mon Sep 17 00:00:00 2001
+From: Wim Taymans <wtaymans@redhat.com>
+Date: Tue, 1 Oct 2019 10:43:48 +0200
+Subject: [PATCH] connection: move remaining data and fds
+
+If we can't send all of the data, move the remaining data to the
+start of the buffer so that we can send it again later.
+
+See #111
+
+Upstream-Status: Backport [3d48ba8394396fc8d8cadb1bff3514217ddd70e6]
+---
+ .../module-protocol-native/connection.c       | 23 +++++++++++--------
+ 1 file changed, 14 insertions(+), 9 deletions(-)
+
+diff --git a/src/modules/module-protocol-native/connection.c b/src/modules/module-protocol-native/connection.c
+index f51129df..7b6cf112 100644
+--- a/src/modules/module-protocol-native/connection.c
++++ b/src/modules/module-protocol-native/connection.c
+@@ -500,8 +500,12 @@ int pw_protocol_native_connection_flush(struct pw_protocol_native_connection *co
+                       if (sent < 0) {
+                               if (errno == EINTR)
+                                       continue;
+-                              else
+-                                      goto send_error;
++                              else {
++                                      res = -errno;
++                                      pw_log_error("could not sendmsg on fd:%d n_fds:%d: %s",
++                                                      conn->fd, n_fds, spa_strerror(res));
++                                      goto exit;
++                              }
+                       }
+                       break;
+               }
+@@ -513,15 +517,16 @@ int pw_protocol_native_connection_flush(struct pw_protocol_native_connection *co
+               n_fds -= outfds;
+               fds += outfds;
+       }
+-      buf->buffer_size = size;
+-      buf->n_fds = n_fds;
+-      return 0;
++      res = 0;
+-      /* ERRORS */
+-send_error:
+-      res = -errno;
+-      pw_log_error("could not sendmsg on fd:%d n_fds:%d: %s", conn->fd, n_fds, strerror(errno));
++exit:
++      if (size > 0)
++              memmove(buf->buffer_data, data, size);
++      buf->buffer_size = size;
++      if (n_fds > 0)
++              memmove(buf->fds, fds, n_fds * sizeof(int));
++      buf->n_fds = n_fds;
+       return res;
+ }
+-- 
+2.23.0
+