summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES1
-rw-r--r--src/Fl_lock.cxx11
2 files changed, 8 insertions, 4 deletions
diff --git a/CHANGES b/CHANGES
index 2f4fbcf60..bc7889ec2 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,6 @@
CHANGES IN FLTK 1.1.8
+ - Fl::awake() could block on X11 and OSX (STR #1537)
- WIN32 did check callbacks after the event processing instead of
before as documented (STR #1535)
- Fl_File_Chooser now hides the window before doing a callback
diff --git a/src/Fl_lock.cxx b/src/Fl_lock.cxx
index 895e78021..6f3b44f2c 100644
--- a/src/Fl_lock.cxx
+++ b/src/Fl_lock.cxx
@@ -127,9 +127,10 @@ void Fl::awake(void* msg) {
// POSIX threading...
#elif HAVE_PTHREAD
# include <unistd.h>
+# include <fcntl.h>
# include <pthread.h>
-# if defined (PTHREAD_MUTEX_RECURSIVE_NP)
+# ifdef PTHREAD_MUTEX_RECURSIVE_NP
// Linux supports recursive locks, use them directly:
static bool minit;
@@ -149,7 +150,7 @@ void Fl::unlock() {
pthread_mutex_unlock(&fltk_mutex);
}
-# else
+# else // !PTHREAD_MUTEX_RECURSIVE_NP
// Make a recursive lock out of the pthread mutex:
static pthread_mutex_t fltk_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -168,7 +169,7 @@ void Fl::unlock() {
if (!--counter) pthread_mutex_unlock(&fltk_mutex);
}
-# endif
+# endif // PTHREAD_MUTEX_RECURSIVE_NP
// Pipe for thread messaging...
static int thread_filedes[2];
@@ -193,6 +194,8 @@ void Fl::lock() {
if (!thread_filedes[1]) { // initialize the mt support
// Init threads communication pipe to let threads awake FLTK from wait
pipe(thread_filedes);
+ fcntl(thread_filedes[1], F_SETFL,
+ fcntl(thread_filedes[1], F_GETFL) | O_NONBLOCK);
Fl::add_fd(thread_filedes[0], FL_READ, thread_awake_cb);
fl_lock_function = lock_function;
fl_unlock_function = Fl::unlock;
@@ -203,7 +206,7 @@ void Fl::awake(void* msg) {
write(thread_filedes[1], &msg, sizeof(void*));
}
-#endif
+#endif // WIN32
//
// End of "$Id$".