posix_mq RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [ANN] posix_mq 2.2.0 - POSIX Message Queues for Ruby
@ 2015-01-16 20:32  7% Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2015-01-16 20:32 UTC (permalink / raw)
  To: ruby-talk, ruby-posix-mq; +Cc: Christopher Lord

POSIX message queues allow local processes to exchange data in the form
of messages.  This API is distinct from that provided by System V
message queues, but provides similar functionality.

* Homepage: http://bogomips.org/ruby_posix_mq/
* public-inbox: ruby-posix-mq@bogomips.org
* git clone git://bogomips.org/ruby_posix_mq.git
* Atom feed: http://bogomips.org/ruby_posix_mq/NEWS.atom.xml
* Mailing list archives: http://bogomips.org/ruby-posix-mq/

Changes:

The major feature of this release is the POSIX_MQ.for_fd class
method thanks to Christopher Lord.  The addition of the
POSIX_MQ#autoclose? and POSIX_MQ#autoclose= round out the new
feature set.  All of the new methods are analogous to their
counterparts in the core IO class.

The mailing list is also moved to ruby-posix-mq@bogomips.org
and no longer requires subscription.  Existing librelist
subscribers will need to resubscribe manually (as I have no
way of doing so automatically):

	ruby-posix-mq+subscribe@bogomips.org

HTTP archives and instructions for extracting the mail archives
via git are available at:

	http://bogomips.org/ruby-posix-mq/

Christopher Lord (1):
      Ability to adopt file descriptors

Eric Wong (16):
      for_fd: delay assigning to mq->des until after mq_getattr
      test_posix_mq: rewrite test to not depend on DL or alarm
      support autoclose= and autoclose?
      pack rw_args struct
      change mailing list to ruby-posix-mq@bogomips.org
      doc: remove --sanitize-html option for pandoc
      switch documentation to olddoc
      LICENSE: allow all future versions of LGPLv3+
      favor comparisons against zero instead of -1
      pkg.mk: misc tweaks and updates
      gemspec: remove rdoc_options setting
      .gitignore: add placeholder
      gemspec: use SPDX license abbreviation
      misc doc updates
      POSIX_MQ#autoclose= propagates to IO
      GNUmakefile: ordering fix for building gem
-- 
EW

^ permalink raw reply	[relevance 7%]

* [ruby.posix.mq] [RFC] POSIX_MQ#autoclose= propagates to IO
@ 2015-01-12  8:27  7% Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2015-01-12  8:27 UTC (permalink / raw)
  To: ruby.posix.mq

If a corresponding IO object exists or is created later, propagate
autoclose to the corresponding IO object to avoid simplify autoclose
handling for the user.  This hopefully avoids nasty surprises in case
users disable autoclose but want to keep the IO object around.
---
 Posting to the old list since that probably has more users.
 I'm not 100% sure this feature is desirable, but it's probably
 not harmful, either...  Maybe my head will be clearer after some
 sleep :)
 Anyways I want to release 2.2.0 soon.

 http://bogomips.org/ruby-posix-mq/ has more low-impact patches
 (subscribe by emailing ruby-posix-mq+subscribe@bogomips.org)

 ext/posix_mq/posix_mq.c | 17 ++++++++++++++++-
 test/test_posix_mq.rb   |  8 ++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/ext/posix_mq/posix_mq.c b/ext/posix_mq/posix_mq.c
index 78544c8..5e1b3b8 100644
--- a/ext/posix_mq/posix_mq.c
+++ b/ext/posix_mq/posix_mq.c
@@ -34,6 +34,7 @@
 #  define MQ_IO_SET(mq,val) ((void)(0))
 #  define MQ_IO_CLOSE(mq) ((int)(0))
 #  define MQ_IO_NIL_P(mq) ((int)(1))
+#  define MQ_IO_SET_AUTOCLOSE(mq, boolean) for(;0;)
 #endif
 
 struct posix_mq {
@@ -48,9 +49,17 @@ struct posix_mq {
 };
 
 #ifdef MQD_TO_FD
+static ID id_setautoclose;
 #  define MQ_IO_MARK(mq) rb_gc_mark((mq)->io)
 #  define MQ_IO_SET(mq,val) do { (mq)->io = (val); } while (0)
 #  define MQ_IO_NIL_P(mq) NIL_P((mq)->io)
+
+static void MQ_IO_SET_AUTOCLOSE(struct posix_mq *mq, VALUE boolean)
+{
+	if (!NIL_P(mq->io))
+		rb_funcall(mq->io, id_setautoclose, 1, boolean);
+}
+
 static int MQ_IO_CLOSE(struct posix_mq *mq)
 {
 	if (NIL_P(mq->io))
@@ -654,9 +663,13 @@ static VALUE to_io(VALUE self)
 	struct posix_mq *mq = get(self, 1);
 	int fd = MQD_TO_FD(mq->des);
 
-	if (NIL_P(mq->io))
+	if (NIL_P(mq->io)) {
 		mq->io = rb_funcall(rb_cIO, id_new, 1, INT2NUM(fd));
 
+		if (!mq->autoclose)
+			rb_funcall(mq->io, id_setautoclose, 1, Qfalse);
+	}
+
 	return mq->io;
 }
 #endif
@@ -1078,6 +1091,7 @@ static VALUE setautoclose(VALUE self, VALUE autoclose)
 {
 	struct posix_mq *mq = get(self, 1);
 
+	MQ_IO_SET_AUTOCLOSE(mq, autoclose);
 	mq->autoclose = RTEST(autoclose) ? 1 : 0;
 	return autoclose;
 }
@@ -1195,6 +1209,7 @@ void Init_posix_mq_ext(void)
 
 #ifdef FD_TO_MQD
 	rb_define_module_function(cPOSIX_MQ, "for_fd", for_fd, 1);
+	id_setautoclose = rb_intern("autoclose=");
 #endif
 
 	id_new = rb_intern("new");
diff --git a/test/test_posix_mq.rb b/test/test_posix_mq.rb
index a4fc407..35967e8 100644
--- a/test/test_posix_mq.rb
+++ b/test/test_posix_mq.rb
@@ -258,6 +258,14 @@ class Test_POSIX_MQ < Test::Unit::TestCase
     end
   end if POSIX_MQ.respond_to?(:for_fd) && POSIX_MQ.method_defined?(:to_io)
 
+  def test_autoclose_propagates_to_io
+    @mq = POSIX_MQ.new @path, IO::CREAT|IO::RDWR, 0666
+    @mq.autoclose = false
+    assert_equal false, @mq.to_io.autoclose?
+    @mq.autoclose = true
+    assert_equal true, @mq.to_io.autoclose?
+  end if POSIX_MQ.method_defined?(:to_io)
+
   def test_notify
     rd, wr = IO.pipe
     orig = trap(:USR1) { wr.syswrite('.') }
-- 
EW

^ permalink raw reply related	[relevance 7%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2015-01-12  8:27  7% [ruby.posix.mq] [RFC] POSIX_MQ#autoclose= propagates to IO Eric Wong
2015-01-16 20:32  7% [ANN] posix_mq 2.2.0 - POSIX Message Queues for Ruby Eric Wong

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/ruby_posix_mq.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).