]> git.alsa-project.org Git - alsa-lib.git/commitdiff
pcm: share plugin: handle -EINTR
authorJaroslav Kysela <perex@perex.cz>
Mon, 27 Jun 2022 11:36:12 +0000 (13:36 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 27 Jun 2022 11:36:36 +0000 (13:36 +0200)
Fixes: https://github.com/alsa-project/alsa-lib/pull/242
Fixes: b97047b4 ("pcm: share plugin: return error if socket read or write call fails")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/pcm/pcm_share.c

index dc972dd82813402f71cb7a43d9b8669a987b8e4c..ac088472e67f29e43fbb11a471aa80e170399d9a 100644 (file)
@@ -289,19 +289,25 @@ static snd_pcm_uframes_t _snd_pcm_share_missing(snd_pcm_t *pcm)
  update_poll:
        if (ready != share->ready) {
                char buf[1];
-               if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
-                       if (ready)
-                               s = read(share->slave_socket, buf, 1);
-                       else
-                               s = write(share->client_socket, buf, 1);
-               } else {
-                       if (ready)
-                               s = write(share->slave_socket, buf, 1);
-                       else
-                               s = read(share->client_socket, buf, 1);
+               while (1) {
+                       if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
+                               if (ready)
+                                       s = read(share->slave_socket, buf, 1);
+                               else
+                                       s = write(share->client_socket, buf, 1);
+                       } else {
+                               if (ready)
+                                       s = write(share->slave_socket, buf, 1);
+                               else
+                                       s = read(share->client_socket, buf, 1);
+                       }
+                       if (s < 0) {
+                               if (errno == EINTR)
+                                       continue;
+                               return INT_MAX;
+                       }
+                       break;
                }
-               if (s == -1)
-                       return INT_MAX;
                share->ready = ready;
        }
        if (!running)