raindrops 0.16.0 → 0.20.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 +5 -5
- data/.document +1 -1
- data/.manifest +3 -2
- data/.olddoc.yml +14 -7
- data/GIT-VERSION-FILE +1 -1
- data/GIT-VERSION-GEN +1 -1
- data/GNUmakefile +1 -1
- data/LATEST +6 -24
- data/LICENSE +3 -3
- data/NEWS +109 -0
- data/README +20 -21
- data/TODO +1 -0
- data/examples/linux-listener-stats.rb +1 -2
- data/examples/watcher_demo.ru +1 -1
- data/examples/yahns.conf.rb +30 -0
- data/examples/zbatery.conf.rb +4 -1
- data/ext/raindrops/extconf.rb +106 -2
- data/ext/raindrops/linux_inet_diag.c +60 -85
- data/ext/raindrops/raindrops.c +75 -21
- data/ext/raindrops/tcp_info.c +245 -0
- data/lib/raindrops/aggregate/pmq.rb +23 -17
- data/lib/raindrops/aggregate.rb +1 -1
- data/lib/raindrops/linux.rb +4 -5
- data/lib/raindrops/middleware/proxy.rb +2 -2
- data/lib/raindrops/middleware.rb +2 -2
- data/lib/raindrops/watcher.rb +13 -13
- data/lib/raindrops.rb +25 -1
- data/pkg.mk +3 -2
- data/raindrops.gemspec +12 -16
- data/test/ipv6_enabled.rb +4 -4
- data/test/test_aggregate_pmq.rb +1 -1
- data/test/test_inet_diag_socket.rb +1 -1
- data/test/test_last_data_recv_unicorn.rb +1 -1
- data/test/test_linux.rb +3 -2
- data/test/test_linux_all_tcp_listen_stats_leak.rb +2 -2
- data/test/test_raindrops.rb +43 -1
- data/test/{test_linux_tcp_info.rb → test_tcp_info.rb} +34 -14
- data/test/test_watcher.rb +15 -10
- metadata +18 -56
- data/ext/raindrops/linux_tcp_info.c +0 -173
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6f78e29ec57e3f3710146a423cf60915d23a5f4366d70dcabbbef74fb69f71f3
|
4
|
+
data.tar.gz: 8a369d49c33a67af3b6acccaf64b04ed192cba9d163c8d48944cfac887511885
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9e5de8e7a7a84038bbe19a954d3d559ebec3ed4c7f68db2e2ada6373b045f4fbcd784c5d5b91005cad1d87f1db93f9dc31c9f7fc59ae56a7f73b98d9a96bf2e
|
7
|
+
data.tar.gz: 9913e9205b2527b9f5bd1bae58b0c2c8962505e87280c06257f603fb722978d6656c99cfa0a297ccd0734a7d6110b0a6ecd5155fec9870ec40a31044a00def4d
|
data/.document
CHANGED
data/.manifest
CHANGED
@@ -18,13 +18,14 @@ examples/linux-listener-stats.rb
|
|
18
18
|
examples/middleware.ru
|
19
19
|
examples/watcher.ru
|
20
20
|
examples/watcher_demo.ru
|
21
|
+
examples/yahns.conf.rb
|
21
22
|
examples/zbatery.conf.rb
|
22
23
|
ext/raindrops/extconf.rb
|
23
24
|
ext/raindrops/linux_inet_diag.c
|
24
|
-
ext/raindrops/linux_tcp_info.c
|
25
25
|
ext/raindrops/my_fileno.h
|
26
26
|
ext/raindrops/raindrops.c
|
27
27
|
ext/raindrops/raindrops_atomic.h
|
28
|
+
ext/raindrops/tcp_info.c
|
28
29
|
lib/raindrops.rb
|
29
30
|
lib/raindrops/aggregate.rb
|
30
31
|
lib/raindrops/aggregate/last_data_recv.rb
|
@@ -48,11 +49,11 @@ test/test_linux_all_tcp_listen_stats.rb
|
|
48
49
|
test/test_linux_all_tcp_listen_stats_leak.rb
|
49
50
|
test/test_linux_ipv6.rb
|
50
51
|
test/test_linux_middleware.rb
|
51
|
-
test/test_linux_tcp_info.rb
|
52
52
|
test/test_middleware.rb
|
53
53
|
test/test_middleware_unicorn.rb
|
54
54
|
test/test_middleware_unicorn_ipv6.rb
|
55
55
|
test/test_raindrops.rb
|
56
56
|
test/test_raindrops_gc.rb
|
57
57
|
test/test_struct.rb
|
58
|
+
test/test_tcp_info.rb
|
58
59
|
test/test_watcher.rb
|
data/.olddoc.yml
CHANGED
@@ -1,9 +1,16 @@
|
|
1
1
|
---
|
2
|
-
cgit_url:
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
cgit_url: https://yhbt.net/raindrops.git/
|
3
|
+
rdoc_url: https://yhbt.net/raindrops/
|
4
|
+
public_email: raindrops-public@yhbt.net
|
5
|
+
ml_url:
|
6
|
+
- https://yhbt.net/raindrops-public/
|
7
|
+
- http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/raindrops-public
|
8
|
+
imap_url:
|
9
|
+
- imaps://yhbt.net/inbox.comp.lang.ruby.raindrops.0
|
10
|
+
- imap://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.lang.ruby.raindrops.0
|
8
11
|
nntp_url:
|
9
|
-
|
12
|
+
- nntps://news.public-inbox.org/inbox.comp.lang.ruby.raindrops
|
13
|
+
- nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.lang.ruby.raindrops
|
14
|
+
source_code:
|
15
|
+
- git clone https://yhbt.net/raindrops.git
|
16
|
+
- torsocks git clone http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/raindrops.git
|
data/GIT-VERSION-FILE
CHANGED
@@ -1 +1 @@
|
|
1
|
-
GIT_VERSION = 0.
|
1
|
+
GIT_VERSION = 0.20.0
|
data/GIT-VERSION-GEN
CHANGED
data/GNUmakefile
CHANGED
data/LATEST
CHANGED
@@ -1,28 +1,10 @@
|
|
1
|
-
=== raindrops 0.
|
1
|
+
=== raindrops 0.20.0 / 2021-12-06 23:41 UTC
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
using strange paths allowed by *nix.
|
3
|
+
Raindrops may now use file-backed mmap() rather than anonymous
|
4
|
+
memory. Thanks to KJ Tsanaktsidis for the patch:
|
6
5
|
|
7
|
-
|
6
|
+
https://yhbt.net/raindrops-public/20211125065618.3432-1-ktsanaktsidis@zendesk.com/T/
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
There are also minor optimizations for Ruby 2.2+ (at the expense
|
13
|
-
of 2.1 and earlier).
|
14
|
-
|
15
|
-
And the usual round of minor tweaks and doc updates.
|
16
|
-
|
17
|
-
10 changes since v0.15.0:
|
18
|
-
gemspec: avoid circular dependency on unicorn
|
19
|
-
remove optimizations which made sense for older rubies
|
20
|
-
linux: workaround Ruby 2.3 change
|
21
|
-
linux: remove Pathname stdlib dependency
|
22
|
-
add .gitattributes for Ruby method detection
|
23
|
-
middleware: minor bytecode size reduction
|
24
|
-
doc: update URLs and references
|
25
|
-
README: remove indentation from URLs in RDoc
|
26
|
-
linux: tcp_listener_stats drops "true" placeholders
|
27
|
-
build: use '--local' domain for dev gem install
|
8
|
+
The documentation is also updated to note our mail archives are now
|
9
|
+
available via IMAP(S).
|
28
10
|
|
data/LICENSE
CHANGED
@@ -3,8 +3,8 @@ revision control for names and email addresses of all of them.
|
|
3
3
|
|
4
4
|
You can redistribute it and/or modify it under the terms of the GNU
|
5
5
|
Lesser General Public License (LGPL) as published by the Free Software
|
6
|
-
Foundation, version {2.1}[
|
7
|
-
later. Currently version {3}[
|
6
|
+
Foundation, version {2.1}[https://www.gnu.org/licenses/lgpl-2.1.txt] or
|
7
|
+
later. Currently version {3}[https://www.gnu.org/licenses/lgpl-3.0.txt],
|
8
8
|
is preferred (see link:COPYING).
|
9
9
|
|
10
10
|
raindrops is distributed in the hope that it will be useful, but WITHOUT
|
@@ -13,4 +13,4 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
13
13
|
License for more details.
|
14
14
|
|
15
15
|
You should have received a copy of the GNU Lesser General Public License
|
16
|
-
along with the raindrops; if not, see <
|
16
|
+
along with the raindrops; if not, see <https://www.gnu.org/licenses/>
|
data/NEWS
CHANGED
@@ -1,3 +1,112 @@
|
|
1
|
+
=== raindrops 0.20.0 / 2021-12-06 23:41 UTC
|
2
|
+
|
3
|
+
Raindrops may now use file-backed mmap() rather than anonymous
|
4
|
+
memory. Thanks to KJ Tsanaktsidis for the patch:
|
5
|
+
|
6
|
+
https://yhbt.net/raindrops-public/20211125065618.3432-1-ktsanaktsidis@zendesk.com/T/
|
7
|
+
|
8
|
+
The documentation is also updated to note our mail archives are now
|
9
|
+
available via IMAP(S).
|
10
|
+
|
11
|
+
=== raindrops 0.19.2 / 2021-05-25 23:13 UTC
|
12
|
+
|
13
|
+
This release fixes compatibility with GC.compact on Ruby 3.x
|
14
|
+
when using ListenStats on Linux. The listener stats
|
15
|
+
functionality is rarely used and does not affect most users
|
16
|
+
who just have raindrops installed for shared atomic counters.
|
17
|
+
|
18
|
+
=== raindrops 0.19.1 / 2020-01-08 09:31 UTC
|
19
|
+
|
20
|
+
This release fixes some warnings on newer Rubies.
|
21
|
+
|
22
|
+
We're no longer on bogomips.org since it's due
|
23
|
+
for expiry and I can't pay extortionists for a .org, so
|
24
|
+
s/bogomips.org/yhbt.net/ for now, and be prepared to move again
|
25
|
+
when extortionists move onto extorting the .net TLD.
|
26
|
+
|
27
|
+
doc: switch homepage to dark216
|
28
|
+
ext/raindrops/extconf: fix cflags reset on ancient CC
|
29
|
+
fixes for newer rubies
|
30
|
+
replace bogomips.org with yhbt.net
|
31
|
+
|
32
|
+
=== raindrops 0.19.0 - Rack 2.x middleware compatibility / 2017-08-09 23:52 UTC
|
33
|
+
|
34
|
+
This release fixes Rack 2.x compatibility for the few users of
|
35
|
+
Raindrops::Middleware
|
36
|
+
<https://bogomips.org/raindrops/Raindrops/Middleware.html>.
|
37
|
+
Thanks to Dmytro Shteflyuk for this release.
|
38
|
+
|
39
|
+
No need to upgrade unless you use Raindrops::Middleware with
|
40
|
+
Rack 2.x.
|
41
|
+
|
42
|
+
There's also a few minor, inconsequential cleanups.
|
43
|
+
|
44
|
+
Dmytro Shteflyuk (1):
|
45
|
+
Properly override respond_to? in Raindrops::Middleware::Proxy
|
46
|
+
|
47
|
+
Eric Wong (2):
|
48
|
+
Ruby thread compatibility updates
|
49
|
+
tcp_info: remove unnecessary extconf.h include
|
50
|
+
|
51
|
+
=== raindrops 0.18.0 / 2017-03-23 02:44 UTC
|
52
|
+
|
53
|
+
The most notable feature of this release is the addition of
|
54
|
+
FreeBSD and OpenBSD TCP_INFO support. This includes the
|
55
|
+
Raindrops::TCP for portably mapping TCP state names to
|
56
|
+
platform-dependent numeric values:
|
57
|
+
|
58
|
+
https://bogomips.org/raindrops/Raindrops.html#TCP
|
59
|
+
|
60
|
+
Thanks to Jeremy Evans and Simon Eskildsen on the
|
61
|
+
unicorn-public@bogomips.org mailing list for inspiring
|
62
|
+
these changes to raindrops.
|
63
|
+
|
64
|
+
There's also a few internal cleanups, and documentation
|
65
|
+
improvements, including some fixes to the largely-forgotten
|
66
|
+
Raindrops::Aggreage::PMQ class:
|
67
|
+
|
68
|
+
https://bogomips.org/raindrops/Raindrops/Aggregate/PMQ.html
|
69
|
+
|
70
|
+
20 changes since 0.17.0:
|
71
|
+
|
72
|
+
test_inet_diag_socket: fix Fixnum deprecation warning
|
73
|
+
TODO: add item for IPv6 breakage
|
74
|
+
ext: fix documentation for C ext-defined classes
|
75
|
+
TCP_Info: custom documentation for #get!
|
76
|
+
TypedData C-API conversion
|
77
|
+
test_watcher: disable test correctly when aggregate is missing
|
78
|
+
tcp_info: support this struct under FreeBSD
|
79
|
+
define Raindrops::TCP hash for TCP states
|
80
|
+
linux_inet_diag: reduce stack usage and simplify
|
81
|
+
avoid reading errno repeatedly
|
82
|
+
aggregate/pmq: avoid false sharing of lock buffers
|
83
|
+
aggregate/pmq: remove io-extra requirement
|
84
|
+
aggregate/pmq: avoid File#stat allocation
|
85
|
+
Merge remote-tracking branch 'origin/freebsd'
|
86
|
+
Merge remote-tracking branch 'origin/aggregate-pmq'
|
87
|
+
doc: remove private email support address
|
88
|
+
doc: update location of TCP_INFO-related stuff
|
89
|
+
build: avoid olddoc for building the RubyGem
|
90
|
+
doc: document Raindrops::TCP hash
|
91
|
+
aggregate/pmq: update version numbers for Ruby and Linux
|
92
|
+
|
93
|
+
=== raindrops 0.17.0 - rack 2.x updates / 2016-07-31 15:19 UTC
|
94
|
+
|
95
|
+
This release features minor updates to support rack 2.x
|
96
|
+
while maintaining support for rack 1.2 and later.
|
97
|
+
As a result, Ruby 1.8.6 compatibility is gone, but
|
98
|
+
Ruby 1.8.7 probably still works, for now.
|
99
|
+
|
100
|
+
There's also a minor warning fix, doc updates, and
|
101
|
+
the homepage now supports HTTPS (HTTP remains supported)
|
102
|
+
|
103
|
+
5 changes since raindrops 0.16.0:
|
104
|
+
drop Rack::Utils.bytesize dependency
|
105
|
+
gemspec: bump Rack dependency
|
106
|
+
linux_inet_diag: GCC attribute format check
|
107
|
+
use HTTPS and move homepage to https://bogomips.org/raindrops/
|
108
|
+
examples: add yahns config, zbatery is abandoned
|
109
|
+
|
1
110
|
=== raindrops 0.16.0 - minor fixes and workarounds / 2016-02-29 12:36 UTC
|
2
111
|
|
3
112
|
There's mainly a fix/workaround for Ruby 2.3 now returning
|
data/README
CHANGED
@@ -40,7 +40,7 @@ and "tcp_diag" kernel modules are loaded as they do not autoload correctly
|
|
40
40
|
We recommend GCC 4+ (or compatible) to support the __sync builtins
|
41
41
|
(__sync_{add,sub}_and_fetch()):
|
42
42
|
|
43
|
-
|
43
|
+
https://gcc.gnu.org/onlinedocs/gcc/_005f_005fsync-Builtins.html
|
44
44
|
|
45
45
|
For non-GCC 4+ users, we also support compilation with the libatomic_ops
|
46
46
|
package starting with Raindrops 0.4.0:
|
@@ -54,33 +54,24 @@ If you use RubyGems:
|
|
54
54
|
|
55
55
|
gem install raindrops
|
56
56
|
|
57
|
-
Otherwise grab the latest tarball from:
|
58
|
-
|
59
|
-
http://raindrops.bogomips.org/files/
|
60
|
-
|
61
|
-
Unpack it, and run "ruby setup.rb"
|
62
|
-
|
63
57
|
== Usage
|
64
58
|
|
65
59
|
See Raindrops::Middleware and Raindrops::LastDataRecv documentation for
|
66
60
|
use Rack servers. The entire library is fully-documented and we are
|
67
|
-
responsive on the
|
68
|
-
you have any questions or comments.
|
61
|
+
responsive on the publicly archived mailbox
|
62
|
+
(mailto:raindrops-public@yhbt.net) if you have any questions or comments.
|
69
63
|
|
70
64
|
== Development
|
71
65
|
|
72
66
|
You can get the latest source via git from the following locations:
|
73
67
|
|
74
|
-
|
75
|
-
|
68
|
+
https://yhbt.net/raindrops.git
|
69
|
+
http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/raindrops.git
|
70
|
+
http://repo.or.cz/w/raindrops.git (gitweb mirror)
|
76
71
|
|
77
|
-
|
78
|
-
tarballs here:
|
72
|
+
Snapshots and tarballs are available.
|
79
73
|
|
80
|
-
|
81
|
-
* http://repo.or.cz/w/raindrops.git (gitweb)
|
82
|
-
|
83
|
-
Inline patches (from "git format-patch") to the mailing list are
|
74
|
+
Inline patches (from "git format-patch") to the mailbox are
|
84
75
|
preferred because they allow code review and comments in the reply to
|
85
76
|
the patch.
|
86
77
|
|
@@ -94,9 +85,17 @@ raindrops is licensed under the LGPL-2.1+
|
|
94
85
|
== Contact
|
95
86
|
|
96
87
|
All feedback (bug reports, user/development discussion, patches, pull
|
97
|
-
requests) go to the
|
88
|
+
requests) go to the publicly archived mailbox:
|
89
|
+
mailto:raindrops-public@yhbt.net
|
90
|
+
|
91
|
+
Mail archives are available over HTTP(S), IMAP(S) and NNTP(S):
|
98
92
|
|
99
|
-
|
93
|
+
* https://yhbt.net/raindrops-public/
|
94
|
+
* http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/raindrops-public/
|
95
|
+
* imaps://yhbt.net/inbox.comp.lang.ruby.raindrops.0
|
96
|
+
* imap://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.lang.ruby.raindrops.0
|
97
|
+
* nntps://news.public-inbox.org/inbox.comp.lang.ruby.raindrops
|
98
|
+
* nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.lang.ruby.raindrops
|
100
99
|
|
101
|
-
|
102
|
-
|
100
|
+
Since archives are public, scrub sensitive information and
|
101
|
+
use anonymity tools such as Tor or Mixmaster if you deem necessary.
|
data/TODO
CHANGED
@@ -15,7 +15,6 @@ end
|
|
15
15
|
usage = "Usage: #$0 [-d DELAY] [-t QUEUED_THRESHOLD] ADDR..."
|
16
16
|
ARGV.size > 0 or abort usage
|
17
17
|
delay = false
|
18
|
-
all = false
|
19
18
|
queued_thresh = -1
|
20
19
|
# "normal" exits when driven on the command-line
|
21
20
|
trap(:INT) { exit 130 }
|
@@ -25,7 +24,7 @@ OptionParser.new('', 24, ' ') do |opts|
|
|
25
24
|
opts.banner = usage
|
26
25
|
opts.on('-d', '--delay=DELAY', Float) { |n| delay = n }
|
27
26
|
opts.on('-t', '--queued-threshold=INT', Integer) { |n| queued_thresh = n }
|
28
|
-
opts.on('-a', '--all') {
|
27
|
+
opts.on('-a', '--all') { } # noop
|
29
28
|
opts.parse! ARGV
|
30
29
|
end
|
31
30
|
|
data/examples/watcher_demo.ru
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
# Inlined rack app using yahns server (git clone git://yhbt.net/yahns.git)
|
2
|
+
# Usage: yahns -c /path/to/this/file.conf.rb
|
3
|
+
# There is no separate config.ru file for this example,
|
4
|
+
# but rack_app may also be a string pointing to the path of a
|
5
|
+
# config.ru file
|
6
|
+
|
7
|
+
require 'rack'
|
8
|
+
rack_app = Rack::Builder.new do
|
9
|
+
use Rack::Head
|
10
|
+
addr = %w(0.0.0.0:9418 0.0.0.0:443 [::]:443 0.0.0.0:80 [::]:80
|
11
|
+
127.0.0.1:6081 127.0.0.1:280 0.0.0.0:119 [::]:119)
|
12
|
+
use Raindrops::Middleware, listeners: addr
|
13
|
+
run Raindrops::Watcher.new(listeners: addr)
|
14
|
+
end.to_app
|
15
|
+
# rack_app = '/path/to/config.ru' # a more standard config
|
16
|
+
|
17
|
+
app(:rack, rack_app) do
|
18
|
+
# I keep IPv4 and IPv6 on separate sockets to avoid ugly
|
19
|
+
# IPv4-mapped-IPv6 addresses:
|
20
|
+
listen 8080
|
21
|
+
listen '[::]:8080', ipv6only: true
|
22
|
+
client_max_body_size 0 # no POST or any uploads
|
23
|
+
client_timeout 5
|
24
|
+
output_buffering false # needed for /tail/ endpoint to avoid ENOSPC
|
25
|
+
queue { worker_threads 30 }
|
26
|
+
end
|
27
|
+
|
28
|
+
# logging is optional, but recommended for diagnosing problems
|
29
|
+
# stderr_path '/var/log/yahns/stderr-raindrops.log'
|
30
|
+
# stdout_path '/var/log/yahns/stdout-raindrops.log'
|
data/examples/zbatery.conf.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# Used for running Raindrops::Watcher, which requires a multi-threaded
|
2
2
|
# Rack server capable of streaming a response. Threads must be used,
|
3
|
-
# so
|
3
|
+
# so any multi-threaded Rack server may be used.
|
4
|
+
# zbatery was recommended in the past, but it is abandoned
|
5
|
+
# <http://zbatery.bogomip.org/>.
|
6
|
+
# yahns may work as an alternative (see yahns.conf.rb in this dir)
|
4
7
|
Rainbows! do
|
5
8
|
use :ThreadSpawn
|
6
9
|
end
|
data/ext/raindrops/extconf.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'mkmf'
|
2
|
+
require 'shellwords'
|
2
3
|
|
3
4
|
dir_config('atomic_ops')
|
4
5
|
have_func('mmap', 'sys/mman.h') or abort 'mmap() not found'
|
@@ -6,10 +7,112 @@ have_func('munmap', 'sys/mman.h') or abort 'munmap() not found'
|
|
6
7
|
|
7
8
|
$CPPFLAGS += " -D_GNU_SOURCE "
|
8
9
|
have_func('mremap', 'sys/mman.h')
|
9
|
-
|
10
|
+
headers = %w(sys/types.h netdb.h string.h sys/socket.h netinet/in.h)
|
11
|
+
if have_header('linux/tcp.h')
|
12
|
+
headers << 'linux/tcp.h'
|
13
|
+
else
|
14
|
+
%w(netinet/tcp.h netinet/tcp_fsm.h).each { |h|
|
15
|
+
have_header(h, headers) and headers << h
|
16
|
+
}
|
17
|
+
end
|
10
18
|
|
11
19
|
$CPPFLAGS += " -D_BSD_SOURCE "
|
20
|
+
|
21
|
+
if have_type("struct tcp_info", headers)
|
22
|
+
%w(
|
23
|
+
tcpi_state
|
24
|
+
tcpi_ca_state
|
25
|
+
tcpi_retransmits
|
26
|
+
tcpi_probes
|
27
|
+
tcpi_backoff
|
28
|
+
tcpi_options
|
29
|
+
tcpi_snd_wscale
|
30
|
+
tcpi_rcv_wscale
|
31
|
+
tcpi_rto
|
32
|
+
tcpi_ato
|
33
|
+
tcpi_snd_mss
|
34
|
+
tcpi_rcv_mss
|
35
|
+
tcpi_unacked
|
36
|
+
tcpi_sacked
|
37
|
+
tcpi_lost
|
38
|
+
tcpi_retrans
|
39
|
+
tcpi_fackets
|
40
|
+
tcpi_last_data_sent
|
41
|
+
tcpi_last_ack_sent
|
42
|
+
tcpi_last_data_recv
|
43
|
+
tcpi_last_ack_recv
|
44
|
+
tcpi_pmtu
|
45
|
+
tcpi_rcv_ssthresh
|
46
|
+
tcpi_rtt
|
47
|
+
tcpi_rttvar
|
48
|
+
tcpi_snd_ssthresh
|
49
|
+
tcpi_snd_cwnd
|
50
|
+
tcpi_advmss
|
51
|
+
tcpi_reordering
|
52
|
+
tcpi_rcv_rtt
|
53
|
+
tcpi_rcv_space
|
54
|
+
tcpi_total_retrans
|
55
|
+
tcpi_snd_wnd
|
56
|
+
tcpi_snd_bwnd
|
57
|
+
tcpi_snd_nxt
|
58
|
+
tcpi_rcv_nxt
|
59
|
+
tcpi_toe_tid
|
60
|
+
tcpi_snd_rexmitpack
|
61
|
+
tcpi_rcv_ooopack
|
62
|
+
tcpi_snd_zerowin
|
63
|
+
).each do |field|
|
64
|
+
cfunc = "tcp_info_#{field}"
|
65
|
+
if have_struct_member('struct tcp_info', field, headers)
|
66
|
+
func_body = <<EOF
|
67
|
+
static VALUE #{cfunc}(VALUE self)
|
68
|
+
{
|
69
|
+
struct tcp_info *info = DATA_PTR(self);
|
70
|
+
return UINT2NUM((uint32_t)info->#{field});
|
71
|
+
}
|
72
|
+
EOF
|
73
|
+
func_body.delete!("\n")
|
74
|
+
$defs << "-DCFUNC_#{cfunc}=#{Shellwords.shellescape(func_body)}"
|
75
|
+
else
|
76
|
+
func_body = "static inline void #{cfunc}(void) {}"
|
77
|
+
$defs << "-DCFUNC_#{cfunc}=#{Shellwords.shellescape(func_body)}"
|
78
|
+
cfunc = 'rb_f_notimplement'.freeze
|
79
|
+
end
|
80
|
+
rbmethod = %Q("#{field.sub(/\Atcpi_/, ''.freeze)}")
|
81
|
+
$defs << "-DDEFINE_METHOD_tcp_info_#{field}=" \
|
82
|
+
"#{Shellwords.shellescape(
|
83
|
+
%Q[rb_define_method(cTCP_Info,#{rbmethod},#{cfunc},0)])}"
|
84
|
+
end
|
85
|
+
tcp_state_map = {
|
86
|
+
ESTABLISHED: %w(TCP_ESTABLISHED TCPS_ESTABLISHED),
|
87
|
+
SYN_SENT: %w(TCP_SYN_SENT TCPS_SYN_SENT),
|
88
|
+
SYN_RECV: %w(TCP_SYN_RECV TCPS_SYN_RECEIVED),
|
89
|
+
FIN_WAIT1: %w(TCP_FIN_WAIT1 TCPS_FIN_WAIT_1),
|
90
|
+
FIN_WAIT2: %w(TCP_FIN_WAIT2 TCPS_FIN_WAIT_2),
|
91
|
+
TIME_WAIT: %w(TCP_TIME_WAIT TCPS_TIME_WAIT),
|
92
|
+
CLOSE: %w(TCP_CLOSE TCPS_CLOSED),
|
93
|
+
CLOSE_WAIT: %w(TCP_CLOSE_WAIT TCPS_CLOSE_WAIT),
|
94
|
+
LAST_ACK: %w(TCP_LAST_ACK TCPS_LAST_ACK),
|
95
|
+
LISTEN: %w(TCP_LISTEN TCPS_LISTEN),
|
96
|
+
CLOSING: %w(TCP_CLOSING TCPS_CLOSING),
|
97
|
+
}
|
98
|
+
nstate = 0
|
99
|
+
tcp_state_map.each do |state, try|
|
100
|
+
try.each do |os_name|
|
101
|
+
have_const(os_name, headers) or next
|
102
|
+
tcp_state_map[state] = os_name
|
103
|
+
nstate += 1
|
104
|
+
end
|
105
|
+
end
|
106
|
+
if nstate == tcp_state_map.size
|
107
|
+
$defs << '-DRAINDROPS_TCP_STATES_ALL_KNOWN=1'
|
108
|
+
tcp_state_map.each do |state, name|
|
109
|
+
$defs << "-DRAINDROPS_TCP_#{state}=#{name}"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
12
114
|
have_func("getpagesize", "unistd.h")
|
115
|
+
have_func('rb_thread_call_without_gvl')
|
13
116
|
have_func('rb_thread_blocking_region')
|
14
117
|
have_func('rb_thread_io_blocking_region')
|
15
118
|
|
@@ -40,7 +143,7 @@ SRC
|
|
40
143
|
$defs.push(format("-DHAVE_GCC_ATOMIC_BUILTINS"))
|
41
144
|
true
|
42
145
|
else
|
43
|
-
|
146
|
+
$CFLAGS = prev_cflags
|
44
147
|
false
|
45
148
|
end
|
46
149
|
end
|
@@ -53,4 +156,5 @@ Users of Debian-based distros may run:
|
|
53
156
|
|
54
157
|
apt-get install libatomic-ops-dev
|
55
158
|
SRC
|
159
|
+
create_header # generate extconf.h to avoid excessively long command-line
|
56
160
|
create_makefile('raindrops_ext')
|