posix_mq 0.8.0pre → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,5 +1,92 @@
1
1
  ChangeLog from http://bogomips.org/ruby_posix_mq.git
2
2
 
3
+ commit 90b66d0a4390e7794247d43b49160a50a9028caa
4
+ Author: Eric Wong <normalperson@yhbt.net>
5
+ Date: Tue Mar 1 09:07:05 2011 +0000
6
+
7
+ posix_mq 1.0.0 - kinder, gentler message queues
8
+
9
+ There is one backwards-incompatible API change:
10
+
11
+ POSIX_MQ#send returns +true+ on success instead of +nil+
12
+ for consistency with POSIX_MQ#trysend.
13
+
14
+ This release adds the POSIX_MQ#trysend, POSIX_MQ#tryreceive and
15
+ POSIX_MQ#tryshift interfaces to avoid exceptions on common
16
+ EAGAIN errors for users of non-blocking queues.
17
+
18
+ Bugfixes: non-blocking behavior changes to a shared descriptor
19
+ in a different process are reflected immediately in the child
20
+ (this won't fix race conditions in your code, however).
21
+ Minor bugfixes for posix-mq-rb(1) and quieted warnings for
22
+ 1.9.3dev.
23
+
24
+ commit c44a8335b2f7ff60cf74730ac697a5e00829cc66
25
+ Author: Eric Wong <normalperson@yhbt.net>
26
+ Date: Tue Mar 1 08:57:16 2011 +0000
27
+
28
+ make methods that should be private, private
29
+
30
+ So private we won't mention them in the commit message!
31
+
32
+ commit c885c2d30b69925f6dd9f36e74c247e650db327b
33
+ Author: Eric Wong <normalperson@yhbt.net>
34
+ Date: Tue Mar 1 08:52:34 2011 +0000
35
+
36
+ remove unused tryinit function
37
+
38
+ Something I considered but decided wasn't worth doing.
39
+
40
+ commit d64ac2686c3c1ff1eea4534100dca8fd73228a62
41
+ Author: Eric Wong <normalperson@yhbt.net>
42
+ Date: Tue Mar 1 08:51:28 2011 +0000
43
+
44
+ POSIX_MQ#send returns +true+ on success
45
+
46
+ This is to be consistent with POSIX_MQ#trysend
47
+
48
+ commit ae1acbcc32aef9efd23daed0611e2919aa0e5037
49
+ Author: Eric Wong <normalperson@yhbt.net>
50
+ Date: Tue Mar 1 08:40:44 2011 +0000
51
+
52
+ finalize try* interfaces
53
+
54
+ Consider them good enough for a 1.0.0 release
55
+
56
+ commit a589cb81d02ce77fa7c7a027328a2cf714878773
57
+ Author: Eric Wong <normalperson@yhbt.net>
58
+ Date: Sun Feb 27 11:43:28 2011 +0000
59
+
60
+ posix-mq-rb: always prefer write-in-full behavior
61
+
62
+ In case somebody made the receiving pipe non-blocking,
63
+ we want the command-line tool to succeed.
64
+
65
+ commit 89c26cdaf25463c891a8ce915fefa1a181b3ac64
66
+ Author: Eric Wong <normalperson@yhbt.net>
67
+ Date: Sun Feb 27 11:40:40 2011 +0000
68
+
69
+ fix warnings and enable them for tests
70
+
71
+ Cleaner code anyways.
72
+
73
+ commit 5af56c9047dae680bde185c8a2b82de03b63e032
74
+ Author: Eric Wong <normalperson@yhbt.net>
75
+ Date: Sun Feb 27 11:37:23 2011 +0000
76
+
77
+ posix-mq-rb: use IO#binmode to get binary IOs
78
+
79
+ Avoids warnings this way
80
+
81
+ commit 316a435ff6c5b1bd9e0298aee096d16fb015405d
82
+ Author: Eric Wong <normalperson@yhbt.net>
83
+ Date: Sun Feb 27 11:27:51 2011 +0000
84
+
85
+ doc: note that the try* interfaces are not final
86
+
87
+ But they'll be pushed to the site for greater
88
+ visibility.
89
+
3
90
  commit 330846614470a64f34b671852ce4bf0f789aeb62
4
91
  Author: Eric Wong <normalperson@yhbt.net>
5
92
  Date: Sun Feb 27 11:11:19 2011 +0000
data/GIT-VERSION-FILE CHANGED
@@ -1 +1 @@
1
- GIT_VERSION = 0.8.0pre
1
+ GIT_VERSION = 1.0.0
data/GIT-VERSION-GEN CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/bin/sh
2
2
 
3
3
  GVF=GIT-VERSION-FILE
4
- DEF_VER=v0.8.0pre.GIT
4
+ DEF_VER=v1.0.0.GIT
5
5
 
6
6
  LF='
7
7
  '
data/LATEST CHANGED
@@ -1,25 +1,17 @@
1
- === posix_mq 0.8.0pre - kinder, gentler and less exceptional / 2011-02-27 11:13 UTC
1
+ === posix_mq 1.0.0 - kinder, gentler message queues / 2011-03-01 09:17 UTC
2
2
 
3
- This adds trysend, tryreceive, and tryshift interfaces to avoid
4
- exceptions on common EAGAIN errors for non-blocking users. EAGAIN
5
- during non-blocking messages is common when there are multiple
6
- readers/writer threads/processes working on the same queue.
3
+ There is one backwards-incompatible API change:
7
4
 
8
- trysend is like send, except it returns true for success and false for
9
- EAGAIN. send (still) returns nil, which I now consider a mistake but
10
- won't change until post-1.0...
5
+ POSIX_MQ#send returns +true+ on success instead of +nil+
6
+ for consistency with POSIX_MQ#trysend.
11
7
 
12
- tryreceive and tryshift are like receive and shift respectively,
13
- but they return nil for EAGAIN and the same return values
14
- for their non-shift variants.
8
+ This release adds the POSIX_MQ#trysend, POSIX_MQ#tryreceive and
9
+ POSIX_MQ#tryshift interfaces to avoid exceptions on common
10
+ EAGAIN errors for users of non-blocking queues.
15
11
 
16
- None of these methods call mq_setattr() beforehand to set the
17
- non-blocking flag, it assumes the user set it once before they were ever
18
- called and never changes it. Checking/setting the non-blocking flag
19
- every time is needless overhead and still subject to race conditions if
20
- multiple processes/queues keep flipping flag on the same queue
21
- descriptor.
22
-
23
- These interfaces are not yet final, feedback is appreciated
24
- at ruby.posix.mq@librelist.org.
12
+ Bugfixes: non-blocking behavior changes to a shared descriptor
13
+ in a different process are reflected immediately in the child
14
+ (this won't fix race conditions in your code, however).
15
+ Minor bugfixes for posix-mq-rb(1) and quieted warnings for
16
+ 1.9.3dev.
25
17
 
data/NEWS CHANGED
@@ -1,3 +1,20 @@
1
+ === posix_mq 1.0.0 - kinder, gentler message queues / 2011-03-01 09:17 UTC
2
+
3
+ There is one backwards-incompatible API change:
4
+
5
+ POSIX_MQ#send returns +true+ on success instead of +nil+
6
+ for consistency with POSIX_MQ#trysend.
7
+
8
+ This release adds the POSIX_MQ#trysend, POSIX_MQ#tryreceive and
9
+ POSIX_MQ#tryshift interfaces to avoid exceptions on common
10
+ EAGAIN errors for users of non-blocking queues.
11
+
12
+ Bugfixes: non-blocking behavior changes to a shared descriptor
13
+ in a different process are reflected immediately in the child
14
+ (this won't fix race conditions in your code, however).
15
+ Minor bugfixes for posix-mq-rb(1) and quieted warnings for
16
+ 1.9.3dev.
17
+
1
18
  === posix_mq 0.8.0pre - kinder, gentler and less exceptional / 2011-02-27 11:13 UTC
2
19
 
3
20
  This adds trysend, tryreceive, and tryshift interfaces to avoid
data/bin/posix-mq-rb CHANGED
@@ -1,7 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
  # -*- encoding: binary -*-
3
- Encoding.default_external = Encoding::BINARY if defined?(Encoding)
4
3
  $stderr.sync = $stdout.sync = true
4
+ $stdout.binmode
5
+ $stderr.binmode
6
+ $stdin.binmode
5
7
 
6
8
  require 'posix_mq'
7
9
  require 'optparse'
@@ -70,7 +72,7 @@ ARGV.options do |x|
70
72
  }
71
73
  end
72
74
  end
73
- x.on('-q', "quiet warnings and errors") { $stderr.reopen("/dev/null", "w") }
75
+ x.on('-q', "quiet warnings and errors") { $stderr.reopen("/dev/null", "wb") }
74
76
  x.on('-h', '--help', 'Show this help message.') { puts x; exit }
75
77
  x.parse!
76
78
  end
@@ -99,14 +101,14 @@ begin
99
101
  exit
100
102
  when :receive
101
103
  buf, prio = mq.receive("", timeout)
102
- $stderr.syswrite("priority=#{prio}\n") if priority
103
- $stdout.syswrite(buf)
104
+ $stderr.write("priority=#{prio}\n") if priority
105
+ $stdout.write(buf)
104
106
  when :send
105
107
  ARGV << $stdin.read if ARGV.empty?
106
108
  ARGV.each { |msg| mq.send(msg, priority, timeout) }
107
109
  when :attr
108
110
  mq_attr = mq.attr
109
- $stdout.syswrite(
111
+ $stdout.write(
110
112
  "flags=#{mq_attr.flags}\n" \
111
113
  "maxmsg=#{mq_attr.maxmsg}\n" \
112
114
  "msgsize=#{mq_attr.msgsize}\n" \
@@ -509,9 +509,10 @@ static void setup_send_buffer(struct rw_args *x, VALUE buffer)
509
509
  }
510
510
 
511
511
  static VALUE _send(int sflags, int argc, VALUE *argv, VALUE self);
512
+
512
513
  /*
513
514
  * call-seq:
514
- * mq.send(string [,priority[, timeout]]) => nil
515
+ * mq.send(string [,priority[, timeout]]) => true
515
516
  *
516
517
  * Inserts the given +string+ into the message queue with an optional,
517
518
  * unsigned integer +priority+. If the optional +timeout+ is specified,
@@ -524,7 +525,7 @@ static VALUE _send(int sflags, int argc, VALUE *argv, VALUE self);
524
525
  */
525
526
  static VALUE my_send(int argc, VALUE *argv, VALUE self)
526
527
  {
527
- _send(0, argc, argv, self);
528
+ return _send(0, argc, argv, self);
528
529
  }
529
530
 
530
531
  static VALUE _send(int sflags, int argc, VALUE *argv, VALUE self)
@@ -549,7 +550,7 @@ static VALUE _send(int sflags, int argc, VALUE *argv, VALUE self)
549
550
  rb_sys_fail("mq_send");
550
551
  }
551
552
 
552
- return (sflags & PMQ_TRY) ? Qtrue : Qnil;
553
+ return Qtrue;
553
554
  }
554
555
 
555
556
  /*
@@ -558,6 +559,10 @@ static VALUE _send(int sflags, int argc, VALUE *argv, VALUE self)
558
559
  *
559
560
  * Inserts the given +string+ into the message queue with a
560
561
  * default priority of 0 and no timeout.
562
+ *
563
+ * Returns itself so its calls may be chained. This use is only
564
+ * recommended only for users who expect blocking behavior from
565
+ * the queue.
561
566
  */
562
567
  static VALUE send0(VALUE self, VALUE buffer)
563
568
  {
@@ -983,21 +988,14 @@ static VALUE setnonblock(VALUE self, VALUE nb)
983
988
  return nb;
984
989
  }
985
990
 
986
- static VALUE tryinit(int argc, VALUE *argv, VALUE self)
987
- {
988
- init(argc, argv, self);
989
- setnonblock(self, Qtrue);
990
-
991
- return self;
992
- }
993
-
994
991
  /*
995
992
  * call-seq:
996
993
  * mq.trysend(string [,priority[, timeout]]) => +true+ or +false+
997
994
  *
998
995
  * Exactly like POSIX_MQ#send, except it returns +false+ instead of raising
999
- * +Errno::EAGAIN+ when non-blocking operation is desired and returns +true+
996
+ * Errno::EAGAIN when non-blocking operation is desired and returns +true+
1000
997
  * on success instead of +nil+.
998
+ *
1001
999
  * This does not guarantee non-blocking behavior, the message queue must
1002
1000
  * be made non-blocking before calling this method.
1003
1001
  */
@@ -1011,7 +1009,7 @@ static VALUE trysend(int argc, VALUE *argv, VALUE self)
1011
1009
  * mq.tryshift([buffer [, timeout]]) => message or nil
1012
1010
  *
1013
1011
  * Exactly like POSIX_MQ#shift, except it returns +nil+ instead of raising
1014
- * +Errno::EAGAIN+ when non-blocking operation is desired.
1012
+ * Errno::EAGAIN when non-blocking operation is desired.
1015
1013
  *
1016
1014
  * This does not guarantee non-blocking behavior, the message queue must
1017
1015
  * be made non-blocking before calling this method.
@@ -1026,7 +1024,7 @@ static VALUE tryshift(int argc, VALUE *argv, VALUE self)
1026
1024
  * mq.tryreceive([buffer [, timeout]]) => [ message, priority ] or nil
1027
1025
  *
1028
1026
  * Exactly like POSIX_MQ#receive, except it returns +nil+ instead of raising
1029
- * +Errno::EAGAIN+ when non-blocking operation is desired.
1027
+ * Errno::EAGAIN when non-blocking operation is desired.
1030
1028
  *
1031
1029
  * This does not guarantee non-blocking behavior, the message queue must
1032
1030
  * be made non-blocking before calling this method.
@@ -1062,7 +1060,7 @@ void Init_posix_mq_ext(void)
1062
1060
 
1063
1061
  rb_define_singleton_method(cPOSIX_MQ, "unlink", s_unlink, 1);
1064
1062
 
1065
- rb_define_method(cPOSIX_MQ, "initialize", init, -1);
1063
+ rb_define_private_method(cPOSIX_MQ, "initialize", init, -1);
1066
1064
  rb_define_method(cPOSIX_MQ, "send", my_send, -1);
1067
1065
  rb_define_method(cPOSIX_MQ, "<<", send0, 1);
1068
1066
  rb_define_method(cPOSIX_MQ, "trysend", trysend, -1);
@@ -1078,8 +1076,8 @@ void Init_posix_mq_ext(void)
1078
1076
  rb_define_method(cPOSIX_MQ, "name", name, 0);
1079
1077
  rb_define_method(cPOSIX_MQ, "notify=", setnotify, 1);
1080
1078
  rb_define_method(cPOSIX_MQ, "nonblock=", setnonblock, 1);
1081
- rb_define_method(cPOSIX_MQ, "notify_exec", setnotify_exec, 2);
1082
- rb_define_method(cPOSIX_MQ, "notify_cleanup", notify_cleanup, 0);
1079
+ rb_define_private_method(cPOSIX_MQ, "notify_exec", setnotify_exec, 2);
1080
+ rb_define_private_method(cPOSIX_MQ, "notify_cleanup", notify_cleanup, 0);
1083
1081
  rb_define_method(cPOSIX_MQ, "nonblock?", nonblock_p, 0);
1084
1082
  #ifdef MQD_TO_FD
1085
1083
  rb_define_method(cPOSIX_MQ, "to_io", to_io, 0);
data/lib/posix_mq.rb CHANGED
@@ -51,16 +51,16 @@ class POSIX_MQ
51
51
  block.arity == 1 or
52
52
  raise ArgumentError, "arity of notify block must be 1"
53
53
  r, w = IO.pipe
54
- self.notify_exec(w, Thread.new(r, w, self) do |r, w, mq|
54
+ notify_exec(w, Thread.new(block) do |blk|
55
55
  begin
56
56
  begin
57
57
  r.read(1) or raise Errno::EINTR
58
58
  rescue Errno::EINTR, Errno::EAGAIN
59
59
  retry
60
60
  end
61
- block.call(mq)
61
+ blk.call(self)
62
62
  ensure
63
- mq.notify_cleanup
63
+ notify_cleanup
64
64
  r.close rescue nil
65
65
  w.close rescue nil
66
66
  end
@@ -1,6 +1,5 @@
1
1
  # -*- encoding: binary -*-
2
2
  require 'test/unit'
3
- require 'posix_mq'
4
3
  require 'thread'
5
4
  require 'fcntl'
6
5
  $stderr.sync = $stdout.sync = true
@@ -9,6 +8,8 @@ begin
9
8
  require "dl/func"
10
9
  rescue LoadError
11
10
  end
11
+ $-w = true
12
+ require 'posix_mq'
12
13
 
13
14
  class Test_POSIX_MQ < Test::Unit::TestCase
14
15
 
@@ -154,7 +155,7 @@ class Test_POSIX_MQ < Test::Unit::TestCase
154
155
  @mq = mq
155
156
  assert mq.kind_of?(POSIX_MQ)
156
157
  assert_equal @path, mq.name
157
- assert_nil mq.send("HI", 0)
158
+ assert_equal true, mq.send("HI", 0)
158
159
  assert_equal 1, mq.attr.curmsgs
159
160
  assert_nil mq.close
160
161
  assert_raises(IOError) { mq.close }
@@ -207,21 +208,21 @@ class Test_POSIX_MQ < Test::Unit::TestCase
207
208
 
208
209
  def test_send_receive
209
210
  @mq = POSIX_MQ.new @path, IO::CREAT|IO::RDWR, 0666
210
- assert_nil @mq.send("hello", 0)
211
+ assert_equal true, @mq.send("hello", 0)
211
212
  assert_equal [ "hello", 0 ], @mq.receive
212
213
  end
213
214
 
214
215
  def test_send_receive_buf
215
216
  buf = ""
216
217
  @mq = POSIX_MQ.new @path, IO::CREAT|IO::RDWR, 0666
217
- assert_nil @mq.send("hello", 0)
218
+ assert_equal true, @mq.send("hello", 0)
218
219
  assert_equal [ "hello", 0 ], @mq.receive(buf)
219
220
  assert_equal "hello", buf
220
221
  end
221
222
 
222
223
  def test_send_receive_prio
223
224
  @mq = POSIX_MQ.new @path, IO::CREAT|IO::RDWR, 0666
224
- assert_nil @mq.send("hello", 2)
225
+ assert_equal true, @mq.send("hello", 2)
225
226
  assert_equal [ "hello", 2 ], @mq.receive
226
227
  end
227
228
 
@@ -402,7 +403,7 @@ class Test_POSIX_MQ < Test::Unit::TestCase
402
403
  end if POSIX_MQ.method_defined?(:notify)
403
404
 
404
405
  def test_bad_open_mode
405
- assert_raises(ArgumentError) { mq = POSIX_MQ.new(@path, "rw") }
406
+ assert_raises(ArgumentError) { POSIX_MQ.new(@path, "rw") }
406
407
  end
407
408
 
408
409
  def test_bad_open_attr
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: posix_mq
3
3
  version: !ruby/object:Gem::Version
4
- hash: 961915908
5
- prerelease: 5
4
+ hash: 23
5
+ prerelease:
6
6
  segments:
7
+ - 1
7
8
  - 0
8
- - 8
9
9
  - 0
10
- - pre
11
- version: 0.8.0pre
10
+ version: 1.0.0
12
11
  platform: ruby
13
12
  authors:
14
13
  - Ruby POSIX MQ hackers
@@ -16,7 +15,7 @@ autorequire:
16
15
  bindir: bin
17
16
  cert_chain: []
18
17
 
19
- date: 2011-02-27 00:00:00 +00:00
18
+ date: 2011-03-01 00:00:00 +00:00
20
19
  default_executable:
21
20
  dependencies:
22
21
  - !ruby/object:Gem::Dependency
@@ -103,14 +102,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
102
  required_rubygems_version: !ruby/object:Gem::Requirement
104
103
  none: false
105
104
  requirements:
106
- - - ">"
105
+ - - ">="
107
106
  - !ruby/object:Gem::Version
108
- hash: 25
107
+ hash: 3
109
108
  segments:
110
- - 1
111
- - 3
112
- - 1
113
- version: 1.3.1
109
+ - 0
110
+ version: "0"
114
111
  requirements: []
115
112
 
116
113
  rubyforge_project: qrp