avoid double close() and EBADF
commitcea38abf1f76b5b795b9341406ee814303f5752b
authorEric Wong <normalperson@yhbt.net>
Fri, 20 Aug 2010 02:25:58 +0000 (19 19:25 -0700)
committerEric Wong <normalperson@yhbt.net>
Fri, 20 Aug 2010 02:30:59 +0000 (19 19:30 -0700)
tree0d1e3345811c49cd2b101565d54013bcfb6af052
parent3cf7ec34b6319693af14215ebb0da51c3e6a4603
avoid double close() and EBADF

It can be dangerous to hit (and ignore) EBADF errors in
multi-threaded applications.  Users of POSIX_MQ#to_io have two
Ruby objects pointing to the same file descriptor, making
things tricky when it comes time to reap resources.

We'll always prefer to close the Ruby IO object if it exists
(because we have less control over its GC behavior) and
ignore the raw descriptor.
ext/posix_mq/posix_mq.c
test/test_posix_mq.rb