sysvmq 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/README.md +24 -1
- data/ext/extconf.rb +5 -0
- data/ext/sysvmq.c +16 -3
- data/sysvmq.gemspec +1 -1
- data/test/sysv_mq_test.rb +2 -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: 9b62bd6b368c988aa1821158c4a68eade4d2dd28
|
4
|
+
data.tar.gz: 1722201de77944fd64324927a0c681f08b700596
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6810448b3b02f863bb4a0989d0b45b36693ecdb3ef68252a2beb5578367741910b5e7193d61307d65d7fe252e8c5dcdfe73995a4eb659ad2ba399f1f22ba2bec
|
7
|
+
data.tar.gz: e986084ee94f00982699a93cc67063a58d7f43db3c2e15b4d4d36bcd506cccfc25e2b386b77c49d6f92ff7f5fb4e3be1426b076296c9553e017fe5c88f2adf4a
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -18,7 +18,7 @@ Add `sysvm` to your Gemfile.
|
|
18
18
|
|
19
19
|
`gem 'sysvmq'`
|
20
20
|
|
21
|
-
Currently known to work on Linux and OS X for MRI >=
|
21
|
+
Currently known to work on Linux and OS X for MRI >= 1.9
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
@@ -40,6 +40,29 @@ ensure
|
|
40
40
|
mq.destroy
|
41
41
|
```
|
42
42
|
|
43
|
+
## Proc settings
|
44
|
+
|
45
|
+
System V queues are limited by default to a maximum of 16 message queues, a maximum of 8KB per message, and a maximum of 16KB for the total size of all messages in a queue.
|
46
|
+
|
47
|
+
To increase (or decrease) these limits, either run:
|
48
|
+
|
49
|
+
```sh
|
50
|
+
sysctl -w kernel.msgmni=32
|
51
|
+
sysctl -w kernel.msgmax=1000000
|
52
|
+
sysctl -w kernel.msgmnb=2000000
|
53
|
+
```
|
54
|
+
|
55
|
+
or write to /etc/sysctl.conf:
|
56
|
+
|
57
|
+
```sh
|
58
|
+
echo 'kernel.msgmni=32' >> /etc/sysctl.conf # maximum number of message queues
|
59
|
+
echo 'kernel.msgmax=1000000' >> /etc/sysctl.conf # maximum number of bytes per message
|
60
|
+
echo 'kernel.msgmnb=2000000' >> /etc/sysctl.conf # maximum total size of all messages in a queue
|
61
|
+
sysctl -p
|
62
|
+
```
|
63
|
+
|
64
|
+
See http://man7.org/linux/man-pages/man5/proc.5.html for more information.
|
65
|
+
|
43
66
|
## Todo
|
44
67
|
|
45
68
|
* Explain messages types
|
data/ext/extconf.rb
CHANGED
data/ext/sysvmq.c
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
#include <ruby.h>
|
2
2
|
#include <ruby/util.h>
|
3
|
-
#include <ruby/thread.h>
|
4
3
|
#include <ruby/io.h>
|
5
4
|
|
6
5
|
#include <sys/types.h>
|
@@ -15,6 +14,20 @@
|
|
15
14
|
|
16
15
|
#define UNINITIALIZED_ERROR -2
|
17
16
|
|
17
|
+
#if defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL) && defined(HAVE_RUBY_THREAD_H)
|
18
|
+
// 2.0
|
19
|
+
#include <ruby/thread.h>
|
20
|
+
#define WITHOUT_GVL(fn,a,ubf,b) \
|
21
|
+
rb_thread_call_without_gvl((fn),(a),(ubf),(b))
|
22
|
+
|
23
|
+
#elif defined(HAVE_RB_THREAD_BLOCKING_REGION)
|
24
|
+
// 1.9
|
25
|
+
typedef VALUE (*my_blocking_fn_t)(void*);
|
26
|
+
#define WITHOUT_GVL(fn,a,ubf,b) \
|
27
|
+
rb_thread_blocking_region((my_blocking_fn_t)(fn),(a),(ubf),(b))
|
28
|
+
|
29
|
+
#endif
|
30
|
+
|
18
31
|
// This is the buffer passed to msg{rcv,snd,ctl}(2)
|
19
32
|
typedef struct {
|
20
33
|
long mtype;
|
@@ -220,7 +233,7 @@ sysvmq_receive(int argc, VALUE *argv, VALUE self)
|
|
220
233
|
// We unlock the GVL waiting for the call so other threads (e.g. signal
|
221
234
|
// handling) can continue to work. Sets `length` on `blocking` with the size
|
222
235
|
// of the message returned.
|
223
|
-
while (
|
236
|
+
while (WITHOUT_GVL(sysvmq_maybe_blocking_receive, &blocking, RUBY_UBF_IO, NULL) == NULL
|
224
237
|
&& blocking.error < 0) {
|
225
238
|
if (errno == EINTR || blocking.error == UNINITIALIZED_ERROR) {
|
226
239
|
continue;
|
@@ -308,7 +321,7 @@ sysvmq_send(int argc, VALUE *argv, VALUE self)
|
|
308
321
|
// msgsnd(2) can block waiting for a message, if IPC_NOWAIT is not passed.
|
309
322
|
// We unlock the GVL waiting for the call so other threads (e.g. signal
|
310
323
|
// handling) can continue to work.
|
311
|
-
while (
|
324
|
+
while (WITHOUT_GVL(sysvmq_maybe_blocking_send, &blocking, RUBY_UBF_IO, NULL) == NULL
|
312
325
|
&& blocking.error < 0) {
|
313
326
|
if (errno == EINTR || blocking.error == UNINITIALIZED_ERROR) {
|
314
327
|
continue;
|
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.2.
|
7
|
+
spec.version = '0.2.1'
|
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
@@ -1,3 +1,4 @@
|
|
1
|
+
#coding: utf-8
|
1
2
|
require_relative 'test_helper'
|
2
3
|
|
3
4
|
class SysVMQTest < MiniTest::Unit::TestCase
|
@@ -52,7 +53,7 @@ class SysVMQTest < MiniTest::Unit::TestCase
|
|
52
53
|
def test_sending_utf_should_report_correct_size_queue
|
53
54
|
message = "ø" * 5
|
54
55
|
@mq.send message
|
55
|
-
assert_equal "ø".bytes.size * 5, @mq.stats[:size]
|
56
|
+
assert_equal "ø".bytes.to_a.size * 5, @mq.stats[:size]
|
56
57
|
end
|
57
58
|
|
58
59
|
def test_receive_on_empty_queue_raises_enomsg_if_ipc_nowait
|
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.2.
|
4
|
+
version: 0.2.1
|
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-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|