Fix libpbd tests.
[ardour.git] / libs / pbd / crossthread.cc
index 7ccf7413806a07408200b068d73be0afbc4ca3c4..2ffede5163aecc736372818fd82ddb934b2d8d42 100644 (file)
@@ -30,7 +30,7 @@ using namespace std;
 using namespace PBD;
 using namespace Glib;
 
-CrossThreadChannel::CrossThreadChannel ()
+CrossThreadChannel::CrossThreadChannel (bool non_blocking)
 {
        _ios = 0;
        fds[0] = -1;
@@ -41,14 +41,16 @@ CrossThreadChannel::CrossThreadChannel ()
                return;
        }
 
-       if (fcntl (fds[0], F_SETFL, O_NONBLOCK)) {
-               error << "cannot set non-blocking mode for x-thread pipe (read) (" << ::strerror (errno) << ')' << endmsg;
-               return;
-       }
-
-       if (fcntl (fds[1], F_SETFL, O_NONBLOCK)) {
-               error << "cannot set non-blocking mode for x-thread pipe (write) (%2)" << ::strerror (errno) << ')' << endmsg;
-               return;
+       if (non_blocking) {
+               if (fcntl (fds[0], F_SETFL, O_NONBLOCK)) {
+                       error << "cannot set non-blocking mode for x-thread pipe (read) (" << ::strerror (errno) << ')' << endmsg;
+                       return;
+               }
+               
+               if (fcntl (fds[1], F_SETFL, O_NONBLOCK)) {
+                       error << "cannot set non-blocking mode for x-thread pipe (write) (%2)" << ::strerror (errno) << ')' << endmsg;
+                       return;
+               }
        }
 }
 
@@ -72,7 +74,7 @@ void
 CrossThreadChannel::wakeup ()
 {
        char c = 0;
-       ::write (fds[1], &c, 1);
+       (void) ::write (fds[1], &c, 1);
 }
 
 RefPtr<IOSource>
@@ -102,7 +104,7 @@ CrossThreadChannel::drain (int fd)
 {
        /* drain selectable fd */
        char buf[64];
-       while (::read (fd, buf, sizeof (buf)) > 0);
+       while (::read (fd, buf, sizeof (buf)) > 0) {};
 }
 
 int