sysvmq 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 328760516c12510088525cd9826745db77023e86
4
- data.tar.gz: fdf3c3f4f43d10a5cfa0f55fd4733ed75d8bd810
3
+ metadata.gz: d566493d3060b35ef5d50756f2222e02e9e0e1ac
4
+ data.tar.gz: 65f7630c46cad73ef1221d8997c37ad288376653
5
5
  SHA512:
6
- metadata.gz: eaac6f14803ef7dfa56adde984e003e4cafc60761364351663b49e5a9a816aa8a4461e6ba85b0e997209fa95cb8cdc11b73d750aca69e5d02682a2f1cac77ef3
7
- data.tar.gz: 326f9e82a5a91ce805fa4e864b5b0837dee7095553e65792945ac31d38885c09477abc36252238d1ebe66253edd99b28b668db25954281f0d18f9b7e7b23089b
6
+ metadata.gz: 61deff9290193b8fd854d3218e85a6570d4864cc8019995834f4d9b869fbe6f34e88c194fd618864417aa61d186866dd673b4435acef5281afd5670e0cf3cbc7
7
+ data.tar.gz: ff8ddcf9e22ffca17957d1d5109de66afe5c86f51c9fca5e46fc2461e2c5cfc097f55c50a4c75cc9098adc241876fa585ecec8c4be457fd1763cf2fd2197d5db
data/README.md CHANGED
@@ -1,11 +1,13 @@
1
1
  # sysvmq [![Build Status](https://travis-ci.org/Sirupsen/sysvmq.png?branch=v0.1.0)](https://travis-ci.org/Sirupsen/sysvmq)
2
2
 
3
- `sysvmq` is a C extension that wraps SysV IPC Message Queues. It's similar to
4
- the [POSIX MQ Ruby wrapper](https://github.com/Sirupsen/posix-mqueue). Message
5
- queues are handy for interprocess communication where you want to be able to
6
- take down either endpoint easily. The main disadvantage of SysV message queues
7
- over POSIX MQs (on Linux) is that SysV doesn't expose a file descriptor to do
8
- e.g. `select(2)` on.
3
+ `sysvmq` is a C extension that wraps System V IPC Message Queues. It's similar
4
+ to the [POSIX MQ Ruby wrapper](https://github.com/Sirupsen/posix-mqueue).
5
+ Message queues are handy for interprocess communication where you want to be
6
+ able to take down either endpoint easily. For example, a pipe or socket requires
7
+ you to implement handover logic in both applications. The main disadvantage of
8
+ SysV message queues over POSIX MQs (on Linux) is that SysV doesn't expose a file
9
+ descriptor to do e.g. `select(2)` on. The advantage of SysV is that it's
10
+ implemented on OS X, which POSIX MQs are not.
9
11
 
10
12
  Note that `sysvmq` doesn't rely on any third-party message broker. The message
11
13
  queue is handled by the kernel. It's extremely stable and performant.
@@ -28,7 +30,7 @@ mq = SysVMQ.new(0xDEADC0DE, 1024, SysVMQ::IPC_CREAT | 0666)
28
30
  mq.send "Hellø Wårld!"
29
31
  assert_equal 1, mq.stats[:count]
30
32
 
31
- assert_equal "Hellø Wårld!", mq.receive
33
+ assert_equal "Hellø Wårld!", mq.receive.force_encoding("UTF-8")
32
34
 
33
35
  # Raise an exception instead of blocking until a message is available
34
36
  mq.receive(0, SysVMQ::IPC_NOWAIT)
@@ -234,7 +234,7 @@ sysvmq_receive(int argc, VALUE *argv, VALUE self)
234
234
  assert(blocking.length != UNINITIALIZED_ERROR);
235
235
 
236
236
  // Reencode with default external encoding
237
- return rb_enc_str_new(sysv->msgbuf->mtext, blocking.length, rb_default_external_encoding());
237
+ return rb_str_new(sysv->msgbuf->mtext, blocking.length);
238
238
  }
239
239
 
240
240
  // Blocking call to msgsnd(2) (see sysvmq_send). This is to be called without
@@ -293,7 +293,7 @@ sysvmq_send(int argc, VALUE *argv, VALUE self)
293
293
  }
294
294
 
295
295
  // TODO: Can a string copy be avoided?
296
- strncpy(sysv->msgbuf->mtext, StringValueCStr(message), blocking.size);
296
+ memcpy(sysv->msgbuf->mtext, RSTRING_PTR(message), blocking.size);
297
297
 
298
298
  // Non-blocking call, skip the expensive GVL release/acquire
299
299
  if ((blocking.flags & IPC_NOWAIT) == IPC_NOWAIT) {
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "sysvmq"
7
- spec.version = '0.1.1'
7
+ spec.version = '0.2.0'
8
8
  spec.authors = ["Simon Eskildsen"]
9
9
  spec.email = ["sirup@sirupsen.com"]
10
10
  spec.summary = %q{Ruby wrapper for SysV Message Queues}
@@ -40,7 +40,7 @@ class SysVMQTest < MiniTest::Unit::TestCase
40
40
  def test_sends_and_receives_utf8
41
41
  message = "simån hørup"
42
42
  @mq.send message
43
- assert_equal message, @mq.receive
43
+ assert_equal message, @mq.receive.force_encoding("UTF-8")
44
44
  end
45
45
 
46
46
  def test_sending_5_bytes_should_report_5_byte_queue
@@ -123,4 +123,10 @@ class SysVMQTest < MiniTest::Unit::TestCase
123
123
  SysVMQ.new("0xDEADC0DE", @size, SysVMQ::IPC_CREAT | 0666)
124
124
  end
125
125
  end
126
+
127
+ def test_null_bytes
128
+ message = "\x00omg\x00omg"
129
+ @mq.send(message)
130
+ assert_equal message, @mq.receive
131
+ end
126
132
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sysvmq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Eskildsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-01 00:00:00.000000000 Z
11
+ date: 2014-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler