sysvmq 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +9 -7
- data/ext/sysvmq.c +2 -2
- data/sysvmq.gemspec +1 -1
- data/test/sysv_mq_test.rb +7 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d566493d3060b35ef5d50756f2222e02e9e0e1ac
|
4
|
+
data.tar.gz: 65f7630c46cad73ef1221d8997c37ad288376653
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61deff9290193b8fd854d3218e85a6570d4864cc8019995834f4d9b869fbe6f34e88c194fd618864417aa61d186866dd673b4435acef5281afd5670e0cf3cbc7
|
7
|
+
data.tar.gz: ff8ddcf9e22ffca17957d1d5109de66afe5c86f51c9fca5e46fc2461e2c5cfc097f55c50a4c75cc9098adc241876fa585ecec8c4be457fd1763cf2fd2197d5db
|
data/README.md
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
# sysvmq [](https://travis-ci.org/Sirupsen/sysvmq)
|
2
2
|
|
3
|
-
`sysvmq` is a C extension that wraps
|
4
|
-
the [POSIX MQ Ruby wrapper](https://github.com/Sirupsen/posix-mqueue).
|
5
|
-
queues are handy for interprocess communication where you want to be
|
6
|
-
take down either endpoint easily.
|
7
|
-
|
8
|
-
|
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)
|
data/ext/sysvmq.c
CHANGED
@@ -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
|
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
|
-
|
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) {
|
data/sysvmq.gemspec
CHANGED
@@ -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.
|
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}
|
data/test/sysv_mq_test.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2014-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|