Quit from splice(read) for avoiding to do splice(write) if there are no data.
When splice(read) returns negative or 0, that means no data. So, the recorder
does not need to do splice(write).

Note:
This patch is related to https://lkml.org/lkml/2013/7/21/200. If the patch of
the link is not applied, splice(write) for virtio-serial induces kernel oops
when there are no data. This patch always avoids to do splice(write) in the
case, so this patch is needed.

Signed-off-by: Yoshihiro YUNOMAE <[email protected]>
---
 trace-recorder.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/trace-recorder.c b/trace-recorder.c
index 7db5f3e..520d486 100644
--- a/trace-recorder.c
+++ b/trace-recorder.c
@@ -337,7 +337,10 @@ static long splice_data(struct tracecmd_recorder *recorder)
                        warning("recorder error in splice input");
                        return -1;
                }
-       }
+               if (errno == EINTR)
+                       return 0;
+       } else if (ret == 0)
+               return 0;
 
        ret = splice(recorder->brass[0], NULL, recorder->fd, NULL,
                     recorder->page_size, 3 /* and NON_BLOCK */);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to