posix_mq 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +0 -2
- data/.gitignore +2 -2
- data/{.wrongdoc.yml → .olddoc.yml} +3 -0
- data/Documentation/GNUmakefile +1 -1
- data/Documentation/posix-mq-rb.1.txt +1 -1
- data/GIT-VERSION-GEN +1 -1
- data/GNUmakefile +3 -10
- data/LICENSE +6 -8
- data/README +37 -9
- data/archive/.gitignore +3 -0
- data/archive/slrnpull.conf +4 -0
- data/ext/posix_mq/posix_mq.c +108 -10
- data/lib/posix_mq.rb +1 -1
- data/pkg.mk +23 -48
- data/posix_mq.gemspec +6 -10
- data/test/test_posix_mq.rb +41 -19
- metadata +33 -52
- data/Rakefile +0 -33
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cd61a0174a8b5bc70e3c7f7dba0a3192ed5c3a4f
|
4
|
+
data.tar.gz: 33d0325cd7b5804755ef3ab663e71acaa22d4171
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: df3e903bd7fcd24583a3a7202d565ba83963974d071dc5a292ad3451324ed95e538ad20a50552cc5a3c28c9680cbe3d736be82fd6d975b9a308f94899d28759a
|
7
|
+
data.tar.gz: 06c68326b0514f8ca43d2ade5621bee95d62f11526779715f6b1a0732e01c038fe906c58c8b887aa09cb7034ce97c957227f051743fd5a5fae599c14c4934679
|
data/.document
CHANGED
data/.gitignore
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
rdoc_url: http://bogomips.org/ruby_posix_mq/
|
3
3
|
cgit_url: http://bogomips.org/ruby_posix_mq.git
|
4
4
|
git_url: git://bogomips.org/ruby_posix_mq.git
|
5
|
+
public_email: ruby-posix-mq@bogomips.org
|
6
|
+
private_email: bofh@bogomips.org
|
7
|
+
ml_url: http://bogomips.org/ruby-posix-mq/
|
5
8
|
changelog_since: 0.4.0
|
6
9
|
merge_html:
|
7
10
|
posix-mq-rb_1: Documentation/posix-mq-rb.1.html
|
data/Documentation/GNUmakefile
CHANGED
data/GIT-VERSION-GEN
CHANGED
data/GNUmakefile
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
all::
|
2
|
+
PLACEHOLDERS = posix-mq-rb_1
|
2
3
|
RSYNC_DEST := bogomips.org:/srv/bogomips/ruby_posix_mq
|
3
|
-
rfproject := qrp
|
4
4
|
rfpackage := posix_mq
|
5
|
-
man-rdoc: man html
|
6
|
-
for i in $(man1_rdoc); do echo > $$i; done
|
7
|
-
doc:: man-rdoc
|
8
|
-
include pkg.mk
|
9
|
-
ifneq ($(VERSION),)
|
10
|
-
release::
|
11
|
-
$(RAKE) publish_news VERSION=$(VERSION)
|
12
|
-
endif
|
13
5
|
|
14
6
|
base_bins := posix-mq-rb
|
15
7
|
bins := $(addprefix bin/, $(base_bins))
|
@@ -24,8 +16,9 @@ man html:
|
|
24
16
|
$(MAKE) -C Documentation install-$@
|
25
17
|
|
26
18
|
pkg_extra += $(man1_paths)
|
19
|
+
$(man1_paths): man
|
20
|
+
include pkg.mk
|
27
21
|
|
28
22
|
doc::
|
29
23
|
install -m644 COPYING-GPL2 doc/COPYING-GPL2
|
30
|
-
$(RM) $(man1_rdoc)
|
31
24
|
.PHONY: man html
|
data/LICENSE
CHANGED
@@ -3,13 +3,11 @@ revision control for names and email addresses of all of them.
|
|
3
3
|
|
4
4
|
You can redistribute it and/or modify it either under the terms of the GNU
|
5
5
|
Lesser General Public License as published by the Free Software Foundation,
|
6
|
-
version 3.0 {LGPLv3}[
|
7
|
-
link:COPYING)
|
8
|
-
{GPLv2}[http://www.gnu.org/licenses/gpl-2.0.txt] (see link:COPYING-GPL2).
|
6
|
+
version 3.0 or later {LGPLv3+}[https://www.gnu.org/licenses/lgpl-3.0.txt]
|
7
|
+
(see link:COPYING).
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
(but no other licenses).
|
9
|
+
It is also available under the GNU General Public License
|
10
|
+
{GPLv2}[https://www.gnu.org/licenses/gpl-2.0.txt] (see link:COPYING-GPL2).
|
13
11
|
|
14
12
|
Ruby posix_mq is distributed in the hope that it will be useful, but
|
15
13
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
@@ -17,5 +15,5 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
|
17
15
|
General Public License for more details.
|
18
16
|
|
19
17
|
You should have received a copy of the GNU Lesser General Public License
|
20
|
-
along with Ruby posix_mq; if not,
|
21
|
-
|
18
|
+
along with Ruby posix_mq; if not, see:
|
19
|
+
https://www.gnu.org/licenses/lgpl-3.0.txt
|
data/README
CHANGED
@@ -23,10 +23,10 @@ network-aware message queue implementations.
|
|
23
23
|
|
24
24
|
* Optional timeouts may be applied to send and receive operations.
|
25
25
|
|
26
|
-
* Thread-safe blocking operations under Ruby 1.9
|
26
|
+
* Thread-safe blocking operations under Ruby 1.9+, releases GVL
|
27
27
|
before blocking operations.
|
28
28
|
|
29
|
-
* Works under Ruby 1.
|
29
|
+
* Works under Ruby 1.9 and later.
|
30
30
|
|
31
31
|
* Documented library API
|
32
32
|
|
@@ -113,7 +113,7 @@ don't email the git mailing list or maintainer with Ruby posix_mq patches.
|
|
113
113
|
== Contact
|
114
114
|
|
115
115
|
All feedback (bug reports, user/development discussion, patches, pull
|
116
|
-
requests) go to the mailing list: mailto:ruby
|
116
|
+
requests) go to the mailing list: mailto:ruby-posix-mq@bogomips.org
|
117
117
|
|
118
118
|
Send patches (from "git format-patch") with "git send-email" and do not
|
119
119
|
send HTML email or attachments. We are very responsive to email and you
|
@@ -121,10 +121,38 @@ will usually get a response within 24-72 hours.
|
|
121
121
|
|
122
122
|
== Mailing List Archives
|
123
123
|
|
124
|
-
|
125
|
-
|
126
|
-
{
|
127
|
-
|
124
|
+
We operate a {public-inbox}[http://public-inbox.org/] which
|
125
|
+
feeds the mailing list. You may subscribe either using
|
126
|
+
{ssoma}[http://ssoma.public-inbox.org/] or by sending a mail
|
127
|
+
to mailto:ruby-posix-mq+subscribe@bogomips.org
|
128
128
|
|
129
|
-
|
130
|
-
|
129
|
+
ssoma is a mail archiver/fetcher using git. It operates in a similar
|
130
|
+
fashion to tools such as slrnpull, fetchmail, or getmail. ssoma
|
131
|
+
subscription instructions:
|
132
|
+
|
133
|
+
URL=git://bogomips.org/ruby-posix-mq
|
134
|
+
LISTNAME=ruby-posix-mq
|
135
|
+
|
136
|
+
# to initialize a maildir (this may be a new or existing maildir,
|
137
|
+
# ssoma will not touch existing messages)
|
138
|
+
# If you prefer mbox, use mbox:/path/to/mbox as the last argument
|
139
|
+
# You may also use imap://$MAILSERVER/INBOX for an IMAP account
|
140
|
+
# or imaps:// for an IMAPS account, as well.
|
141
|
+
ssoma add $LISTNAME $URL maildir:/path/to/maildir
|
142
|
+
|
143
|
+
# read with your favorite MUA (only using mutt as an example)
|
144
|
+
mutt -f /path/to/maildir # (or /path/to/mbox)
|
145
|
+
|
146
|
+
# to keep your mbox or maildir up-to-date, periodically run:
|
147
|
+
ssoma sync $LISTNAME
|
148
|
+
|
149
|
+
# your MUA may modify and delete messages from the maildir or mbox,
|
150
|
+
# this does not affect ssoma functionality at all
|
151
|
+
|
152
|
+
# to sync all your ssoma subscriptions
|
153
|
+
ssoma sync
|
154
|
+
|
155
|
+
# You may wish to sync in your cronjob
|
156
|
+
ssoma sync --cron
|
157
|
+
|
158
|
+
* Mailing list archives: http://bogomips.org/ruby-posix-mq/
|
data/archive/.gitignore
ADDED
data/ext/posix_mq/posix_mq.c
CHANGED
@@ -26,6 +26,7 @@
|
|
26
26
|
|
27
27
|
#if defined(__linux__)
|
28
28
|
# define MQD_TO_FD(mqd) (int)(mqd)
|
29
|
+
# define FD_TO_MQD(fd) (mqd_t)(fd)
|
29
30
|
#elif defined(HAVE___MQ_OSHANDLE) /* FreeBSD */
|
30
31
|
# define MQD_TO_FD(mqd) __mq_oshandle(mqd)
|
31
32
|
#else
|
@@ -33,10 +34,12 @@
|
|
33
34
|
# define MQ_IO_SET(mq,val) ((void)(0))
|
34
35
|
# define MQ_IO_CLOSE(mq) ((int)(0))
|
35
36
|
# define MQ_IO_NIL_P(mq) ((int)(1))
|
37
|
+
# define MQ_IO_SET_AUTOCLOSE(mq, boolean) for(;0;)
|
36
38
|
#endif
|
37
39
|
|
38
40
|
struct posix_mq {
|
39
41
|
mqd_t des;
|
42
|
+
unsigned autoclose:1;
|
40
43
|
struct mq_attr attr;
|
41
44
|
VALUE name;
|
42
45
|
VALUE thread;
|
@@ -46,9 +49,17 @@ struct posix_mq {
|
|
46
49
|
};
|
47
50
|
|
48
51
|
#ifdef MQD_TO_FD
|
52
|
+
static ID id_setautoclose;
|
49
53
|
# define MQ_IO_MARK(mq) rb_gc_mark((mq)->io)
|
50
54
|
# define MQ_IO_SET(mq,val) do { (mq)->io = (val); } while (0)
|
51
55
|
# define MQ_IO_NIL_P(mq) NIL_P((mq)->io)
|
56
|
+
|
57
|
+
static void MQ_IO_SET_AUTOCLOSE(struct posix_mq *mq, VALUE boolean)
|
58
|
+
{
|
59
|
+
if (!NIL_P(mq->io))
|
60
|
+
rb_funcall(mq->io, id_setautoclose, 1, boolean);
|
61
|
+
}
|
62
|
+
|
52
63
|
static int MQ_IO_CLOSE(struct posix_mq *mq)
|
53
64
|
{
|
54
65
|
if (NIL_P(mq->io))
|
@@ -139,13 +150,13 @@ struct open_args {
|
|
139
150
|
/* used to pass arguments to mq_send/mq_receive inside blocking region */
|
140
151
|
struct rw_args {
|
141
152
|
mqd_t des;
|
153
|
+
unsigned msg_prio;
|
142
154
|
union {
|
143
155
|
ssize_t received;
|
144
156
|
int retval;
|
145
157
|
};
|
146
158
|
char *msg_ptr;
|
147
159
|
size_t msg_len;
|
148
|
-
unsigned msg_prio;
|
149
160
|
struct timespec *timeout;
|
150
161
|
};
|
151
162
|
|
@@ -299,7 +310,8 @@ static void _free(void *ptr)
|
|
299
310
|
|
300
311
|
if (mq->des != MQD_INVALID && MQ_IO_NIL_P(mq)) {
|
301
312
|
/* we ignore errors when gc-ing */
|
302
|
-
|
313
|
+
if (mq->autoclose)
|
314
|
+
mq_close(mq->des);
|
303
315
|
errno = 0;
|
304
316
|
}
|
305
317
|
xfree(ptr);
|
@@ -312,6 +324,7 @@ static VALUE alloc(VALUE klass)
|
|
312
324
|
VALUE rv = Data_Make_Struct(klass, struct posix_mq, mark, _free, mq);
|
313
325
|
|
314
326
|
mq->des = MQD_INVALID;
|
327
|
+
mq->autoclose = 1;
|
315
328
|
mq->attr.mq_flags = 0;
|
316
329
|
mq->attr.mq_maxmsg = 0;
|
317
330
|
mq->attr.mq_msgsize = -1;
|
@@ -365,6 +378,37 @@ static void rstruct2mqattr(struct mq_attr *attr, VALUE astruct, int all)
|
|
365
378
|
attr->mq_curmsgs = NUM2LONG(tmp);
|
366
379
|
}
|
367
380
|
|
381
|
+
#ifdef FD_TO_MQD
|
382
|
+
/*
|
383
|
+
* call-seq:
|
384
|
+
* POSIX_MQ.for_fd(socket) => mq
|
385
|
+
*
|
386
|
+
* Adopts a socket as a POSIX message queue. Argument will be
|
387
|
+
* checked to ensure it is a POSIX message queue socket.
|
388
|
+
*
|
389
|
+
* This is useful for adopting systemd sockets passed via the
|
390
|
+
* ListenMessageQueue directive.
|
391
|
+
* Returns a +POSIX_MQ+ instance. This method is only available
|
392
|
+
* under Linux and FreeBSD and is not intended to be portable.
|
393
|
+
*
|
394
|
+
*/
|
395
|
+
static VALUE for_fd(VALUE klass, VALUE socket)
|
396
|
+
{
|
397
|
+
VALUE mqv = alloc(klass);
|
398
|
+
struct posix_mq *mq = get(mqv, 0);
|
399
|
+
mqd_t mqd;
|
400
|
+
|
401
|
+
mq->name = Qnil;
|
402
|
+
mqd = FD_TO_MQD(NUM2INT(socket));
|
403
|
+
|
404
|
+
if (mq_getattr(mqd, &mq->attr) < 0)
|
405
|
+
rb_sys_fail("provided file descriptor is not a POSIX MQ");
|
406
|
+
|
407
|
+
mq->des = mqd;
|
408
|
+
return mqv;
|
409
|
+
}
|
410
|
+
#endif /* FD_TO_MQD */
|
411
|
+
|
368
412
|
/*
|
369
413
|
* call-seq:
|
370
414
|
* POSIX_MQ.new(name [, flags [, mode [, mq_attr]]) => mq
|
@@ -486,7 +530,7 @@ static VALUE s_unlink(VALUE self, VALUE name)
|
|
486
530
|
{
|
487
531
|
int rv = mq_unlink(StringValueCStr(name));
|
488
532
|
|
489
|
-
if (rv
|
533
|
+
if (rv < 0)
|
490
534
|
rb_sys_fail("mq_unlink");
|
491
535
|
|
492
536
|
return INT2NUM(1);
|
@@ -507,10 +551,14 @@ static VALUE _unlink(VALUE self)
|
|
507
551
|
struct posix_mq *mq = get(self, 0);
|
508
552
|
int rv;
|
509
553
|
|
554
|
+
if (NIL_P(mq->name)) {
|
555
|
+
rb_raise(rb_eArgError, "can not unlink an adopted socket");
|
556
|
+
}
|
557
|
+
|
510
558
|
assert(TYPE(mq->name) == T_STRING && "mq->name is not a string");
|
511
559
|
|
512
560
|
rv = mq_unlink(RSTRING_PTR(mq->name));
|
513
|
-
if (rv
|
561
|
+
if (rv < 0)
|
514
562
|
rb_sys_fail("mq_unlink");
|
515
563
|
|
516
564
|
return self;
|
@@ -559,7 +607,7 @@ static VALUE _send(int sflags, int argc, VALUE *argv, VALUE self)
|
|
559
607
|
|
560
608
|
retry:
|
561
609
|
WITHOUT_GVL(xsend, &x, RUBY_UBF_IO, 0);
|
562
|
-
if (x.retval
|
610
|
+
if (x.retval < 0) {
|
563
611
|
if (errno == EINTR)
|
564
612
|
goto retry;
|
565
613
|
if (errno == EAGAIN && (sflags & PMQ_TRY))
|
@@ -593,7 +641,7 @@ static VALUE send0(VALUE self, VALUE buffer)
|
|
593
641
|
|
594
642
|
retry:
|
595
643
|
WITHOUT_GVL(xsend, &x, RUBY_UBF_IO, 0);
|
596
|
-
if (x.retval
|
644
|
+
if (x.retval < 0) {
|
597
645
|
if (errno == EINTR)
|
598
646
|
goto retry;
|
599
647
|
rb_sys_fail("mq_send");
|
@@ -615,9 +663,13 @@ static VALUE to_io(VALUE self)
|
|
615
663
|
struct posix_mq *mq = get(self, 1);
|
616
664
|
int fd = MQD_TO_FD(mq->des);
|
617
665
|
|
618
|
-
if (NIL_P(mq->io))
|
666
|
+
if (NIL_P(mq->io)) {
|
619
667
|
mq->io = rb_funcall(rb_cIO, id_new, 1, INT2NUM(fd));
|
620
668
|
|
669
|
+
if (!mq->autoclose)
|
670
|
+
rb_funcall(mq->io, id_setautoclose, 1, Qfalse);
|
671
|
+
}
|
672
|
+
|
621
673
|
return mq->io;
|
622
674
|
}
|
623
675
|
#endif
|
@@ -775,7 +827,7 @@ static VALUE _close(VALUE self)
|
|
775
827
|
struct posix_mq *mq = get(self, 1);
|
776
828
|
|
777
829
|
if (! MQ_IO_CLOSE(mq)) {
|
778
|
-
if (mq_close(mq->des)
|
830
|
+
if (mq_close(mq->des) < 0)
|
779
831
|
rb_sys_fail("mq_close");
|
780
832
|
}
|
781
833
|
mq->des = MQD_INVALID;
|
@@ -807,6 +859,15 @@ static VALUE name(VALUE self)
|
|
807
859
|
{
|
808
860
|
struct posix_mq *mq = get(self, 0);
|
809
861
|
|
862
|
+
if (NIL_P(mq->name)) {
|
863
|
+
/*
|
864
|
+
* We could use readlink(2) on /proc/self/fd/N, but lots of
|
865
|
+
* care required.
|
866
|
+
* http://stackoverflow.com/questions/1188757/
|
867
|
+
*/
|
868
|
+
rb_raise(rb_eArgError, "can not get name of an adopted socket");
|
869
|
+
}
|
870
|
+
|
810
871
|
return rb_str_dup(mq->name);
|
811
872
|
}
|
812
873
|
|
@@ -853,12 +914,12 @@ static void my_mq_notify(mqd_t des, struct sigevent *not)
|
|
853
914
|
{
|
854
915
|
int rv = mq_notify(des, not);
|
855
916
|
|
856
|
-
if (rv
|
917
|
+
if (rv < 0) {
|
857
918
|
if (errno == ENOMEM) {
|
858
919
|
rb_gc();
|
859
920
|
rv = mq_notify(des, not);
|
860
921
|
}
|
861
|
-
if (rv
|
922
|
+
if (rv < 0)
|
862
923
|
rb_sys_fail("mq_notify");
|
863
924
|
}
|
864
925
|
}
|
@@ -1019,6 +1080,36 @@ static VALUE setnonblock(VALUE self, VALUE nb)
|
|
1019
1080
|
return nb;
|
1020
1081
|
}
|
1021
1082
|
|
1083
|
+
/*
|
1084
|
+
* call-seq:
|
1085
|
+
* mq.autoclose = boolean => boolean
|
1086
|
+
*
|
1087
|
+
* Determines whether or not the _mq_ will be closed automatically
|
1088
|
+
* at finalization.
|
1089
|
+
*/
|
1090
|
+
static VALUE setautoclose(VALUE self, VALUE autoclose)
|
1091
|
+
{
|
1092
|
+
struct posix_mq *mq = get(self, 1);
|
1093
|
+
|
1094
|
+
MQ_IO_SET_AUTOCLOSE(mq, autoclose);
|
1095
|
+
mq->autoclose = RTEST(autoclose) ? 1 : 0;
|
1096
|
+
return autoclose;
|
1097
|
+
}
|
1098
|
+
|
1099
|
+
/*
|
1100
|
+
* call-seq:
|
1101
|
+
* mq.autoclose? => boolean
|
1102
|
+
*
|
1103
|
+
* Returns whether or not the _mq_ will be closed automatically
|
1104
|
+
* at finalization.
|
1105
|
+
*/
|
1106
|
+
static VALUE autoclose_p(VALUE self)
|
1107
|
+
{
|
1108
|
+
struct posix_mq *mq = get(self, 1);
|
1109
|
+
|
1110
|
+
return mq->autoclose ? Qtrue : Qfalse;
|
1111
|
+
}
|
1112
|
+
|
1022
1113
|
/*
|
1023
1114
|
* call-seq:
|
1024
1115
|
* mq.trysend(string [,priority[, timeout]]) => +true+ or +false+
|
@@ -1110,10 +1201,17 @@ void Init_posix_mq_ext(void)
|
|
1110
1201
|
rb_define_private_method(cPOSIX_MQ, "notify_exec", setnotify_exec, 2);
|
1111
1202
|
rb_define_private_method(cPOSIX_MQ, "notify_cleanup", notify_cleanup, 0);
|
1112
1203
|
rb_define_method(cPOSIX_MQ, "nonblock?", nonblock_p, 0);
|
1204
|
+
rb_define_method(cPOSIX_MQ, "autoclose?", autoclose_p, 0);
|
1205
|
+
rb_define_method(cPOSIX_MQ, "autoclose=", setautoclose, 1);
|
1113
1206
|
#ifdef MQD_TO_FD
|
1114
1207
|
rb_define_method(cPOSIX_MQ, "to_io", to_io, 0);
|
1115
1208
|
#endif
|
1116
1209
|
|
1210
|
+
#ifdef FD_TO_MQD
|
1211
|
+
rb_define_module_function(cPOSIX_MQ, "for_fd", for_fd, 1);
|
1212
|
+
id_setautoclose = rb_intern("autoclose=");
|
1213
|
+
#endif
|
1214
|
+
|
1117
1215
|
id_new = rb_intern("new");
|
1118
1216
|
id_kill = rb_intern("kill");
|
1119
1217
|
id_fileno = rb_intern("fileno");
|
data/lib/posix_mq.rb
CHANGED
@@ -41,7 +41,7 @@ class POSIX_MQ
|
|
41
41
|
# SIGEV_THREAD functionality in mq_notify(3). So far we only
|
42
42
|
# know of glibc + Linux supporting this. Please let us
|
43
43
|
# know if your platform can support this functionality and
|
44
|
-
# are willing to test for us <ruby
|
44
|
+
# are willing to test for us <ruby-posix-mq@bogomips.org>
|
45
45
|
#
|
46
46
|
# As far as we can tell, this method is not very useful
|
47
47
|
# nor efficient. You would be better served using signals or
|
data/pkg.mk
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
RUBY = ruby
|
2
2
|
RAKE = rake
|
3
3
|
RSYNC = rsync
|
4
|
-
|
4
|
+
OLDDOC = olddoc
|
5
|
+
RDOC = rdoc
|
5
6
|
|
6
7
|
GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
|
7
8
|
@./GIT-VERSION-GEN
|
@@ -12,14 +13,6 @@ RUBY_VERSION := $(shell $(RUBY) -e 'puts RUBY_VERSION')
|
|
12
13
|
RUBY_ENGINE := $(shell $(RUBY) -e 'puts((RUBY_ENGINE rescue "ruby"))')
|
13
14
|
lib := lib
|
14
15
|
|
15
|
-
ifeq ($(shell test -f script/isolate_for_tests && echo t),t)
|
16
|
-
isolate_libs := tmp/isolate/$(RUBY_ENGINE)-$(RUBY_VERSION)/isolate.mk
|
17
|
-
$(isolate_libs): script/isolate_for_tests
|
18
|
-
@$(RUBY) script/isolate_for_tests
|
19
|
-
-include $(isolate_libs)
|
20
|
-
lib := $(lib):$(ISOLATE_LIBS)
|
21
|
-
endif
|
22
|
-
|
23
16
|
ext := $(firstword $(wildcard ext/*))
|
24
17
|
ifneq ($(ext),)
|
25
18
|
ext_pfx := tmp/ext/$(RUBY_ENGINE)-$(RUBY_VERSION)
|
@@ -36,7 +29,7 @@ $(ext_pfx)/$(ext)/%: $(ext)/% $(ext_d)
|
|
36
29
|
install -m 644 $< $@
|
37
30
|
$(ext_pfx)/$(ext)/Makefile: $(ext)/extconf.rb $(ext_d) $(ext_h)
|
38
31
|
$(RM) -f $(@D)/*.o
|
39
|
-
cd $(@D) && $(RUBY) $(CURDIR)/$(ext)/extconf.rb
|
32
|
+
cd $(@D) && $(RUBY) $(CURDIR)/$(ext)/extconf.rb $(EXTCONF_ARGS)
|
40
33
|
ext_sfx := _ext.$(DLEXT)
|
41
34
|
ext_dl := $(ext_pfx)/$(ext)/$(notdir $(ext)_ext.$(DLEXT))
|
42
35
|
$(ext_dl): $(ext_src) $(ext_pfx_src) $(ext_pfx)/$(ext)/Makefile
|
@@ -48,10 +41,10 @@ else
|
|
48
41
|
build:
|
49
42
|
endif
|
50
43
|
|
51
|
-
pkg_extra += GIT-VERSION-FILE NEWS
|
52
|
-
|
53
|
-
$(
|
54
|
-
|
44
|
+
pkg_extra += GIT-VERSION-FILE NEWS LATEST
|
45
|
+
NEWS: GIT-VERSION-FILE .olddoc.yml
|
46
|
+
$(OLDDOC) prepare
|
47
|
+
LATEST: NEWS
|
55
48
|
|
56
49
|
manifest:
|
57
50
|
$(RM) .manifest
|
@@ -63,28 +56,20 @@ manifest:
|
|
63
56
|
cmp $@+ $@ || mv $@+ $@
|
64
57
|
$(RM) $@+
|
65
58
|
|
66
|
-
doc:: .document .
|
59
|
+
doc:: .document .olddoc.yml $(pkg_extra) $(PLACEHOLDERS)
|
67
60
|
-find lib -type f -name '*.rbc' -exec rm -f '{}' ';'
|
68
61
|
-find ext -type f -name '*.rbc' -exec rm -f '{}' ';'
|
69
62
|
$(RM) -r doc
|
70
|
-
$(
|
63
|
+
$(RDOC) -f oldweb
|
64
|
+
$(OLDDOC) merge
|
71
65
|
install -m644 COPYING doc/COPYING
|
66
|
+
install -m644 NEWS doc/NEWS
|
67
|
+
install -m644 NEWS.atom.xml doc/NEWS.atom.xml
|
72
68
|
install -m644 $(shell LC_ALL=C grep '^[A-Z]' .document) doc/
|
73
69
|
|
74
70
|
ifneq ($(VERSION),)
|
75
71
|
pkggem := pkg/$(rfpackage)-$(VERSION).gem
|
76
72
|
pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
|
77
|
-
release_notes := release_notes-$(VERSION)
|
78
|
-
release_changes := release_changes-$(VERSION)
|
79
|
-
|
80
|
-
release-notes: $(release_notes)
|
81
|
-
release-changes: $(release_changes)
|
82
|
-
$(release_changes):
|
83
|
-
$(WRONGDOC) release_changes > $@+
|
84
|
-
$(VISUAL) $@+ && test -s $@+ && mv $@+ $@
|
85
|
-
$(release_notes):
|
86
|
-
$(WRONGDOC) release_notes > $@+
|
87
|
-
$(VISUAL) $@+ && test -s $@+ && mv $@+ $@
|
88
73
|
|
89
74
|
# ensures we're actually on the tagged $(VERSION), only used for release
|
90
75
|
verify:
|
@@ -120,31 +105,18 @@ $(pkgtgz): manifest fix-perms
|
|
120
105
|
|
121
106
|
package: $(pkgtgz) $(pkggem)
|
122
107
|
|
123
|
-
|
124
|
-
# make tgz release on RubyForge
|
125
|
-
@echo rubyforge add_release -f \
|
126
|
-
-n $(release_notes) -a $(release_changes) \
|
127
|
-
$(rfproject) $(rfpackage) $(VERSION) $(pkgtgz)
|
128
|
-
@echo gem push $(pkggem)
|
129
|
-
@echo rubyforge add_file \
|
130
|
-
$(rfproject) $(rfpackage) $(VERSION) $(pkggem)
|
131
|
-
release:: verify package $(release_notes) $(release_changes)
|
132
|
-
# make tgz release on RubyForge
|
133
|
-
rubyforge add_release -f -n $(release_notes) -a $(release_changes) \
|
134
|
-
$(rfproject) $(rfpackage) $(VERSION) $(pkgtgz)
|
108
|
+
release:: verify package
|
135
109
|
# push gem to RubyGems.org
|
136
110
|
gem push $(pkggem)
|
137
|
-
# in case of gem downloads from RubyForge releases page
|
138
|
-
rubyforge add_file \
|
139
|
-
$(rfproject) $(rfpackage) $(VERSION) $(pkggem)
|
140
111
|
else
|
141
112
|
gem install-gem: GIT-VERSION-FILE
|
142
113
|
$(MAKE) $@ VERSION=$(GIT_VERSION)
|
143
114
|
endif
|
144
115
|
|
145
|
-
all::
|
116
|
+
all:: check
|
146
117
|
test_units := $(wildcard test/test_*.rb)
|
147
|
-
test:
|
118
|
+
test: check
|
119
|
+
check: test-unit
|
148
120
|
test-unit: $(test_units)
|
149
121
|
$(test_units): build
|
150
122
|
$(RUBY) -I $(lib) $@ $(RUBY_TEST_OPTS)
|
@@ -154,8 +126,6 @@ ifneq ($(RSYNC_DEST),)
|
|
154
126
|
publish_doc:
|
155
127
|
-git set-file-times
|
156
128
|
$(MAKE) doc
|
157
|
-
find doc/images -type f | \
|
158
|
-
TZ=UTC xargs touch -d '1970-01-01 00:00:06' doc/rdoc.css
|
159
129
|
$(MAKE) doc_gz
|
160
130
|
$(RSYNC) -av doc/ $(RSYNC_DEST)/
|
161
131
|
git ls-files | xargs touch
|
@@ -163,7 +133,7 @@ endif
|
|
163
133
|
|
164
134
|
# Create gzip variants of the same timestamp as the original so nginx
|
165
135
|
# "gzip_static on" can serve the gzipped versions directly.
|
166
|
-
doc_gz: docs = $(shell find doc -type f ! -regex '
|
136
|
+
doc_gz: docs = $(shell find doc -type f ! -regex '^.*\.gz$$')
|
167
137
|
doc_gz:
|
168
138
|
for i in $(docs); do \
|
169
139
|
gzip --rsyncable -9 < $$i > $$i.gz; touch -r $$i $$i.gz; done
|
@@ -171,5 +141,10 @@ check-warnings:
|
|
171
141
|
@(for i in $$(git ls-files '*.rb'| grep -v '^setup\.rb$$'); \
|
172
142
|
do $(RUBY) -d -W2 -c $$i; done) | grep -v '^Syntax OK$$' || :
|
173
143
|
|
174
|
-
|
144
|
+
ifneq ($(PLACEHOLDERS),)
|
145
|
+
$(PLACEHOLDERS):
|
146
|
+
echo olddoc_placeholder > $@
|
147
|
+
endif
|
148
|
+
|
149
|
+
.PHONY: all .FORCE-GIT-VERSION-FILE doc check test $(test_units) manifest
|
175
150
|
.PHONY: check-warnings
|
data/posix_mq.gemspec
CHANGED
@@ -1,27 +1,23 @@
|
|
1
1
|
# -*- encoding: binary -*-
|
2
2
|
ENV["VERSION"] or abort "VERSION= must be specified"
|
3
3
|
manifest = File.readlines('.manifest').map! { |x| x.chomp! }
|
4
|
-
require '
|
5
|
-
extend
|
4
|
+
require 'olddoc'
|
5
|
+
extend Olddoc::Gemspec
|
6
6
|
name, summary, title = readme_metadata
|
7
7
|
|
8
8
|
Gem::Specification.new do |s|
|
9
9
|
s.name = %q{posix_mq}
|
10
10
|
s.version = ENV["VERSION"].dup
|
11
11
|
s.authors = ["Ruby POSIX MQ hackers"]
|
12
|
-
s.date = Time.now.utc.strftime('%Y-%m-%d')
|
13
12
|
s.description = readme_description
|
14
|
-
s.email = %q{ruby
|
13
|
+
s.email = %q{ruby-posix-mq@bogomips.org}
|
15
14
|
s.executables = %w(posix-mq-rb)
|
16
15
|
s.extensions = %w(ext/posix_mq/extconf.rb)
|
17
16
|
s.extra_rdoc_files = extra_rdoc_files(manifest)
|
18
17
|
s.files = manifest
|
19
|
-
s.homepage =
|
18
|
+
s.homepage = Olddoc.config['rdoc_url']
|
20
19
|
s.summary = summary
|
21
|
-
s.rdoc_options = rdoc_options
|
22
|
-
s.rubyforge_project = %q{qrp}
|
23
20
|
s.test_files = manifest.grep(%r{\Atest/test_.*\.rb\z})
|
24
|
-
s.add_development_dependency(%q<
|
25
|
-
|
26
|
-
# s.licenses = %w(LGPLv3) # accessor not compatible with older RubyGems
|
21
|
+
s.add_development_dependency(%q<olddoc>, "~> 1.0")
|
22
|
+
s.licenses = %w(GPL-2.0 LGPL-3.0+)
|
27
23
|
end
|
data/test/test_posix_mq.rb
CHANGED
@@ -3,11 +3,6 @@ require 'test/unit'
|
|
3
3
|
require 'thread'
|
4
4
|
require 'fcntl'
|
5
5
|
$stderr.sync = $stdout.sync = true
|
6
|
-
require "dl"
|
7
|
-
begin
|
8
|
-
require "dl/func"
|
9
|
-
rescue LoadError
|
10
|
-
end
|
11
6
|
$-w = true
|
12
7
|
require 'posix_mq'
|
13
8
|
|
@@ -17,6 +12,8 @@ class Test_POSIX_MQ < Test::Unit::TestCase
|
|
17
12
|
warn "POSIX_MQ#to_io not supported on this platform: #{RUBY_PLATFORM}"
|
18
13
|
POSIX_MQ.method_defined?(:notify) or
|
19
14
|
warn "POSIX_MQ#notify not supported on this platform: #{RUBY_PLATFORM}"
|
15
|
+
POSIX_MQ.respond_to?(:for_fd) or
|
16
|
+
warn "POSIX_MQ::for_fd not supported on this platform: #{RUBY_PLATFORM}"
|
20
17
|
|
21
18
|
def setup
|
22
19
|
@mq = nil
|
@@ -102,23 +99,15 @@ class Test_POSIX_MQ < Test::Unit::TestCase
|
|
102
99
|
assert elapsed < 1.10, elapsed.inspect
|
103
100
|
end
|
104
101
|
|
105
|
-
def
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
if defined?(DL::Function)
|
111
|
-
alarm = libc["alarm"]
|
112
|
-
alarm = DL::CFunc.new(alarm, DL::TYPE_INT, "alarm")
|
113
|
-
alarm = DL::Function.new(alarm, [DL::TYPE_INT])
|
114
|
-
else
|
115
|
-
alarm = libc["alarm", "II"]
|
102
|
+
def test_signal_safe
|
103
|
+
alarm = lambda do |x|
|
104
|
+
Thread.new(x) do |time|
|
105
|
+
sleep(time)
|
106
|
+
Process.kill(:USR1, $$)
|
116
107
|
end
|
117
|
-
break
|
118
108
|
end
|
119
|
-
alarm or return warn "alarm() not found in #{libcs.inspect}"
|
120
109
|
alarms = 0
|
121
|
-
trap(
|
110
|
+
sig = trap(:USR1) do
|
122
111
|
alarms += 1
|
123
112
|
Thread.new { @mq.send("HI") }
|
124
113
|
end
|
@@ -133,6 +122,8 @@ class Test_POSIX_MQ < Test::Unit::TestCase
|
|
133
122
|
assert elapsed >= interval, elapsed.inspect
|
134
123
|
assert elapsed < 1.10, elapsed.inspect
|
135
124
|
assert_equal 1, alarms
|
125
|
+
ensure
|
126
|
+
trap(:USR1, sig) if sig
|
136
127
|
end
|
137
128
|
|
138
129
|
def test_timed_send
|
@@ -244,6 +235,37 @@ class Test_POSIX_MQ < Test::Unit::TestCase
|
|
244
235
|
assert_nothing_raised { IO.select([@mq], nil, nil, 0) }
|
245
236
|
end if POSIX_MQ.method_defined?(:to_io)
|
246
237
|
|
238
|
+
def test_for_fd
|
239
|
+
buf = ""
|
240
|
+
@mq = POSIX_MQ.new @path, IO::CREAT|IO::RDWR, 0666
|
241
|
+
@alt = POSIX_MQ.for_fd(@mq.to_io.to_i)
|
242
|
+
assert_equal true, @mq.send("hello", 0)
|
243
|
+
assert_equal [ "hello", 0 ], @alt.receive(buf)
|
244
|
+
assert_equal "hello", buf
|
245
|
+
assert_equal @mq.to_io.to_i, @alt.to_io.to_i
|
246
|
+
assert_raises(ArgumentError) { @alt.name }
|
247
|
+
assert_raises(Errno::EBADF) { POSIX_MQ.for_fd(1) }
|
248
|
+
@alt.autoclose = false
|
249
|
+
assert_equal false, @alt.autoclose?
|
250
|
+
|
251
|
+
# iterate a bunch and hope GC kicks in
|
252
|
+
fd = @mq.to_io.fileno
|
253
|
+
10_000.times do
|
254
|
+
mq = POSIX_MQ.for_fd(fd)
|
255
|
+
assert_equal true, mq.autoclose?
|
256
|
+
mq.autoclose = false
|
257
|
+
assert_equal false, mq.autoclose?
|
258
|
+
end
|
259
|
+
end if POSIX_MQ.respond_to?(:for_fd) && POSIX_MQ.method_defined?(:to_io)
|
260
|
+
|
261
|
+
def test_autoclose_propagates_to_io
|
262
|
+
@mq = POSIX_MQ.new @path, IO::CREAT|IO::RDWR, 0666
|
263
|
+
@mq.autoclose = false
|
264
|
+
assert_equal false, @mq.to_io.autoclose?
|
265
|
+
@mq.autoclose = true
|
266
|
+
assert_equal true, @mq.to_io.autoclose?
|
267
|
+
end if POSIX_MQ.method_defined?(:to_io)
|
268
|
+
|
247
269
|
def test_notify
|
248
270
|
rd, wr = IO.pipe
|
249
271
|
orig = trap(:USR1) { wr.syswrite('.') }
|
metadata
CHANGED
@@ -1,69 +1,52 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
name:
|
3
|
-
cG9zaXhfbXE=
|
2
|
+
name: posix_mq
|
4
3
|
version: !ruby/object:Gem::Version
|
5
|
-
version: 2.
|
6
|
-
prerelease:
|
4
|
+
version: 2.2.0
|
7
5
|
platform: ruby
|
8
6
|
authors:
|
9
|
-
-
|
10
|
-
UnVieSBQT1NJWCBNUSBoYWNrZXJz
|
7
|
+
- Ruby POSIX MQ hackers
|
11
8
|
autorequire:
|
12
9
|
bindir: bin
|
13
10
|
cert_chain: []
|
14
|
-
date:
|
11
|
+
date: 2015-01-16 00:00:00.000000000 Z
|
15
12
|
dependencies:
|
16
13
|
- !ruby/object:Gem::Dependency
|
17
|
-
name:
|
18
|
-
d3Jvbmdkb2M=
|
14
|
+
name: olddoc
|
19
15
|
requirement: !ruby/object:Gem::Requirement
|
20
|
-
none: false
|
21
16
|
requirements:
|
22
|
-
- -
|
23
|
-
fj4=
|
17
|
+
- - "~>"
|
24
18
|
- !ruby/object:Gem::Version
|
25
|
-
version:
|
26
|
-
MS41
|
19
|
+
version: '1.0'
|
27
20
|
type: :development
|
28
21
|
prerelease: false
|
29
22
|
version_requirements: !ruby/object:Gem::Requirement
|
30
|
-
none: false
|
31
23
|
requirements:
|
32
|
-
- -
|
33
|
-
fj4=
|
24
|
+
- - "~>"
|
34
25
|
- !ruby/object:Gem::Version
|
35
|
-
version:
|
36
|
-
|
37
|
-
|
38
|
-
form
|
39
|
-
|
26
|
+
version: '1.0'
|
27
|
+
description: |-
|
28
|
+
POSIX message queues allow local processes to exchange data in the form
|
40
29
|
of messages. This API is distinct from that provided by System V
|
41
|
-
|
42
|
-
|
43
|
-
email: !binary |-
|
44
|
-
cnVieS5wb3NpeC5tcUBsaWJyZWxpc3QuY29t
|
30
|
+
message queues, but provides similar functionality.
|
31
|
+
email: ruby-posix-mq@bogomips.org
|
45
32
|
executables:
|
46
|
-
-
|
47
|
-
cG9zaXgtbXEtcmI=
|
33
|
+
- posix-mq-rb
|
48
34
|
extensions:
|
49
|
-
-
|
50
|
-
ZXh0L3Bvc2l4X21xL2V4dGNvbmYucmI=
|
35
|
+
- ext/posix_mq/extconf.rb
|
51
36
|
extra_rdoc_files:
|
52
37
|
- README
|
53
38
|
- LICENSE
|
54
39
|
- NEWS
|
55
|
-
- ChangeLog
|
56
40
|
- lib/posix_mq.rb
|
57
41
|
- ext/posix_mq/posix_mq.c
|
58
|
-
-
|
42
|
+
- posix-mq-rb_1
|
59
43
|
files:
|
60
|
-
- .document
|
61
|
-
- .gitignore
|
62
|
-
- .manifest
|
63
|
-
- .
|
44
|
+
- ".document"
|
45
|
+
- ".gitignore"
|
46
|
+
- ".manifest"
|
47
|
+
- ".olddoc.yml"
|
64
48
|
- COPYING
|
65
49
|
- COPYING-GPL2
|
66
|
-
- ChangeLog
|
67
50
|
- Documentation/.gitignore
|
68
51
|
- Documentation/GNUmakefile
|
69
52
|
- Documentation/posix-mq-rb.1.txt
|
@@ -74,44 +57,42 @@ files:
|
|
74
57
|
- LICENSE
|
75
58
|
- NEWS
|
76
59
|
- README
|
77
|
-
-
|
60
|
+
- archive/.gitignore
|
61
|
+
- archive/slrnpull.conf
|
78
62
|
- bin/posix-mq-rb
|
79
63
|
- ext/posix_mq/extconf.rb
|
80
64
|
- ext/posix_mq/posix_mq.c
|
81
65
|
- lib/posix_mq.rb
|
82
66
|
- man/man1/posix-mq-rb.1
|
83
67
|
- pkg.mk
|
68
|
+
- posix-mq-rb_1
|
84
69
|
- posix_mq.gemspec
|
85
70
|
- setup.rb
|
86
71
|
- test/test_posix_mq.rb
|
87
72
|
homepage: http://bogomips.org/ruby_posix_mq/
|
88
|
-
licenses:
|
73
|
+
licenses:
|
74
|
+
- GPL-2.0
|
75
|
+
- LGPL-3.0+
|
76
|
+
metadata: {}
|
89
77
|
post_install_message:
|
90
|
-
rdoc_options:
|
91
|
-
- -t
|
92
|
-
- posix_mq - POSIX Message Queues for Ruby
|
93
|
-
- -W
|
94
|
-
- http://bogomips.org/ruby_posix_mq.git/tree/%s
|
78
|
+
rdoc_options: []
|
95
79
|
require_paths:
|
96
80
|
- lib
|
97
81
|
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
-
none: false
|
99
82
|
requirements:
|
100
|
-
- -
|
83
|
+
- - ">="
|
101
84
|
- !ruby/object:Gem::Version
|
102
85
|
version: '0'
|
103
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
-
none: false
|
105
87
|
requirements:
|
106
|
-
- -
|
88
|
+
- - ">="
|
107
89
|
- !ruby/object:Gem::Version
|
108
90
|
version: '0'
|
109
91
|
requirements: []
|
110
|
-
rubyforge_project:
|
111
|
-
|
112
|
-
rubygems_version: 1.8.23
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.4.5
|
113
94
|
signing_key:
|
114
|
-
specification_version:
|
95
|
+
specification_version: 4
|
115
96
|
summary: POSIX Message Queues for Ruby
|
116
97
|
test_files:
|
117
98
|
- test/test_posix_mq.rb
|
data/Rakefile
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# -*- encoding: binary -*-
|
2
|
-
require 'wrongdoc'
|
3
|
-
cgit_url = Wrongdoc.config[:cgit_url]
|
4
|
-
git_url = Wrongdoc.config[:git_url]
|
5
|
-
|
6
|
-
desc "post news article to rubyforge"
|
7
|
-
task :publish_news do
|
8
|
-
require 'rubyforge'
|
9
|
-
spec = Gem::Specification.load('posix_mq.gemspec')
|
10
|
-
tmp = Tempfile.new('rf-news')
|
11
|
-
_, subject, body = `git cat-file tag v#{spec.version}`.split(/\n\n/, 3)
|
12
|
-
tmp.puts subject
|
13
|
-
tmp.puts
|
14
|
-
tmp.puts spec.description.strip
|
15
|
-
tmp.puts ""
|
16
|
-
tmp.puts "* #{spec.homepage}"
|
17
|
-
tmp.puts "* #{spec.email}"
|
18
|
-
tmp.puts "* #{git_url}"
|
19
|
-
tmp.print "\nChanges:\n\n"
|
20
|
-
tmp.puts body
|
21
|
-
tmp.flush
|
22
|
-
system(ENV["VISUAL"], tmp.path) or abort "#{ENV["VISUAL"]} failed: #$?"
|
23
|
-
msg = File.readlines(tmp.path)
|
24
|
-
subject = msg.shift
|
25
|
-
blank = msg.shift
|
26
|
-
blank == "\n" or abort "no newline after subject!"
|
27
|
-
subject.strip!
|
28
|
-
body = msg.join("").strip!
|
29
|
-
|
30
|
-
rf = RubyForge.new.configure
|
31
|
-
rf.login
|
32
|
-
rf.post_news('qrp', subject, body)
|
33
|
-
end
|