iodine 0.7.36 → 0.7.41
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +40 -0
- data/.travis.yml +10 -8
- data/CHANGELOG.md +28 -0
- data/README.md +55 -48
- data/Rakefile +3 -1
- data/examples/shootout.ru +8 -0
- data/exe/iodine +1 -0
- data/ext/iodine/extconf.rb +0 -34
- data/ext/iodine/fio.c +65 -65
- data/ext/iodine/fio.h +1 -1
- data/ext/iodine/fio_tls_missing.c +6 -0
- data/ext/iodine/fio_tls_openssl.c +64 -28
- data/ext/iodine/http.c +87 -100
- data/ext/iodine/http1.c +6 -15
- data/ext/iodine/http1_parser.h +806 -63
- data/ext/iodine/iodine.c +12 -0
- data/ext/iodine/iodine_defer.c +1 -0
- data/ext/iodine/iodine_http.c +11 -0
- data/ext/iodine/iodine_http.h +2 -0
- data/ext/iodine/iodine_rack_io.c +1 -5
- data/ext/iodine/iodine_tls.c +2 -16
- data/iodine.gemspec +2 -2
- data/lib/iodine.rb +2 -1
- data/lib/iodine/connection.rb +12 -0
- data/lib/iodine/version.rb +1 -1
- metadata +7 -7
- data/ext/iodine/http1_parser.c +0 -458
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03af29c680fee3cd7b70b4a9fbc0f370b42a763f83f4422cc0f1cae296b95f1c
|
4
|
+
data.tar.gz: b6e25d8cc33dd955989ae6c8f6bf18d45f84dad42887eff22f39c68aada56f02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4eab8d5f7309dd8845d4f6c8052935dbd8145201c4820786ae000e895277883765c1dd628c1e053816b50a1d7c002180f6b4e0a5833e60d76277dab8ecf81b1
|
7
|
+
data.tar.gz: f90eb620cf2a9aaf7c943fe981e829f698cb1e8fc176ad8ad778df2c36c5eb026314522d428bee8058915e95f9ed3750ed078931193b81b0dec062e27eb569c2
|
@@ -0,0 +1,40 @@
|
|
1
|
+
---
|
2
|
+
name: Bug report
|
3
|
+
about: Create a report to help us improve
|
4
|
+
title: ''
|
5
|
+
labels: ''
|
6
|
+
assignees: ''
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
### System Information
|
11
|
+
|
12
|
+
- **OS**: [e.g. macOS 10.15.4]
|
13
|
+
- **Ruby**: [e.g. 2.7.0]
|
14
|
+
- **Version**: [e.g. 0.7.38]
|
15
|
+
- **OpenSSL**: [OpenSSL 1.1.1f 20 Mar 2020]
|
16
|
+
|
17
|
+
### Description
|
18
|
+
|
19
|
+
A clear and concise description of what the bug is.
|
20
|
+
|
21
|
+
### Rack App to Reproduce
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
APP = {|env| [200, {}, "Hello World"] }
|
25
|
+
run APP
|
26
|
+
```
|
27
|
+
|
28
|
+
### Testing code
|
29
|
+
|
30
|
+
```sh
|
31
|
+
curl http://localhost:3000/
|
32
|
+
```
|
33
|
+
|
34
|
+
### Expected behavior
|
35
|
+
|
36
|
+
A clear and concise description of what you expected to happen.
|
37
|
+
|
38
|
+
### Actual behavior
|
39
|
+
|
40
|
+
A clear and concise description of what actually happened.
|
data/.travis.yml
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
language: ruby
|
2
|
+
arch:
|
3
|
+
- amd64
|
4
|
+
- arm64
|
2
5
|
os:
|
3
6
|
- linux
|
4
7
|
# - osx
|
@@ -6,15 +9,16 @@ before_install:
|
|
6
9
|
- gem install bundler -v 1.10.6
|
7
10
|
- bundle install
|
8
11
|
rvm:
|
9
|
-
- 2.
|
10
|
-
- 2.5
|
11
|
-
- 2.
|
12
|
+
- 2.7.1
|
13
|
+
- 2.6.5
|
14
|
+
- 2.5.7
|
15
|
+
- 2.4.9
|
12
16
|
- 2.3.8
|
13
17
|
- 2.2.2
|
14
18
|
notifications:
|
15
19
|
email: false
|
16
20
|
sudo: required
|
17
|
-
dist:
|
21
|
+
dist: xenial
|
18
22
|
addons:
|
19
23
|
apt:
|
20
24
|
sources:
|
@@ -24,7 +28,5 @@ addons:
|
|
24
28
|
script:
|
25
29
|
- echo CFLAGS = $CFLAGS
|
26
30
|
- echo cflags = $cflags
|
27
|
-
- bundle exec rake
|
28
|
-
-
|
29
|
-
- rake build
|
30
|
-
- find pkg/iodine-*.gem -exec gem install -V {} +
|
31
|
+
- bundle exec rake install
|
32
|
+
- env VERBOSE=1 bundle exec rspec --format documentation
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,34 @@ Please notice that this change log contains changes for upcoming releases as wel
|
|
6
6
|
|
7
7
|
## Changes:
|
8
8
|
|
9
|
+
#### Change log v.0.7.41 (2020-07-24)
|
10
|
+
|
11
|
+
**Fix**: Hot Restart failed because listening sockets were cleared away. Credit to Néstor Coppi (@Shelvak) for exposing issue #97.
|
12
|
+
|
13
|
+
**Fix**: CLI argument parsing is now only active when using the iodine CLI (or if defining `IODINE_PARSE_CLI` before requiring `iodine`). Credit to Aldis Berjoza (@graudeejs) for exposing issue #96.
|
14
|
+
|
15
|
+
#### Change log v.0.7.40 (2020-05-23)
|
16
|
+
|
17
|
+
**Fix**: fixed TLS logging and performance issues exposed by Franck Gille (@fgi) in issue #93.
|
18
|
+
|
19
|
+
#### Change log v.0.7.39 (2020-05-18)
|
20
|
+
|
21
|
+
**Security**: a request smuggling attack vector and Transfer Encoding attack vector in the HTTP/1.1 parser were exposed by Sam Sanoop from [the Snyk Security team (snyk.io)](https://snyk.io). The parser was updated to deal with these potential issues.
|
22
|
+
|
23
|
+
**Fix**: (`http`) fixes an issue with date calculation - exposed by Franck Gille (@fgi) in issue #92.
|
24
|
+
|
25
|
+
**Fix**: (`extconf`) fixes an installation concern raised by Benoit Daloze (@eregon), in issue #91. The default compiler is now used.
|
26
|
+
|
27
|
+
#### Change log v.0.7.38
|
28
|
+
|
29
|
+
**Fix**: (`http`) fixes an issue and improves support for chunked encoded payloads. Credit to Ian Ker-Seymer ( @ianks ) for exposing this, writing tests and opening both the issue #87 and the PR #88.
|
30
|
+
|
31
|
+
#### Change log v.0.7.37
|
32
|
+
|
33
|
+
**Fix**: requests will fail when the path contains a dangling `?` (empty query). Credit to @adam12 for exposing this and opening issue #86.
|
34
|
+
|
35
|
+
**Fix**: documentation improvements and corrections, credit to Caleb Albritton ( @WA9ACE ) and Don Morrison ( @elskwid ) for PRs #82 and #83. Credit to Nir ( @Roko131 ) and Aurel Branzeanu ( @texpert ) for opening and commenting on issue #84.
|
36
|
+
|
9
37
|
#### Change log v.0.7.36
|
10
38
|
|
11
39
|
**Fix**: avoids clobbering the namespace when attempting to set Rack's default handler. Credit to Caleb Albritton ( @WA9ACE ) for issue #80 and PR #81.
|
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
# iodine - a fast HTTP /
|
1
|
+
# iodine - Why Settle for a fast HTTP / WebSocket Server with native Pub/Sub?
|
2
|
+
|
2
3
|
[![Gem](https://img.shields.io/gem/dt/iodine.svg)](https://rubygems.org/gems/iodine)
|
3
4
|
[![Build Status](https://travis-ci.org/boazsegev/iodine.svg?branch=master)](https://travis-ci.org/boazsegev/iodine)
|
4
5
|
[![Gem Version](https://badge.fury.io/rb/iodine.svg)](https://badge.fury.io/rb/iodine)
|
@@ -7,28 +8,30 @@
|
|
7
8
|
|
8
9
|
[![Logo](https://github.com/boazsegev/iodine/raw/master/logo.png)](https://github.com/boazsegev/iodine)
|
9
10
|
|
10
|
-
|
11
|
+
Iodine is a fast concurrent web application server for real-time Ruby applications, with native support for WebSockets and Pub/Sub services - but it's also so much more.
|
11
12
|
|
12
|
-
|
13
|
+
Iodine is a Ruby wrapper for many of the [facil.io](https://facil.io) C framework, leveraging the speed of C for many common web application tasks. In addition, iodine abstracts away all network concerns, so you never need to worry about the transport layer, free to concentrate on your application logic.
|
13
14
|
|
14
|
-
Iodine
|
15
|
+
Iodine includes native support for:
|
15
16
|
|
16
17
|
* HTTP, WebSockets and EventSource (SSE) Services (server);
|
17
18
|
* WebSocket connections (server / client);
|
18
19
|
* Pub/Sub (with optional Redis Pub/Sub scaling);
|
19
|
-
*
|
20
|
-
*
|
20
|
+
* Fast(!) builtin Mustache template engine.
|
21
|
+
* Static file service (with automatic `gzip` support for pre-compressed assets);
|
22
|
+
* Optimized Logging to `stderr`.
|
21
23
|
* Asynchronous event scheduling and timers;
|
22
|
-
*
|
24
|
+
* HTTP/1.1 keep-alive and pipelining;
|
25
|
+
* Heap Fragmentation Protection.
|
23
26
|
* TLS 1.2 and above (Requires OpenSSL >= 1.1.0);
|
24
27
|
* TCP/IP server and client connectivity;
|
25
28
|
* Unix Socket server and client connectivity;
|
29
|
+
* Hot Restart (using the USR1 signal and without hot deployment);
|
26
30
|
* Custom protocol authoring;
|
27
|
-
* Optimized Logging to `stderr`.
|
28
31
|
* [Sequel](https://github.com/jeremyevans/sequel) and ActiveRecord forking protection.
|
29
32
|
* and more!
|
30
33
|
|
31
|
-
|
34
|
+
Since iodine wraps much of the [C facil.io framework](https://github.com/boazsegev/facil.io) to Ruby:
|
32
35
|
|
33
36
|
* Iodine can handle **thousands of concurrent connections** (tested with more then 20K connections on Linux)!
|
34
37
|
|
@@ -36,9 +39,9 @@ Iodine is an **evented** framework with a simple API that ports much of the [C f
|
|
36
39
|
|
37
40
|
Iodine is a C extension for Ruby, developed and optimized for Ruby MRI 2.2.2 and up... it should support the whole Ruby 2.0 MRI family, but CI tests start at Ruby 2.2.2.
|
38
41
|
|
39
|
-
**Note**: iodine does **not** support
|
42
|
+
**Note**: iodine does **not** support streaming when using Rack. It's recommended to avoid blocking the server when using `body.each` since the `each` loop will block the iodine's thread until it's finished and iodine won't send any data before the loop is done.
|
40
43
|
|
41
|
-
## Iodine - a fast & powerful HTTP +
|
44
|
+
## Iodine - a fast & powerful HTTP + WebSockets server with native Pub/Sub
|
42
45
|
|
43
46
|
Iodine includes a light and fast HTTP and Websocket server written in C that was written according to the [Rack interface specifications](http://www.rubydoc.info/github/rack/rack/master/file/SPEC) and the [Websocket draft extension](./SPEC-Websocket-Draft.md).
|
44
47
|
|
@@ -46,6 +49,10 @@ With `Iodine.listen service: :http` it's possible to run multiple HTTP applicati
|
|
46
49
|
|
47
50
|
Iodine also supports native process cluster Pub/Sub and a native RedisEngine to easily scale iodine's Pub/Sub horizontally.
|
48
51
|
|
52
|
+
### Known Issues and Reporting Issues
|
53
|
+
|
54
|
+
See the [GitHub Open Issues](https://github.com/boazsegev/iodine/issues) list for known issues and to report new issues.
|
55
|
+
|
49
56
|
### Installing and Running Iodine
|
50
57
|
|
51
58
|
Install iodine on any Linux / BSD / macOS system using:
|
@@ -68,6 +75,8 @@ bundler exec iodine
|
|
68
75
|
|
69
76
|
#### Installing with SSL/TLS
|
70
77
|
|
78
|
+
**Note**: iodine has known issues with the TLS/SSL support. TLS/SSL should **NOT** be used in production (see issues #95 and #94).
|
79
|
+
|
71
80
|
Make sure to update OpenSSL to the latest version **before installing Ruby** (`rbenv` should do this automatically).
|
72
81
|
|
73
82
|
To avoid name resolution conflicts, iodine will bind to the same OpenSSL version Ruby is bound to. To use SSL/TLS this should be OpenSSL >= 1.1.0 or LibreSSL >= 2.7.4.
|
@@ -85,9 +94,7 @@ Confirmed OpenSSL to be version 1.1.0 or above (OpenSSL 1.1.0j 20 Nov 2018)...
|
|
85
94
|
...
|
86
95
|
```
|
87
96
|
|
88
|
-
**
|
89
|
-
|
90
|
-
The installation script tests for OpenSSL 1.1.0 and above. However, this testing approach sometimes provides false positives. If TLS isn't required, install with `NO_SSL=1`. i.e.:
|
97
|
+
The installation script tests for OpenSSL 1.1.0 and above. However, this testing approach sometimes provides false positives. **If TLS isn't required, install with `NO_SSL=1`**. i.e.:
|
91
98
|
|
92
99
|
```bash
|
93
100
|
NO_SSL=1 bundler exec iodine
|
@@ -108,17 +115,19 @@ On Rails:
|
|
108
115
|
if(defined?(Iodine))
|
109
116
|
Iodine.threads = ENV.fetch("RAILS_MAX_THREADS", 5).to_i if Iodine.threads.zero?
|
110
117
|
Iodine.workers = ENV.fetch("WEB_CONCURRENCY", 2).to_i if Iodine.workers.zero?
|
111
|
-
Iodine::DEFAULT_SETTINGS[:port]
|
118
|
+
Iodine::DEFAULT_SETTINGS[:port] ||= ENV.fetch("PORT") if ENV.fetch("PORT")
|
112
119
|
end
|
113
120
|
```
|
114
121
|
|
115
122
|
When using native WebSockets with Rails, middle-ware is probably the best approach. A guide for this approach will, hopefully, get published in the future.
|
116
123
|
|
124
|
+
**Note**: command-line instructions (CLI) should be the preferred way for configuring iodine, allowing for code-less configuration updates.
|
125
|
+
|
117
126
|
### Optimizing Iodine's Concurrency
|
118
127
|
|
119
128
|
To get the most out of iodine, consider the amount of CPU cores available and the concurrency level the application requires.
|
120
129
|
|
121
|
-
Iodine will calculate, when possible, a good enough default concurrency model. See if this works for your application or customize according to the application's needs.
|
130
|
+
Iodine will calculate, when possible, a good enough default concurrency model for fast applications. See if this works for your application or customize according to the application's needs.
|
122
131
|
|
123
132
|
Command line arguments allow easy access to different options, including concurrency levels. i.e., to set up 16 threads and 4 processes:
|
124
133
|
|
@@ -134,13 +143,19 @@ export WORKERS=-1 # negative values are fractions of CPU cores.
|
|
134
143
|
bundler exec iodine -p $PORT
|
135
144
|
```
|
136
145
|
|
146
|
+
Negative values are evaluated as "CPU Cores / abs(Value)". i.e., on an 8 core CPU machine, this will produce 4 worker processes with 2 threads per worker:
|
147
|
+
|
148
|
+
```bash
|
149
|
+
bundler exec iodine -p $PORT -t 2 -w -2
|
150
|
+
```
|
151
|
+
|
137
152
|
### Heap Fragmentation Protection
|
138
153
|
|
139
154
|
Iodine includes a fast, network oriented, custom memory allocator, optimizing away some of the work usually placed on the Ruby Garbage Collector (GC).
|
140
155
|
|
141
156
|
This approach helps to minimize heap fragmentation for long running processes, by grouping many short-lived objects into a common memory space.
|
142
157
|
|
143
|
-
It
|
158
|
+
It is still recommended to consider [jemalloc](http://jemalloc.net) or other allocators that also help mitigate heap fragmentation issues.
|
144
159
|
|
145
160
|
### Static file serving support
|
146
161
|
|
@@ -348,7 +363,7 @@ Since the master / root process doesn't handle any requests (it only handles pub
|
|
348
363
|
|
349
364
|
### Optimized HTTP logging
|
350
365
|
|
351
|
-
By default, iodine is pretty
|
366
|
+
By default, iodine is pretty quiet. Some messages are logged to `stderr`, but not many.
|
352
367
|
|
353
368
|
However, HTTP requests can be logged using iodine's optimized logger to `stderr`. Iodine will optimize the log output by caching the output time string which updates every second rather than every request.
|
354
369
|
|
@@ -433,11 +448,11 @@ Iodine.connect url: "wss://echo.websocket.org", handler: EchoClient.new, ping: 4
|
|
433
448
|
Iodine.start
|
434
449
|
```
|
435
450
|
|
436
|
-
### TLS 1.2 support
|
451
|
+
### TLS >= 1.2 support
|
437
452
|
|
438
453
|
> Requires OpenSSL >= `1.1.0`. On Heroku, requires `heroku-18`.
|
439
454
|
|
440
|
-
Iodine supports secure connections fore TLS version 1.2 and up (depending on the OpenSSL version).
|
455
|
+
Iodine supports secure connections fore TLS version 1.2 **and up** (depending on the OpenSSL version).
|
441
456
|
|
442
457
|
A self signed certificate is available using the `-tls` flag from the command-line.
|
443
458
|
|
@@ -478,31 +493,11 @@ run APP
|
|
478
493
|
|
479
494
|
### How does it compare to other servers?
|
480
495
|
|
481
|
-
|
482
|
-
|
483
|
-
In my tests, pitching Iodine against Puma, Iodine was anywhere between x1.5 and x7 faster than Puma (depending on use-case). such a big difference is suspect and I recommend that you test it yourself.
|
496
|
+
In my tests, pitching Iodine against Puma, Iodine was anywhere between x1.5 and more than x10 faster than Puma (depending on use-case and settings).
|
484
497
|
|
485
|
-
|
498
|
+
Such a big difference is suspect and I recommend that you test it yourself - even better if you test performance using your own application and a number of possible different settings (how many threads per CPU core? how many worker processes? middleware vs. server request logging, etc').
|
486
499
|
|
487
|
-
|
488
|
-
|
489
|
-
* Iodine performed at 74,786.27 req/sec, consuming ~68.4Mb of memory.
|
490
|
-
|
491
|
-
* Puma performed at 48,994.59 req/sec, consuming ~79.6Mb of memory.
|
492
|
-
|
493
|
-
When benchmarking using a VM (crossing machine boundaries, 16 threads, 4 workers, 200 concurrent connections), I calculated Iodine to be x2.3 faster:
|
494
|
-
|
495
|
-
* Iodine performed at 23,559.56 req/sec, consuming ~88.8Mb of memory.
|
496
|
-
|
497
|
-
* Puma performed at 9,935.31 req/sec, consuming ~84.0Mb of memory.
|
498
|
-
|
499
|
-
When benchmarking using a VM (crossing machine boundaries, single thread, single worker, 200 concurrent connections), I calculated Iodine to be x7.3 faster:
|
500
|
-
|
501
|
-
* Iodine performed at 18,444.31 req/sec, consuming ~25.6Mb of memory.
|
502
|
-
|
503
|
-
* Puma performed at 2,521.56 req/sec, consuming ~27.5Mb of memory.
|
504
|
-
|
505
|
-
I have doubts about my own benchmarks and I recommend benchmarking the performance for yourself using `wrk` or `ab`:
|
500
|
+
I recommend benchmarking the performance for yourself using `wrk` or `ab`:
|
506
501
|
|
507
502
|
```bash
|
508
503
|
$ wrk -c200 -d4 -t2 http://localhost:3000/
|
@@ -510,7 +505,7 @@ $ wrk -c200 -d4 -t2 http://localhost:3000/
|
|
510
505
|
$ ab -n 100000 -c 200 -k http://127.0.0.1:3000/
|
511
506
|
```
|
512
507
|
|
513
|
-
|
508
|
+
The best application to use for benchmarking is your actual application. Or, you could create a simple `config.ru` file with a __hello world__ app:
|
514
509
|
|
515
510
|
```ruby
|
516
511
|
App = Proc.new do |env|
|
@@ -523,17 +518,21 @@ end
|
|
523
518
|
run App
|
524
519
|
```
|
525
520
|
|
526
|
-
Then start comparing servers. Here are the settings I used to compare iodine and Puma (4 processes,
|
521
|
+
Then start comparing servers. Here are the settings I used to compare iodine and Puma (4 processes, 4 threads):
|
527
522
|
|
528
523
|
```bash
|
529
|
-
$ RACK_ENV=production iodine -p 3000 -t
|
524
|
+
$ RACK_ENV=production iodine -p 3000 -t 4 -w 4
|
530
525
|
# vs.
|
531
|
-
$ RACK_ENV=production puma -p 3000 -t
|
526
|
+
$ RACK_ENV=production puma -p 3000 -t 4 -w 4
|
532
527
|
# Review the `iodine -?` help for more command line options.
|
533
528
|
```
|
534
529
|
|
535
530
|
It's recommended that the servers (Iodine/Puma) and the client (`wrk`/`ab`) run on separate machines.
|
536
531
|
|
532
|
+
It is worth noting that iodine can also speed up logging by replacing the logging middleware with `iodine -v`. This approach uses less memory and improves performance at the expense of fuzzy timing and some string caching.
|
533
|
+
|
534
|
+
On my machine, testing with the logging functionality enabled, iodine was more then 10 times faster than puma (60.9K req/sec vs. 5.3K req/sec)
|
535
|
+
|
537
536
|
### A few notes
|
538
537
|
|
539
538
|
Iodine's upgrade / callback design has a number of benefits, some of them related to better IO handling, resource optimization (no need for two IO polling systems), etc. This also allows us to use middleware without interfering with connection upgrades and provides backwards compatibility.
|
@@ -585,7 +584,7 @@ More possible compile time options can be found in the [facil.io documentation](
|
|
585
584
|
|
586
585
|
## Evented oriented design with extra safety
|
587
586
|
|
588
|
-
Iodine is an
|
587
|
+
Iodine is an evented server, similar in its architecture to `nginx` and `puma`. It's different than the simple "thread-per-client" design that is often taught when we begin to learn about network programming.
|
589
588
|
|
590
589
|
By leveraging `epoll` (on Linux) and `kqueue` (on BSD), iodine can listen to multiple network events on multiple sockets using a single thread.
|
591
590
|
|
@@ -770,6 +769,14 @@ Yes, please, here are some thoughts:
|
|
770
769
|
|
771
770
|
* If you love the project or thought the code was nice, maybe helped you in your own project, drop me a line. I'd love to know.
|
772
771
|
|
772
|
+
### Running the Tests
|
773
|
+
|
774
|
+
Running this task will compile the C extensions then run RSpec tests:
|
775
|
+
|
776
|
+
```sh
|
777
|
+
bundle exec rake spec
|
778
|
+
```
|
779
|
+
|
773
780
|
## License
|
774
781
|
|
775
782
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
@@ -3,10 +3,12 @@ require "rake/extensiontask"
|
|
3
3
|
|
4
4
|
begin
|
5
5
|
require 'rspec/core/rake_task'
|
6
|
-
RSpec::Core::RakeTask.new(:
|
6
|
+
RSpec::Core::RakeTask.new(:rspec)
|
7
7
|
rescue LoadError
|
8
8
|
end
|
9
9
|
|
10
|
+
task :spec => [:compile, :rspec]
|
11
|
+
|
10
12
|
task :default => [:compile, :spec]
|
11
13
|
|
12
14
|
Rake::ExtensionTask.new "iodine" do |ext|
|
data/examples/shootout.ru
CHANGED
@@ -22,6 +22,14 @@ module ShootoutApp
|
|
22
22
|
len += out[-1].length
|
23
23
|
request.params.each { |k,v| out << "#{k}: #{v}\n" ; len += out[-1].length }
|
24
24
|
end
|
25
|
+
if(env['rack.input'])
|
26
|
+
env['rack.input'].rewind
|
27
|
+
out << "Body\n\n"
|
28
|
+
out << env['rack.input'].read
|
29
|
+
len += out[-1].length + 6
|
30
|
+
out << "\n\nBody Length: #{out[-1].length}\n\n"
|
31
|
+
len += out[-1].length
|
32
|
+
end
|
25
33
|
[200, { 'Content-Length' => len.to_s, 'Content-Type' => 'text/plain; charset=UTF-8;' }, out]
|
26
34
|
end
|
27
35
|
# We'll base the shootout on the internal Pub/Sub service.
|
data/exe/iodine
CHANGED
data/ext/iodine/extconf.rb
CHANGED
@@ -1,34 +1,5 @@
|
|
1
1
|
require 'mkmf'
|
2
2
|
|
3
|
-
if ENV['CC']
|
4
|
-
ENV['CPP'] ||= ENV['CC']
|
5
|
-
puts "detected user prefered compiler (#{ENV['CC']}):", `#{ENV['CC']} -v`
|
6
|
-
elsif find_executable('clang') && puts('testing clang for stdatomic support...').nil? && system("printf \"\#include <stdatomic.h>\nint main(void) {}\" | clang -include stdatomic.h -xc -o /dev/null -", out: '/dev/null')
|
7
|
-
$CC = ENV['CC'] = 'clang'
|
8
|
-
$CPP = ENV['CPP'] = 'clang'
|
9
|
-
puts "using clang compiler v. #{`clang -dumpversion`}."
|
10
|
-
elsif find_executable('gcc') && (`gcc -dumpversion 2>&1`.to_i >= 5)
|
11
|
-
$CC = ENV['CC'] = 'gcc'
|
12
|
-
$CPP = ENV['CPP'] = find_executable('g++') ? 'g++' : 'gcc'
|
13
|
-
puts "using gcc #{ `gcc -dumpversion 2>&1`.to_i }"
|
14
|
-
elsif find_executable('gcc-6')
|
15
|
-
$CC = ENV['CC'] = 'gcc-6'
|
16
|
-
$CPP = ENV['CPP'] = find_executable('g++-6') ? 'g++-6' : 'gcc-6'
|
17
|
-
puts 'using gcc-6 compiler.'
|
18
|
-
elsif find_executable('gcc-5')
|
19
|
-
$CC = ENV['CC'] = 'gcc-5'
|
20
|
-
$CPP = ENV['CPP'] = find_executable('g++-5') ? 'g++-5' : 'gcc-5'
|
21
|
-
puts 'using gcc-5 compiler.'
|
22
|
-
elsif find_executable('gcc-4.9')
|
23
|
-
$CC = ENV['CC'] = 'gcc-4.9'
|
24
|
-
$CPP = ENV['CPP'] = find_executable('g++-4.9') ? 'g++-4.9' : 'gcc-4.9'
|
25
|
-
puts 'using gcc-4.9 compiler.'
|
26
|
-
else
|
27
|
-
puts 'using an unknown (old?) compiler... who knows if this will work out... we hope.'
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
|
32
3
|
# Test polling
|
33
4
|
def iodine_test_polling_support
|
34
5
|
iodine_poll_test_kqueue = <<EOS
|
@@ -129,10 +100,5 @@ EOS
|
|
129
100
|
end
|
130
101
|
end
|
131
102
|
end
|
132
|
-
# $defs << "-DFIO_USE_RISKY_HASH"
|
133
|
-
|
134
|
-
RbConfig::MAKEFILE_CONFIG['CFLAGS'] = $CFLAGS = "-std=c11 -DFIO_PRINT_STATE=0 #{$CFLAGS} #{$CFLAGS == ENV['CFLAGS'] ? "" : ENV['CFLAGS']}"
|
135
|
-
RbConfig::MAKEFILE_CONFIG['CC'] = $CC = ENV['CC'] if ENV['CC']
|
136
|
-
RbConfig::MAKEFILE_CONFIG['CPP'] = $CPP = ENV['CPP'] if ENV['CPP']
|
137
103
|
|
138
104
|
create_makefile 'iodine/iodine'
|