From 531106e51e519458d37bed3721da4eff2f163206 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 8 Jan 2010 11:30:49 -0800 Subject: no point in non-blocking for fd notifications It's not needed since the native thread will retry in the unlikely case of EINTR/EAGAIN. And writing one byte to a pipe that's guaranteed by POSIX to be at least 512 bytes is highly unlikely. It's also bad because F_SETFL takes the big kernel lock under Linux (and possibly other systems), and doing it unnecessarily is a waste of system cycles. --- ext/posix_mq/posix_mq.c | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'ext/posix_mq/posix_mq.c') diff --git a/ext/posix_mq/posix_mq.c b/ext/posix_mq/posix_mq.c index 3972620..6480645 100644 --- a/ext/posix_mq/posix_mq.c +++ b/ext/posix_mq/posix_mq.c @@ -730,23 +730,9 @@ static void setup_notify_io(struct sigevent *not, VALUE io) { VALUE fileno = rb_funcall(io, id_fileno, 0, 0); int fd = NUM2INT(fileno); - int flags; pthread_attr_t attr; int e; - /* - * fd going to be written to inside a native thread, - * make it blocking for simplicity - */ - flags = fcntl(fd, F_GETFL); - if (flags < 0) { - rb_sys_fail("fcntl F_GETFL"); - } else if (flags & O_NONBLOCK) { - flags = fcntl(fd, F_SETFL, flags & ~O_NONBLOCK); - if (flags < 0) - rb_sys_fail("fcntl F_SETFL"); - } - if ((e = pthread_attr_init(&attr))) goto err; if ((e = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED))) -- cgit v1.2.3-24-ge0c7