[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-smalltalk] [PATCH 5/5] libgst: Fix a race when polling on a filede
From: |
Holger Hans Peter Freyther |
Subject: |
[Help-smalltalk] [PATCH 5/5] libgst: Fix a race when polling on a filedescriptor |
Date: |
Sun, 9 Sep 2012 23:57:02 +0200 |
From: Paolo Bonzini <address@hidden>
It is possible that data arrives after the initial poll
and before enabling SIGIO/SIGPOLL of the filedescriptor.
This would lead to a read on a sockey being blocked forever
even when data is available.
2012-09-09 Paolo Bonzini <address@hidden>
* libgst/sysdep/posix/events.c: Register the fd with gst
before polling.
---
libgst/ChangeLog | 5 +++++
libgst/sysdep/posix/events.c | 5 ++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/libgst/ChangeLog b/libgst/ChangeLog
index e04612c..31cd69a 100644
--- a/libgst/ChangeLog
+++ b/libgst/ChangeLog
@@ -1,3 +1,8 @@
+2012-09-09 Paolo Bonzini <address@hidden>
+
+ * libgst/sysdep/posix/events.c: Register the fd with gst
+ before polling.
+
2012-07-15 Paolo Bonzini <address@hidden>
* libgst/opt.c: Fix error in compute_jump_length that could lead
diff --git a/libgst/sysdep/posix/events.c b/libgst/sysdep/posix/events.c
index da3a784..2525b37 100644
--- a/libgst/sysdep/posix/events.c
+++ b/libgst/sysdep/posix/events.c
@@ -395,6 +395,10 @@ _gst_async_file_polling (int fd,
polling_queue *new;
index = num_used_pollfds++;
+
+ /* Enable async io on the fd before we poll as data could arrive after
+ the fd was polled and before the async io was enabled. */
+ set_file_interrupt (fd, file_polling_handler);
result = _gst_sync_file_polling (fd, cond);
if (result != 0)
{
@@ -431,7 +435,6 @@ _gst_async_file_polling (int fd,
}
pollfds[index].revents = 0;
- set_file_interrupt (fd, file_polling_handler);
/* Even if I/O was made possible while setting up our machinery,
the list will only be walked before the next bytecode, so there
--
1.7.10.4