This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:

Subject: v4l2-compliance: call select before dequeuing event
Author:  Deborah Brouwer <[email protected]>
Date:    Thu Jun 8 18:52:04 2023 -0700

When the streaming option is called with a stateful decoder,
testUserPtr() and testDmaBuf() will hang indefinitely when attempting to
dequeue a source change event. To prevent this call select() with a
timeout.

Signed-off-by: Deborah Brouwer <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>

 utils/v4l2-compliance/v4l2-test-buffers.cpp | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=29d0a2c7a42d5fbfdb3725fcd493aad21dd99cb6
diff --git a/utils/v4l2-compliance/v4l2-test-buffers.cpp 
b/utils/v4l2-compliance/v4l2-test-buffers.cpp
index a097a0ff555e..6d592c9b094b 100644
--- a/utils/v4l2-compliance/v4l2-test-buffers.cpp
+++ b/utils/v4l2-compliance/v4l2-test-buffers.cpp
@@ -1746,9 +1746,19 @@ int testUserPtr(struct node *node, struct node 
*node_m2m_cap, unsigned frame_cou
 
                if (node->is_m2m) {
                        if (node->codec_mask & STATEFUL_DECODER) {
+                               int fd_flags = fcntl(node->g_fd(), F_GETFL);
+                               struct timeval tv = { 1, 0 };
+                               fd_set efds;
                                v4l2_event ev;
 
+                               fcntl(node->g_fd(), F_SETFL, fd_flags | 
O_NONBLOCK);
+                               FD_ZERO(&efds);
+                               FD_SET(node->g_fd(), &efds);
+                               ret = select(node->g_fd() + 1, nullptr, 
nullptr, &efds, &tv);
+                               fail_on_test_val(ret < 0, ret);
+                               fail_on_test(ret == 0);
                                fail_on_test(node->dqevent(ev));
+                               fcntl(node->g_fd(), F_SETFL, fd_flags);
                                fail_on_test(ev.type != 
V4L2_EVENT_SOURCE_CHANGE);
                                fail_on_test(!(ev.u.src_change.changes & 
V4L2_EVENT_SRC_CH_RESOLUTION));
                        }
@@ -1949,9 +1959,19 @@ int testDmaBuf(struct node *expbuf_node, struct node 
*node, struct node *node_m2
 
                if (node->is_m2m) {
                        if (node->codec_mask & STATEFUL_DECODER) {
+                               int fd_flags = fcntl(node->g_fd(), F_GETFL);
+                               struct timeval tv = { 1, 0 };
+                               fd_set efds;
                                v4l2_event ev;
 
+                               fcntl(node->g_fd(), F_SETFL, fd_flags | 
O_NONBLOCK);
+                               FD_ZERO(&efds);
+                               FD_SET(node->g_fd(), &efds);
+                               ret = select(node->g_fd() + 1, nullptr, 
nullptr, &efds, &tv);
+                               fail_on_test_val(ret < 0, ret);
+                               fail_on_test(ret == 0);
                                fail_on_test(node->dqevent(ev));
+                               fcntl(node->g_fd(), F_SETFL, fd_flags);
                                fail_on_test(ev.type != 
V4L2_EVENT_SOURCE_CHANGE);
                                fail_on_test(!(ev.u.src_change.changes & 
V4L2_EVENT_SRC_CH_RESOLUTION));
                        }

_______________________________________________
linuxtv-commits mailing list
[email protected]
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to