polyphony 0.47.4 → 0.47.5
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/CHANGELOG.md +301 -296
- data/Gemfile.lock +1 -1
- data/TODO.md +10 -18
- data/examples/core/supervisor.rb +3 -3
- data/examples/core/worker-thread.rb +3 -4
- data/ext/polyphony/backend_common.h +0 -20
- data/ext/polyphony/backend_io_uring.c +7 -10
- data/ext/polyphony/backend_libev.c +4 -8
- data/lib/polyphony/extensions/fiber.rb +12 -2
- data/lib/polyphony/extensions/socket.rb +8 -9
- data/lib/polyphony/version.rb +1 -1
- data/test/test_socket.rb +27 -1
- data/test/test_supervise.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4343a37f26793e76528ea8e87287e2f3fbc4c8182064e820eedfc131d4308729
|
4
|
+
data.tar.gz: 89273660342f647e3e016290ef48ac10f33b040a3ca6538b1fdd29aab13519da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7aa6b9f5e9ea61b682a112b30286b1e66f71088da67f96827d6415a6be12de4874de79ccd2236f36ba4da1bf5e9c078735bd07ac32520268c12cadfe60cd8565
|
7
|
+
data.tar.gz: e564dfed776907921bdceafcdb47e78fe5655d345812f3484d7493df74f3485d09bf32e756c766cc45efe45591524c6a24d55c19530fa14ededbb4f481e80977
|
data/CHANGELOG.md
CHANGED
@@ -1,497 +1,502 @@
|
|
1
|
+
## 0.47.5
|
2
|
+
|
3
|
+
- Add `socket_class` argument to `Backend#accept`, `Backend#accept_loop`
|
4
|
+
- Fix `#supervise` to stop when all children fibers are done
|
5
|
+
|
1
6
|
## 0.47.4
|
2
7
|
|
3
|
-
|
8
|
+
- Add support for Unix sockets
|
4
9
|
|
5
10
|
## 0.47.3
|
6
11
|
|
7
|
-
|
8
|
-
|
12
|
+
- Enable I/O in signal handlers (#45)
|
13
|
+
- Accept `:interval` argument in `#spin_loop`
|
9
14
|
|
10
15
|
## 0.47.2
|
11
16
|
|
12
|
-
|
17
|
+
- Fix API compatibility between TCPSocket and IO
|
13
18
|
|
14
19
|
## 0.47.0
|
15
20
|
|
16
|
-
|
17
|
-
|
21
|
+
- Implement `#spin_scope` used for creating blocking fiber scopes
|
22
|
+
- Reimplement `move_on_after`, `cancel_after`, `Timeout.timeout` using
|
18
23
|
`Backend#timeout` (avoids creating canceller fiber for most common use case)
|
19
|
-
|
20
|
-
|
24
|
+
- Implement `Backend#timeout` API
|
25
|
+
- Implemented capped queues
|
21
26
|
|
22
27
|
## 0.46.1
|
23
28
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
29
|
+
- Add `TCPServer#accept_loop`, `OpenSSL::SSL::SSLSocket#accept_loop` method
|
30
|
+
- Fix compilation error on MacOS (#43)
|
31
|
+
- Fix backtrace for `Timeout.timeout`
|
32
|
+
- Add `Backend#timer_loop`
|
28
33
|
|
29
34
|
## 0.46.0
|
30
35
|
|
31
|
-
|
36
|
+
- Implement [io_uring backend](https://github.com/digital-fabric/polyphony/pull/44)
|
32
37
|
|
33
38
|
## 0.45.5
|
34
39
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
40
|
+
- Fix compilation error (#43)
|
41
|
+
- Add support for resetting move_on_after, cancel_after timeouts
|
42
|
+
- Optimize anti-event starvation polling
|
43
|
+
- Implement optimized runqueue for better performance
|
44
|
+
- Schedule parent with priority on uncaught exception
|
45
|
+
- Fix race condition in `Mutex#synchronize` (#41)
|
41
46
|
|
42
47
|
## 0.45.4
|
43
48
|
|
44
|
-
|
49
|
+
- Improve signal trapping mechanism
|
45
50
|
|
46
51
|
## 0.45.3
|
47
52
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
53
|
+
- Don't swallow error in `Process#kill_and_await`
|
54
|
+
- Add `Fiber#mailbox` attribute reader
|
55
|
+
- Fix bug in `Fiber.await`
|
56
|
+
- Implement `IO#getc`, `IO#getbyte`
|
52
57
|
|
53
58
|
## 0.45.2
|
54
59
|
|
55
|
-
|
60
|
+
- Rewrite `Fiber#<<`, `Fiber#await`, `Fiber#receive` in C
|
56
61
|
|
57
62
|
## 0.45.1
|
58
63
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
64
|
+
- Fix Net::HTTP compatibility
|
65
|
+
- Fix fs adapter
|
66
|
+
- Improve performance of IO#puts
|
67
|
+
- Mutex#synchronize
|
68
|
+
- Fix Socket#connect
|
69
|
+
- Cleanup code
|
70
|
+
- Improve support for Ruby 3 keyword args
|
66
71
|
|
67
72
|
## 0.45.0
|
68
73
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
74
|
+
- Cleanup code
|
75
|
+
- Rename `Agent` to `Backend`
|
76
|
+
- Implement `Polyphony::ConditionVariable`
|
77
|
+
- Fix Kernel.system
|
73
78
|
|
74
79
|
## 0.44.0 2020-07-25
|
75
80
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
+
- Fix reentrant `ResourcePool` (#38)
|
82
|
+
- Add `ResourcePool#discard!` (#35)
|
83
|
+
- Add `Mysql2::Client` and `Sequel::ConnectionPool` adapters (#35)
|
84
|
+
- Reimplement `Kernel.trap` using `Fiber#interject`
|
85
|
+
- Add `Fiber#interject` for running arbitrary code on arbitrary fibers (#39)
|
81
86
|
|
82
87
|
## 0.43.11 2020-07-24
|
83
88
|
|
84
|
-
|
85
|
-
|
89
|
+
- Dump uncaught exception info for forked process (#36)
|
90
|
+
- Add additional socket config options (#37)
|
86
91
|
- :reuse_port (`SO_REUSEPORT`)
|
87
92
|
- :backlog (listen backlog, default `SOMAXCONN`)
|
88
|
-
|
93
|
+
- Fix possible race condition in Queue#shift (#34)
|
89
94
|
|
90
95
|
## 0.43.10 2020-07-23
|
91
96
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
97
|
+
- Fix race condition when terminating fibers (#33)
|
98
|
+
- Fix lock release in `Mutex` (#32)
|
99
|
+
- Virtualize agent interface
|
100
|
+
- Implement `LibevAgent_connect`
|
96
101
|
|
97
102
|
## 0.43.9 2020-07-22
|
98
103
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
+
- Rewrite `Channel` using `Queue`
|
105
|
+
- Rewrite `Mutex` using `Queue`
|
106
|
+
- Reimplement `Event` in C to prevent cross-thread race condition
|
107
|
+
- Reimplement `ResourcePool` using `Queue`
|
108
|
+
- Implement `Queue#size`
|
104
109
|
|
105
110
|
## 0.43.8 2020-07-21
|
106
111
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
+
- Rename `LibevQueue` to `Queue`
|
113
|
+
- Reimplement Event using `Agent#wait_event`
|
114
|
+
- Improve Queue shift queue performance
|
115
|
+
- Introduce `Agent#wait_event` API for waiting on asynchronous events
|
116
|
+
- Minimize `fcntl` syscalls in IO operations
|
112
117
|
|
113
118
|
## 0.43.7 2020-07-20
|
114
119
|
|
115
|
-
|
116
|
-
|
117
|
-
|
120
|
+
- Fix memory leak in ResourcePool (#31)
|
121
|
+
- Check and adjust file position before reading (#30)
|
122
|
+
- Minor documentation fixes
|
118
123
|
|
119
124
|
## 0.43.6 2020-07-18
|
120
125
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
+
- Allow brute-force interrupting with second Ctrl-C
|
127
|
+
- Fix outgoing SSL connections (#28)
|
128
|
+
- Improve Fiber#await_all_children with many children
|
129
|
+
- Use `writev` for writing multiple strings
|
130
|
+
- Add logo (thanks [Gerald](https://webocube.com/)!)
|
126
131
|
|
127
132
|
## 0.43.5 2020-07-13
|
128
133
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
+
- Fix `#read_nonblock`, `#write_nonblock` for `IO` and `Socket` (#27)
|
135
|
+
- Patch `Kernel#p`, `IO#puts` to issue single write call
|
136
|
+
- Add support for multiple arguments in `IO#write` and `LibevAgent#write`
|
137
|
+
- Use LibevQueue for fiber run queue
|
138
|
+
- Reimplement LibevQueue as ring buffer
|
134
139
|
|
135
140
|
## 0.43.4 2020-07-09
|
136
141
|
|
137
|
-
|
138
|
-
|
139
|
-
|
142
|
+
- Reimplement Kernel#trap
|
143
|
+
- Dynamically allocate read buffer if length not given (#23)
|
144
|
+
- Prevent CPU saturation on infinite sleep (#24)
|
140
145
|
|
141
146
|
## 0.43.3 2020-07-08
|
142
147
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
148
|
+
- Fix behaviour after call to `Process.daemon` (#8)
|
149
|
+
- Replace core `Queue` class with `Polyphony::Queue` (#22)
|
150
|
+
- Make `ResourcePool` reentrant (#1)
|
151
|
+
- Accept `:with_exception` argument in `cancel_after` (#16)
|
147
152
|
|
148
153
|
## 0.43.2 2020-07-07
|
149
154
|
|
150
|
-
|
155
|
+
- Fix sending Redis commands with array arguments (#21)
|
151
156
|
|
152
157
|
## 0.43.1 2020-06
|
153
158
|
|
154
|
-
|
159
|
+
- Fix compiling C-extension on MacOS (#20)
|
155
160
|
|
156
161
|
## 0.43 2020-07-05
|
157
162
|
|
158
|
-
|
159
|
-
|
160
|
-
|
163
|
+
- Add IO#read_loop
|
164
|
+
- Fix OpenSSL extension
|
165
|
+
- More work on docs
|
161
166
|
|
162
167
|
## 0.42 2020-07-03
|
163
168
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
169
|
+
- Improve documentation
|
170
|
+
- Fix backtrace on SIGINT
|
171
|
+
- Implement LibevAgent#accept_loop, #read_loop
|
172
|
+
- Move ref counting from thread to agent
|
173
|
+
- Short circuit switchpoint if continuing with the same fiber
|
174
|
+
- Always do a switchpoint in #read, #write, #accept
|
170
175
|
|
171
176
|
## 0.41 2020-06-27
|
172
177
|
|
173
|
-
|
178
|
+
- Introduce System Agent design, remove all `Gyro` classes
|
174
179
|
|
175
180
|
## 0.40 2020-05-04
|
176
181
|
|
177
|
-
|
182
|
+
- More improvements to stability after fork
|
178
183
|
|
179
184
|
## 0.38 2020-04-13
|
180
185
|
|
181
|
-
|
186
|
+
- Fix post-fork segfault if parent process has multiple threads with active watchers
|
182
187
|
|
183
188
|
## 0.37 2020-04-07
|
184
189
|
|
185
|
-
|
186
|
-
|
190
|
+
- Explicitly kill threads on exit to prevent possible segfault
|
191
|
+
- Remove Modulation dependency
|
187
192
|
|
188
193
|
## 0.36 2020-03-31
|
189
194
|
|
190
|
-
|
191
|
-
|
192
|
-
|
195
|
+
- More docs
|
196
|
+
- More C code refactoring
|
197
|
+
- Fix freeing for active child, signal watchers
|
193
198
|
|
194
199
|
## 0.35 2020-03-29
|
195
200
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
+
- Rename `Fiber#cancel!` to `Fiber#cancel`
|
202
|
+
- Rename `Gyro::Async#signal!` to `Gyro::Async#signal`
|
203
|
+
- Use `Fiber#auto_watcher` in thread pool, thread extension
|
204
|
+
- Implement `Fiber#auto_io` for reusing IO watcher instances
|
205
|
+
- Refactor C code
|
201
206
|
|
202
207
|
## 0.34 2020-03-25
|
203
208
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
209
|
+
- Add `Fiber#auto_watcher` mainly for use in places like `Gyro::Queue#shift`
|
210
|
+
- Refactor C extension
|
211
|
+
- Improved GC'ing for watchers
|
212
|
+
- Implement process supervisor (`Polyphony::ProcessSupervisor`)
|
213
|
+
- Improve fiber supervision
|
214
|
+
- Fix forking behaviour
|
215
|
+
- Use correct backtrace for fiber control exceptions
|
216
|
+
- Allow calling `move_on_after` and `cancel_after` without block
|
212
217
|
|
213
218
|
## 0.33 2020-03-08
|
214
219
|
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
220
|
+
- Implement `Fiber#supervise` (WIP)
|
221
|
+
- Add `Fiber#restart` API
|
222
|
+
- Fix race condition in `Thread#join`, `Thread#raise` (#14)
|
223
|
+
- Add `Exception#source_fiber` - references the fiber in which an uncaught
|
219
224
|
exception occurred
|
220
225
|
|
221
226
|
## 0.32 2020-02-29
|
222
227
|
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
228
|
+
- Accept optional throttling rate in `#spin_loop`
|
229
|
+
- Remove CancelScope
|
230
|
+
- Allow spinning fibers from a parent fiber other than the current
|
231
|
+
- Add `#receive_pending` global API.
|
232
|
+
- Prevent race condition in `Gyro::Queue`.
|
233
|
+
- Improve signal handling - `INT`, `TERM` signals are now always handled in the
|
229
234
|
main fiber
|
230
|
-
|
235
|
+
- Fix adapter requires (redis and postgres)
|
231
236
|
|
232
237
|
## 0.31 2020-02-20
|
233
238
|
|
234
|
-
|
235
|
-
|
236
|
-
|
239
|
+
- Fix signal handling race condition (#13)
|
240
|
+
- Move adapter code into polyphony/adapters
|
241
|
+
- Fix spin_loop caller, add tag parameter
|
237
242
|
|
238
243
|
## 0.30 2020-02-04
|
239
244
|
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
245
|
+
- Add support for awaiting a fiber from multiple monitor fibers at once
|
246
|
+
- Implemented child fibers
|
247
|
+
- Fix TERM and INT signal handling (#11)
|
248
|
+
- Fix compiling on Linux
|
249
|
+
- Do not reset runnable value in Gyro_suspend (prevents interrupting timers)
|
250
|
+
- Don't snooze when stopping a fiber
|
251
|
+
- Fix IO#read for files larger than 8KB (#10)
|
252
|
+
- Fix fiber messaging in main fiber
|
253
|
+
- Prevent signalling of inactive async watcher
|
254
|
+
- Better fiber messaging
|
250
255
|
|
251
256
|
## 0.29 2020-02-02
|
252
257
|
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
258
|
+
- Pass SignalException to main fiber
|
259
|
+
- Add (restore) default thread pool
|
260
|
+
- Prevent race condition in Thread#join
|
261
|
+
- Add support for cross-thread fiber scheduling
|
262
|
+
- Remove `#defer` global method
|
263
|
+
- Prevent starvation of waiting fibers when using snooze (#7)
|
264
|
+
- Improve tracing
|
265
|
+
- Fix IRB adapter
|
261
266
|
|
262
267
|
## 0.28 2020-01-27
|
263
268
|
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
269
|
+
- Accept block in Supervisor#initialize
|
270
|
+
- Refactor `ThreadPool`
|
271
|
+
- Implement fiber switch events for `TracePoint`
|
272
|
+
- Add optional tag parameter to #spin
|
273
|
+
- Correctly increment ref count for indefinite sleep
|
274
|
+
- Add `irb` adapter
|
275
|
+
- Add support for listen/notify to postgres adapter
|
276
|
+
- Use `:waiting`, `:runnable`, `:running`, `:dead` for fiber states
|
277
|
+
- Move docs to https://digital-fabric.github.io/polyphony/
|
273
278
|
|
274
279
|
## 0.27 2020-01-19
|
275
280
|
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
281
|
+
- Reimplement `Throttler` using recurring timer
|
282
|
+
- Add `Gyro::Selector` for wrapping libev
|
283
|
+
- Add `Gyro::Queue`, a fiber-aware thread-safe queue
|
284
|
+
- Implement multithreaded fiber scheduling
|
280
285
|
|
281
286
|
## 0.26 2020-01-12
|
282
287
|
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
288
|
+
- Optimize `IO#read_watcher`, `IO#write_watcher`
|
289
|
+
- Implement `Fiber#raise`
|
290
|
+
- Fix `Kernel#gets` with `ARGV`
|
291
|
+
- Return `[pid, exit_status]` from `Gyro::Child#await`
|
287
292
|
|
288
293
|
## 0.25 2020-01-10
|
289
294
|
|
290
|
-
|
291
|
-
|
295
|
+
- Fold `Coprocess` functionality into `Fiber`
|
296
|
+
- Add support for indefinite `#sleep`
|
292
297
|
|
293
298
|
## 0.24 2020-01-08
|
294
299
|
|
295
|
-
|
296
|
-
|
297
|
-
|
300
|
+
- Extract HTTP code into separate polyphony-http gem
|
301
|
+
- Cull core, io examples
|
302
|
+
- Remove `SIGINT` handler
|
298
303
|
|
299
304
|
## 0.23 2020-01-07
|
300
305
|
|
301
|
-
|
302
|
-
|
303
|
-
|
306
|
+
- Remove `API#pulse`
|
307
|
+
- Better repeat timer, reimplement `API#every`
|
308
|
+
- Move global API methods to separate module, include in `Object` instead of
|
304
309
|
`Kernel`
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
310
|
+
- Improve setting root fiber and corresponding coprocess
|
311
|
+
- Fix `ResourcePool#preheat!`
|
312
|
+
- Rename `$Coprocess#list` to `Coprocess#map`
|
313
|
+
- Fix `CancelScope#on_cancel`, remove `CancelScope#protect`
|
314
|
+
- Remove `auto_run` mechanism. Just use `suspend`!
|
315
|
+
- Optional coverage report for tests
|
316
|
+
- More tests
|
317
|
+
- Add `Coprocess.select` and `Supervisor#select` methods
|
318
|
+
- Add `Coprocess.join` alias to `Coprocess.await` method
|
319
|
+
- Add support for cancelling multiple coprocesses with a single cancel scope
|
320
|
+
- Fix stopping a coprocess before it being scheduled for the first time
|
321
|
+
- Rewrite `thread`, `thread_pool` modules
|
322
|
+
- Add `Kernel#orig_sleep` alias to sync `#sleep` method
|
323
|
+
- Add optional resume value to `Gyro::Async#signal!`
|
324
|
+
- Patch Fiber#inspect to show correct block location
|
325
|
+
- Add Gyro.run
|
326
|
+
- Move away from callback-based API for `Gyro::Timer`, `Gyro::Signal`
|
322
327
|
|
323
328
|
## 0.22 2020-01-02
|
324
329
|
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
330
|
+
- Redesign Gyro scheduling subsystem, go scheduler-less
|
331
|
+
- More docs
|
332
|
+
- Rewrite HTTP client agent c1b63787
|
333
|
+
- Increment Gyro refcount in ResourcePool#acquire
|
334
|
+
- Rewrite ResourcePool
|
335
|
+
- Fix socket extensions
|
336
|
+
- Fix ALPN setup in Net.secure_socket
|
332
337
|
|
333
338
|
## 0.21 2019-12-12
|
334
339
|
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
340
|
+
- Add Coprocess.await (for waiting for multiple coprocesses)
|
341
|
+
- Add Coprocess#caller, Coprocess#location methods
|
342
|
+
- Remove callback-oriented Gyro APIs
|
343
|
+
- Revise signal handling API
|
344
|
+
- Improve error handling in HTTP/2 adapter
|
345
|
+
- More documentation
|
341
346
|
|
342
347
|
## 0.20 2019-11-27
|
343
348
|
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
349
|
+
- Refactor and improve CancelScope, ResourcePool
|
350
|
+
- Reimplement cancel_after, move_on_after using plain timers
|
351
|
+
- Use Timer#await instead of Timer#start in Pulser
|
352
|
+
- Rename Fiber.main to Fiber.root
|
353
|
+
- Replace use of defer with proper fiber scheduling
|
354
|
+
- Improve Coprocess resume, interrupt, cancel methods
|
355
|
+
- Cleanup code using Rubocop
|
356
|
+
- Update and cleanup examples
|
357
|
+
- Remove fiber pool
|
358
|
+
- Rename `CoprocessInterrupt` to `Interrupt`
|
359
|
+
- Fix ResourcePool, Mutex, Thread, ThreadPool
|
360
|
+
- Fix coprocess message passing behaviour
|
361
|
+
- Add HTTP::Request#consume API
|
362
|
+
- Use bundler 2.x
|
363
|
+
- Remove separate parse loop fiber in HTTP 1, HTTP 2 adapters
|
364
|
+
- Fix handling of exceptions in coprocesses
|
365
|
+
- Implement synthetic, sanitized exception backtrace showing control flow across
|
361
366
|
fibers
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
+
- Fix channels
|
368
|
+
- Fix HTTP1 connection shutdown and error states
|
369
|
+
- Workaround for IO#read without length
|
370
|
+
- Rename `next_tick` to `defer`
|
371
|
+
- Fix race condition in firing of deferred items, use linked list instead of
|
367
372
|
array for deferred items
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
373
|
+
- Rename `EV` module to `Gyro`
|
374
|
+
- Keep track of main fiber when forking
|
375
|
+
- Add `<<` alias for `send_chunk` in HTTP::Request
|
376
|
+
- Implement Socket#accept in C
|
377
|
+
- Better conformance of rack adapter to rack spec (WIP)
|
378
|
+
- Fix HTTP1 adapter
|
379
|
+
- Better support for debugging with ruby-debug-ide (WIP)
|
375
380
|
|
376
381
|
## 0.19 2019-06-12
|
377
382
|
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
+
- Rewrite HTTP server for better concurrency, sequential API
|
384
|
+
- Support 204 no-content response in HTTP 1
|
385
|
+
- Add optional count parameter to Kernel#throttled_loop for finite looping
|
386
|
+
- Implement Fiber#safe_transfer in C
|
387
|
+
- Optimize Kernel#next_tick implementation using ev_idle instead of ev_timer
|
383
388
|
|
384
389
|
## 0.18 2019-06-08
|
385
390
|
|
386
|
-
|
387
|
-
|
391
|
+
- Rename Kernel#coproc to Kernel#spin
|
392
|
+
- Rewrite Supervisor#spin
|
388
393
|
|
389
394
|
## 0.17 2019-05-24
|
390
395
|
|
391
|
-
|
392
|
-
|
396
|
+
- Implement IO#read_watcher, IO#write_watcher in C for better performance
|
397
|
+
- Implement nonblocking (yielding) versions of Kernel#system, IO.popen,
|
393
398
|
Process.detach, IO#gets IO#puts, other IO singleton methods
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
399
|
+
- Add Coprocess#join as alias to Coprocess#await
|
400
|
+
- Rename Kernel#spawn to Kernel#coproc
|
401
|
+
- Fix encoding of strings read with IO#read, IO#readpartial
|
402
|
+
- Fix non-blocking behaviour of IO#read, IO#readpartial, IO#write
|
398
403
|
|
399
404
|
## 0.16 2019-05-22
|
400
405
|
|
401
|
-
|
402
|
-
|
406
|
+
- Reorganize and refactor code
|
407
|
+
- Allow opening secure socket without OpenSSL context
|
403
408
|
|
404
409
|
## 0.15 2019-05-20
|
405
410
|
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
+
- Optimize `#next_tick` callback (about 6% faster than before)
|
412
|
+
- Fix IO#<< to return self
|
413
|
+
- Refactor HTTP code and examples
|
414
|
+
- Fix race condition in `Supervisor#stop!`
|
415
|
+
- Add `Kernel#snooze` method (`EV.snooze` will be deprecated eventually)
|
411
416
|
|
412
417
|
## 0.14 2019-05-17
|
413
418
|
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
419
|
+
- Use chunked encoding in HTTP 1 response
|
420
|
+
- Rewrite `IO#read`, `#readpartial`, `#write` in C (about 30% performance improvement)
|
421
|
+
- Add method delegation to `ResourcePool`
|
422
|
+
- Optimize PG::Connection#async_exec
|
423
|
+
- Fix `Coprocess#cancel!`
|
424
|
+
- Preliminary support for websocket (see `examples/io/http_ws_server.rb`)
|
425
|
+
- Rename `Coroutine` to `Coprocess`
|
421
426
|
|
422
427
|
## 0.13 2019-01-05
|
423
428
|
|
424
|
-
|
429
|
+
- Rename Rubato to Polyphony (I know, this is getting silly...)
|
425
430
|
|
426
431
|
## 0.12 2019-01-01
|
427
432
|
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
433
|
+
- Add Coroutine#resume
|
434
|
+
- Improve startup time
|
435
|
+
- Accept rate: or interval: arguments for throttle
|
436
|
+
- Set correct backtrace for errors
|
437
|
+
- Improve handling of uncaught raised errors
|
438
|
+
- Implement HTTP 1.1/2 client agent with connection management
|
434
439
|
|
435
440
|
## 0.11 2018-12-27
|
436
441
|
|
437
|
-
|
442
|
+
- Move reactor loop to secondary fiber, allow blocking operations on main
|
438
443
|
fiber.
|
439
|
-
|
444
|
+
- Example implementation of erlang-style generic server pattern (implement async
|
440
445
|
API to a coroutine)
|
441
|
-
|
446
|
+
- Implement coroutine mailboxes, Coroutine#<<, Coroutine#receive, Kernel.receive
|
442
447
|
for message passing
|
443
|
-
|
448
|
+
- Add Coroutine.current for getting current coroutine
|
444
449
|
|
445
450
|
## 0.10 2018-11-20
|
446
451
|
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
452
|
+
- Rewrite Rubato core for simpler code and better performance
|
453
|
+
- Implement EV.snooze (sleep until next tick)
|
454
|
+
- Coroutine encapsulates a task spawned on a separate fiber
|
455
|
+
- Supervisor supervises multiple coroutines
|
456
|
+
- CancelScope used to cancel an ongoing task (usually with a timeout)
|
457
|
+
- Rate throttling
|
458
|
+
- Implement async SSL server
|
454
459
|
|
455
460
|
## 0.9 2018-11-14
|
456
461
|
|
457
|
-
|
462
|
+
- Rename Nuclear to Rubato
|
458
463
|
|
459
464
|
## 0.8 2018-10-04
|
460
465
|
|
461
|
-
|
466
|
+
- Replace nio4r with in-house extension based on libev, with better API,
|
462
467
|
better performance, support for IO, timer, signal and async watchers
|
463
|
-
|
468
|
+
- Fix mem leak coming from nio4r (probably related to code in Selector#select)
|
464
469
|
|
465
470
|
## 0.7 2018-09-13
|
466
471
|
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
472
|
+
- Implement resource pool
|
473
|
+
- transaction method for pg cient
|
474
|
+
- Async connect for pg client
|
475
|
+
- Add testing module for testing async code
|
476
|
+
- Improve HTTP server performance
|
477
|
+
- Proper promise chaining
|
473
478
|
|
474
479
|
## 0.6 2018-09-11
|
475
480
|
|
476
|
-
|
477
|
-
|
481
|
+
- Add http, redis, pg dependencies
|
482
|
+
- Move ALPN code inside net module
|
478
483
|
|
479
484
|
## 0.4 2018-09-10
|
480
485
|
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
486
|
+
- Code refactored and reogranized
|
487
|
+
- Fix recursion in next_tick
|
488
|
+
- HTTP 2 server with support for ALPN protocol negotiation and HTTP upgrade
|
489
|
+
- OpenSSL server
|
485
490
|
|
486
491
|
## 0.3 2018-09-06
|
487
492
|
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
493
|
+
- Event reactor
|
494
|
+
- Timers
|
495
|
+
- Promises
|
496
|
+
- async/await syntax for promises
|
497
|
+
- IO and read/write stream
|
498
|
+
- TCP server/client
|
499
|
+
- Promised threads
|
500
|
+
- HTTP server
|
501
|
+
- Redis interface
|
502
|
+
- PostgreSQL interface
|
data/Gemfile.lock
CHANGED
data/TODO.md
CHANGED
@@ -1,17 +1,13 @@
|
|
1
1
|
- Graceful shutdown again:
|
2
2
|
|
3
|
-
- Add `Polyphony::GracefulShutdown` exception
|
4
|
-
- Two exceptions for stopping fibers:
|
5
|
-
- `Polyphony::GracefulShutdown` - graceful shutdown
|
6
|
-
- `Polyphony::Terminate` - ungraceful shutdown
|
7
3
|
- Fiber API:
|
8
|
-
- `Fiber#
|
9
|
-
- `Fiber#
|
4
|
+
- `Fiber#terminate(graceul)` - with a graceful flag
|
5
|
+
- `Fiber#terminate_all_children(graceful)` - with a graceful flag
|
6
|
+
- `Fiber#shutdown_all_children(graceful)` - with a graceful flag
|
10
7
|
|
8
|
+
- Set graceful termination in `@graceful_shutdown`
|
11
9
|
- Add `Fiber#graceful_shutdown?` method
|
12
|
-
- Returns
|
13
|
-
- Override `Polyphony::Terminate#invoke` to reset the `@graceful_shutdown` fiber
|
14
|
-
flag
|
10
|
+
- Returns `@graceful_shutdown`
|
15
11
|
|
16
12
|
And then we have:
|
17
13
|
|
@@ -19,15 +15,11 @@
|
|
19
15
|
spin do
|
20
16
|
loop { do_some_stuff }
|
21
17
|
ensure
|
22
|
-
|
23
|
-
|
24
|
-
shutdown_gracefully
|
18
|
+
shutdown_gracefully if Fiber.current.graceful_shutdown?
|
25
19
|
end
|
26
20
|
```
|
27
21
|
|
28
|
-
-
|
29
|
-
fibers, *unless* it was stopped with a `Polyphony::GracefulShutdown` (which it
|
30
|
-
can check with `@graceful_shutdown`).
|
22
|
+
- `Fiber#finalize_children` should pass graceful shutdown flag to children
|
31
23
|
|
32
24
|
- More tight loops
|
33
25
|
- IO#gets_loop, Socket#gets_loop, OpenSSL::Socket#gets_loop (medium effort)
|
@@ -37,13 +29,13 @@
|
|
37
29
|
|
38
30
|
- check integration with rb-inotify
|
39
31
|
|
40
|
-
-
|
32
|
+
- Improve `#supervise`. It does not work as advertised, and seems to exhibit an
|
33
|
+
inconsistent behaviour (see supervisor example).
|
34
|
+
|
41
35
|
- Add test that mimics the original design for Monocrono:
|
42
36
|
- 256 fibers each waiting for a message
|
43
37
|
- When message received do some blocking work using a `ThreadPool`
|
44
38
|
- Send messages, collect responses, check for correctness
|
45
|
-
- Improve `#supervise`. It does not work as advertised, and seems to exhibit an
|
46
|
-
inconsistent behaviour (see supervisor example).
|
47
39
|
|
48
40
|
- io_uring
|
49
41
|
- Use playground.c to find out why we when submitting and waiting for
|
data/examples/core/supervisor.rb
CHANGED
@@ -9,9 +9,9 @@ def my_sleep(t)
|
|
9
9
|
puts "#{t} done"
|
10
10
|
end
|
11
11
|
|
12
|
-
spin { my_sleep(1) }
|
13
|
-
spin { my_sleep(2) }
|
14
|
-
spin { my_sleep(3) }
|
12
|
+
spin { my_sleep(0.1) }
|
13
|
+
spin { my_sleep(0.2) }
|
14
|
+
spin { my_sleep(0.3) }
|
15
15
|
spin { puts "fiber count: #{Fiber.current.children.count}" }
|
16
16
|
snooze
|
17
17
|
|
@@ -13,11 +13,9 @@ end
|
|
13
13
|
$worker = Thread.new do
|
14
14
|
Fiber.current.tag = :worker
|
15
15
|
loop do
|
16
|
-
client, block = receive
|
16
|
+
(client, block) = receive
|
17
17
|
do_work(client, &block)
|
18
18
|
end
|
19
|
-
rescue Exception => e
|
20
|
-
p e
|
21
19
|
end
|
22
20
|
|
23
21
|
def process(&block)
|
@@ -27,4 +25,5 @@ end
|
|
27
25
|
|
28
26
|
sleep 0.1
|
29
27
|
|
30
|
-
p process { 1 + 1 }
|
28
|
+
p process { 1 + 1 }
|
29
|
+
p process { 42 ** 2 }
|
@@ -3,26 +3,6 @@
|
|
3
3
|
#include "ruby.h"
|
4
4
|
#include "ruby/io.h"
|
5
5
|
|
6
|
-
VALUE cTCPSocket;
|
7
|
-
VALUE cTCPServer;
|
8
|
-
VALUE cUNIXSocket;
|
9
|
-
VALUE cUNIXServer;
|
10
|
-
|
11
|
-
void Init_SocketClasses() {
|
12
|
-
rb_require("socket");
|
13
|
-
cTCPSocket = rb_const_get(rb_cObject, rb_intern("TCPSocket"));
|
14
|
-
cTCPServer = rb_const_get(rb_cObject, rb_intern("TCPServer"));
|
15
|
-
cUNIXSocket = rb_const_get(rb_cObject, rb_intern("UNIXSocket"));
|
16
|
-
cUNIXServer = rb_const_get(rb_cObject, rb_intern("UNIXServer"));
|
17
|
-
}
|
18
|
-
|
19
|
-
VALUE ConnectionSocketClass(VALUE server) {
|
20
|
-
if (RTEST(rb_obj_is_kind_of(server, cTCPServer))) return cTCPSocket;
|
21
|
-
if (RTEST(rb_obj_is_kind_of(server, cUNIXServer))) return cUNIXSocket;
|
22
|
-
|
23
|
-
rb_raise(rb_eRuntimeError, "Invalid server class");
|
24
|
-
}
|
25
|
-
|
26
6
|
//////////////////////////////////////////////////////////////////////
|
27
7
|
//////////////////////////////////////////////////////////////////////
|
28
8
|
// the following is copied verbatim from the Ruby source code (io.c)
|
@@ -668,12 +668,11 @@ VALUE Backend_send(VALUE self, VALUE io, VALUE str) {
|
|
668
668
|
return INT2NUM(len);
|
669
669
|
}
|
670
670
|
|
671
|
-
VALUE io_uring_backend_accept(Backend_t *backend, VALUE server_socket, int loop) {
|
671
|
+
VALUE io_uring_backend_accept(Backend_t *backend, VALUE server_socket, VALUE socket_class, int loop) {
|
672
672
|
rb_io_t *fptr;
|
673
673
|
struct sockaddr addr;
|
674
674
|
socklen_t len = (socklen_t)sizeof addr;
|
675
675
|
VALUE socket = Qnil;
|
676
|
-
VALUE socket_class = ConnectionSocketClass(server_socket);
|
677
676
|
VALUE underlying_sock = rb_ivar_get(server_socket, ID_ivar_io);
|
678
677
|
if (underlying_sock != Qnil) server_socket = underlying_sock;
|
679
678
|
|
@@ -718,16 +717,16 @@ VALUE io_uring_backend_accept(Backend_t *backend, VALUE server_socket, int loop)
|
|
718
717
|
return Qnil;
|
719
718
|
}
|
720
719
|
|
721
|
-
VALUE Backend_accept(VALUE self, VALUE
|
720
|
+
VALUE Backend_accept(VALUE self, VALUE server_socket, VALUE socket_class) {
|
722
721
|
Backend_t *backend;
|
723
722
|
GetBackend(self, backend);
|
724
|
-
return io_uring_backend_accept(backend,
|
723
|
+
return io_uring_backend_accept(backend, server_socket, socket_class, 0);
|
725
724
|
}
|
726
725
|
|
727
|
-
VALUE Backend_accept_loop(VALUE self, VALUE
|
726
|
+
VALUE Backend_accept_loop(VALUE self, VALUE server_socket, VALUE socket_class) {
|
728
727
|
Backend_t *backend;
|
729
728
|
GetBackend(self, backend);
|
730
|
-
io_uring_backend_accept(backend,
|
729
|
+
io_uring_backend_accept(backend, server_socket, socket_class, 1);
|
731
730
|
return self;
|
732
731
|
}
|
733
732
|
|
@@ -945,8 +944,6 @@ VALUE Backend_kind(VALUE self) {
|
|
945
944
|
}
|
946
945
|
|
947
946
|
void Init_Backend() {
|
948
|
-
Init_SocketClasses();
|
949
|
-
|
950
947
|
VALUE cBackend = rb_define_class_under(mPolyphony, "Backend", rb_cData);
|
951
948
|
rb_define_alloc_func(cBackend, Backend_allocate);
|
952
949
|
|
@@ -967,8 +964,8 @@ void Init_Backend() {
|
|
967
964
|
rb_define_method(cBackend, "recv", Backend_recv, 3);
|
968
965
|
rb_define_method(cBackend, "recv_loop", Backend_recv_loop, 1);
|
969
966
|
rb_define_method(cBackend, "send", Backend_send, 2);
|
970
|
-
rb_define_method(cBackend, "accept", Backend_accept,
|
971
|
-
rb_define_method(cBackend, "accept_loop", Backend_accept_loop,
|
967
|
+
rb_define_method(cBackend, "accept", Backend_accept, 2);
|
968
|
+
rb_define_method(cBackend, "accept_loop", Backend_accept_loop, 2);
|
972
969
|
rb_define_method(cBackend, "connect", Backend_connect, 3);
|
973
970
|
rb_define_method(cBackend, "wait_io", Backend_wait_io, 2);
|
974
971
|
rb_define_method(cBackend, "sleep", Backend_sleep, 1);
|
@@ -493,7 +493,7 @@ VALUE Backend_write_m(int argc, VALUE *argv, VALUE self) {
|
|
493
493
|
Backend_writev(self, argv[0], argc - 1, argv + 1);
|
494
494
|
}
|
495
495
|
|
496
|
-
VALUE Backend_accept(VALUE self, VALUE server_socket) {
|
496
|
+
VALUE Backend_accept(VALUE self, VALUE server_socket, VALUE socket_class) {
|
497
497
|
Backend_t *backend;
|
498
498
|
struct libev_io watcher;
|
499
499
|
rb_io_t *fptr;
|
@@ -501,7 +501,6 @@ VALUE Backend_accept(VALUE self, VALUE server_socket) {
|
|
501
501
|
struct sockaddr addr;
|
502
502
|
socklen_t len = (socklen_t)sizeof addr;
|
503
503
|
VALUE switchpoint_result = Qnil;
|
504
|
-
VALUE socket_class = ConnectionSocketClass(server_socket);
|
505
504
|
VALUE underlying_sock = rb_ivar_get(server_socket, ID_ivar_io);
|
506
505
|
if (underlying_sock != Qnil) server_socket = underlying_sock;
|
507
506
|
|
@@ -550,7 +549,7 @@ error:
|
|
550
549
|
return RAISE_EXCEPTION(switchpoint_result);
|
551
550
|
}
|
552
551
|
|
553
|
-
VALUE Backend_accept_loop(VALUE self, VALUE server_socket) {
|
552
|
+
VALUE Backend_accept_loop(VALUE self, VALUE server_socket, VALUE socket_class) {
|
554
553
|
Backend_t *backend;
|
555
554
|
struct libev_io watcher;
|
556
555
|
rb_io_t *fptr;
|
@@ -559,7 +558,6 @@ VALUE Backend_accept_loop(VALUE self, VALUE server_socket) {
|
|
559
558
|
socklen_t len = (socklen_t)sizeof addr;
|
560
559
|
VALUE switchpoint_result = Qnil;
|
561
560
|
VALUE socket = Qnil;
|
562
|
-
VALUE socket_class = ConnectionSocketClass(server_socket);
|
563
561
|
VALUE underlying_sock = rb_ivar_get(server_socket, ID_ivar_io);
|
564
562
|
if (underlying_sock != Qnil) server_socket = underlying_sock;
|
565
563
|
|
@@ -850,8 +848,6 @@ VALUE Backend_kind(VALUE self) {
|
|
850
848
|
void Init_Backend() {
|
851
849
|
ev_set_allocator(xrealloc);
|
852
850
|
|
853
|
-
Init_SocketClasses();
|
854
|
-
|
855
851
|
VALUE cBackend = rb_define_class_under(mPolyphony, "Backend", rb_cData);
|
856
852
|
rb_define_alloc_func(cBackend, Backend_allocate);
|
857
853
|
|
@@ -869,8 +865,8 @@ void Init_Backend() {
|
|
869
865
|
rb_define_method(cBackend, "read", Backend_read, 4);
|
870
866
|
rb_define_method(cBackend, "read_loop", Backend_read_loop, 1);
|
871
867
|
rb_define_method(cBackend, "write", Backend_write_m, -1);
|
872
|
-
rb_define_method(cBackend, "accept", Backend_accept,
|
873
|
-
rb_define_method(cBackend, "accept_loop", Backend_accept_loop,
|
868
|
+
rb_define_method(cBackend, "accept", Backend_accept, 2);
|
869
|
+
rb_define_method(cBackend, "accept_loop", Backend_accept_loop, 2);
|
874
870
|
rb_define_method(cBackend, "connect", Backend_connect, 3);
|
875
871
|
rb_define_method(cBackend, "recv", Backend_recv, 3);
|
876
872
|
rb_define_method(cBackend, "recv_loop", Backend_read_loop, 1);
|
@@ -67,19 +67,29 @@ module Polyphony
|
|
67
67
|
self << fiber unless result.is_a?(Exception)
|
68
68
|
end
|
69
69
|
loop { supervise_perform(opts) }
|
70
|
+
rescue Polyphony::MoveOn
|
71
|
+
# generated in #supervise_perform to stop supervisor
|
70
72
|
ensure
|
71
73
|
@on_child_done = nil
|
72
74
|
end
|
73
75
|
|
74
76
|
def supervise_perform(opts)
|
75
77
|
fiber = receive
|
76
|
-
|
78
|
+
if fiber && opts[:restart]
|
79
|
+
restart_fiber(fiber, opts)
|
80
|
+
elsif Fiber.current.children.empty?
|
81
|
+
Fiber.current.stop
|
82
|
+
end
|
77
83
|
rescue Polyphony::Restart
|
78
84
|
restart_all_children
|
79
85
|
rescue Exception => e
|
80
86
|
Kernel.raise e if e.source_fiber.nil? || e.source_fiber == self
|
81
87
|
|
82
|
-
|
88
|
+
if opts[:restart]
|
89
|
+
restart_fiber(e.source_fiber, opts)
|
90
|
+
elsif Fiber.current.children.empty?
|
91
|
+
Fiber.current.stop
|
92
|
+
end
|
83
93
|
end
|
84
94
|
|
85
95
|
def restart_fiber(fiber, opts)
|
@@ -8,7 +8,7 @@ require_relative '../core/thread_pool'
|
|
8
8
|
# Socket overrides (eventually rewritten in C)
|
9
9
|
class ::Socket
|
10
10
|
def accept
|
11
|
-
Thread.current.backend.accept(self)
|
11
|
+
Thread.current.backend.accept(self, TCPSocket)
|
12
12
|
end
|
13
13
|
|
14
14
|
NO_EXCEPTION = { exception: false }.freeze
|
@@ -134,7 +134,7 @@ class ::TCPSocket
|
|
134
134
|
end
|
135
135
|
|
136
136
|
def recv(maxlen, flags = 0, outbuf = nil)
|
137
|
-
Thread.current.backend.recv(self,
|
137
|
+
Thread.current.backend.recv(self, outbuf || +'', maxlen)
|
138
138
|
end
|
139
139
|
|
140
140
|
def recv_loop(&block)
|
@@ -188,11 +188,12 @@ class ::TCPServer
|
|
188
188
|
|
189
189
|
alias_method :orig_accept, :accept
|
190
190
|
def accept
|
191
|
-
@io
|
191
|
+
Thread.current.backend.accept(@io, TCPSocket)
|
192
|
+
# @io.accept
|
192
193
|
end
|
193
194
|
|
194
195
|
def accept_loop(&block)
|
195
|
-
Thread.current.backend.accept_loop(@io, &block)
|
196
|
+
Thread.current.backend.accept_loop(@io, TCPSocket, &block)
|
196
197
|
end
|
197
198
|
|
198
199
|
alias_method :orig_close, :close
|
@@ -204,19 +205,17 @@ end
|
|
204
205
|
class ::UNIXServer
|
205
206
|
alias_method :orig_accept, :accept
|
206
207
|
def accept
|
207
|
-
Thread.current.backend.accept(self)
|
208
|
+
Thread.current.backend.accept(self, UNIXSocket)
|
208
209
|
end
|
209
210
|
|
210
211
|
def accept_loop(&block)
|
211
|
-
Thread.current.backend.accept_loop(self, &block)
|
212
|
+
Thread.current.backend.accept_loop(self, UNIXSocket, &block)
|
212
213
|
end
|
213
|
-
|
214
|
-
|
215
214
|
end
|
216
215
|
|
217
216
|
class ::UNIXSocket
|
218
217
|
def recv(maxlen, flags = 0, outbuf = nil)
|
219
|
-
Thread.current.backend.recv(self,
|
218
|
+
Thread.current.backend.recv(self, outbuf || +'', maxlen)
|
220
219
|
end
|
221
220
|
|
222
221
|
def recv_loop(&block)
|
data/lib/polyphony/version.rb
CHANGED
data/test/test_socket.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'helper'
|
4
|
+
require 'fileutils'
|
4
5
|
|
5
6
|
class SocketTest < MiniTest::Test
|
6
7
|
def setup
|
@@ -24,7 +25,32 @@ class SocketTest < MiniTest::Test
|
|
24
25
|
snooze
|
25
26
|
client = TCPSocket.new('127.0.0.1', port)
|
26
27
|
client.write("1234\n")
|
27
|
-
assert_equal "1234\n", client.
|
28
|
+
assert_equal "1234\n", client.recv(8192)
|
29
|
+
client.close
|
30
|
+
ensure
|
31
|
+
server_fiber&.stop
|
32
|
+
server_fiber&.await
|
33
|
+
server&.close
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_unix_socket
|
37
|
+
path = '/tmp/test_unix_socket'
|
38
|
+
FileUtils.rm(path) rescue nil
|
39
|
+
server = UNIXServer.new(path)
|
40
|
+
server_fiber = spin do
|
41
|
+
server.accept_loop do |socket|
|
42
|
+
spin do
|
43
|
+
while (data = socket.gets(8192))
|
44
|
+
socket << data
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
snooze
|
51
|
+
client = UNIXSocket.new(path)
|
52
|
+
client.write("1234\n")
|
53
|
+
assert_equal "1234\n", client.recv(8192)
|
28
54
|
client.close
|
29
55
|
ensure
|
30
56
|
server_fiber&.stop
|
data/test/test_supervise.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polyphony
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.47.
|
4
|
+
version: 0.47.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sharon Rosner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|