cztop-reactor 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e017a75dd5e337e33e1340e765a2d9a25b4537c2d5ae9416c836e5f29f1f514
4
- data.tar.gz: 015bb511a4955accc92c03f4f94887ca6b3ea7427d3840138053a85e14934661
3
+ metadata.gz: ead3b23a272e3e970d8a951b1eb32ee312076363965fb3d423ac81c9eecf4be6
4
+ data.tar.gz: f9f8024946fee7172468c8716fc87fc3e953e86697f6b568b86f1d08c05306ff
5
5
  SHA512:
6
- metadata.gz: 3ed15bc7f31360a04d4a076af0dc711a2c6d3b42f4711af9eb131eca681d28d66e04e639b766fd95f5acac81a625c2f90e4465817f5b9ed8a5c8b5d18e0086a1
7
- data.tar.gz: ff7d4d53270b16dc0af808f41052557b1810606d60ccac53d8fff99568fd53ca971da6066cefdd7c467b1a0db169cf64be06ed16b23ac3f1b6391b3e929bcece
6
+ metadata.gz: ce8274021e57515e5dcc260f536fe0c4ac9f3adb0e107dfbd4505e1ce2736c4606690eba22be75dabac5d3a0633cad88071cb23e8eb80dcb1606989e86aeb787
7
+ data.tar.gz: a9afef7f4b16eab396785f8c541837586a485f9942f0ad9f8f06cb4f14b75a452e32683ca6561df83477cdc065001d85099e5bc0c7cda9c70f8cbb6e6ac35f95
Binary file
data.tar.gz.sig CHANGED
Binary file
data/ChangeLog CHANGED
@@ -1,223 +1,287 @@
1
+ 2019-05-22 Michael Granger <ged@FaerieMUD.org>
2
+
3
+ @ * History.md:
4
+ | Update history again
5
+ | [1a00e0c967d8] [tip]
6
+ |
7
+ o * Rakefile:
8
+ | Bump minimum ruby version
9
+ | [d381e9bc342d]
10
+ |
11
+ o * lib/cztop/reactor/socket_monitoring.rb:
12
+ | Super to monitor event handler methods if possible
13
+ | [62f6d793708f]
14
+ |
15
+ o * lib/cztop/reactor/signal_handling.rb,
16
+ | spec/cztop/reactor/signal_handling_spec.rb:
17
+ | Fix bug in signal-handler teardown
18
+ | [200c8be89458]
19
+ |
20
+ o * lib/cztop/reactor.rb:
21
+ | Turn on verbose on monitors if $VERBOSE is set
22
+ | [3689a0184718]
23
+ |
24
+ o * .ruby-version:
25
+ | Bump the development ruby version
26
+ | [b3db756e1a01]
27
+ |
28
+ 2019-01-03 Michael Granger <ged@FaerieMUD.org>
29
+
30
+ o * History.md, cztop-reactor.gemspec, lib/cztop/reactor.rb:
31
+ | Bump the minor version, update history
32
+ | [c6f266ae900d]
33
+ |
34
+ 2019-01-02 Michael Granger <ged@FaerieMUD.org>
35
+
36
+ o * lib/cztop/reactor.rb, lib/cztop/reactor/socket_monitoring.rb,
37
+ | spec/cztop/reactor/socket_monitoring_spec.rb:
38
+ | Fix several issues with socket monitoring.
39
+ | [595e1b8a2a91]
40
+ |
41
+ o * certs/ged.pem:
42
+ | Update my gem-signing cert
43
+ | [683e342f5efb]
44
+ |
45
+ 2018-07-31 Michael Granger <ged@FaerieMUD.org>
46
+
47
+ o * lib/cztop/reactor.rb:
48
+ | Add a #sockets_description method to the Reactor.
49
+ | [928e089b35bc]
50
+ |
51
+ o * lib/cztop/reactor/socket_monitoring.rb:
52
+ | Super from the socket monitoring mixin
53
+ | [573d0b865314]
54
+ |
1
55
  2018-07-23 Michael Granger <ged@FaerieMUD.org>
2
56
 
3
- * lib/cztop/reactor/socket_monitoring.rb:
4
- Add socket monitoring methods for delayed and retried connections
5
- [418d608db892] [tip]
6
-
7
- * .hgtags:
8
- Added tag v0.6.0 for changeset f97428feb0e2
9
- [489876542fea]
10
-
11
- * .hgsigs:
12
- Added signature for changeset aea0b1dd1107
13
- [f97428feb0e2] [v0.6.0]
14
-
15
- * History.md, cztop-reactor.gemspec, lib/cztop/reactor.rb:
16
- Bump the minor version, update history.
17
- [aea0b1dd1107]
18
-
19
- * lib/cztop/reactor/socket_monitoring.rb,
20
- spec/cztop/reactor/socket_monitoring_spec.rb:
21
- Fix unfinished socket monitor spec
22
- [39358fbf9896]
23
-
57
+ o * .hgtags:
58
+ | Added tag v0.7.0 for changeset 109e6fb99097
59
+ | [3500fe91f630]
60
+ |
61
+ o * .hgsigs:
62
+ | Added signature for changeset 8f0c402e974e
63
+ | [109e6fb99097] [v0.7.0]
64
+ |
65
+ o * History.md, cztop-reactor.gemspec, lib/cztop/reactor.rb:
66
+ | Bump the minor version, update history.
67
+ | [8f0c402e974e]
68
+ |
69
+ o * lib/cztop/reactor/socket_monitoring.rb:
70
+ | Add socket monitoring methods for delayed and retried connections
71
+ | [418d608db892]
72
+ |
73
+ o * .hgtags:
74
+ | Added tag v0.6.0 for changeset f97428feb0e2
75
+ | [489876542fea]
76
+ |
77
+ o * .hgsigs:
78
+ | Added signature for changeset aea0b1dd1107
79
+ | [f97428feb0e2] [v0.6.0]
80
+ |
81
+ o * History.md, cztop-reactor.gemspec, lib/cztop/reactor.rb:
82
+ | Bump the minor version, update history.
83
+ | [aea0b1dd1107]
84
+ |
85
+ o * lib/cztop/reactor/socket_monitoring.rb,
86
+ | spec/cztop/reactor/socket_monitoring_spec.rb:
87
+ | Fix unfinished socket monitor spec
88
+ | [39358fbf9896]
89
+ |
24
90
  2018-07-21 Michael Granger <ged@FaerieMUD.org>
25
91
 
26
- * Manifest.txt, lib/cztop/reactor/socket_monitoring.rb,
27
- spec/cztop/reactor/socket_monitoring_spec.rb:
28
- Add a socket monitor mixin
29
- [e65cdcbe5f89]
30
-
92
+ o * Manifest.txt, lib/cztop/reactor/socket_monitoring.rb,
93
+ | spec/cztop/reactor/socket_monitoring_spec.rb:
94
+ | Add a socket monitor mixin
95
+ | [e65cdcbe5f89]
96
+ |
31
97
  2018-07-11 Michael Granger <ged@FaerieMUD.org>
32
98
 
33
- * .hgtags:
34
- Added tag v0.5.0 for changeset c82d889b3d2e
35
- [0338a8ab0f8b] [github/master]
36
-
37
- * .hgsigs:
38
- Added signature for changeset c6276b15f479
39
- [c82d889b3d2e] [v0.5.0]
40
-
41
- * History.md, Rakefile, cztop-reactor.gemspec, lib/cztop/reactor.rb:
42
- Bump the minor version, cztop dep, and update History.
43
- [c6276b15f479]
44
-
45
- * cztop-reactor.gemspec, lib/cztop/reactor.rb,
46
- spec/cztop/reactor_spec.rb:
47
- Added methods to pause/resume all timers.
48
- [67cfabefffd2]
49
-
99
+ o * .hgtags:
100
+ | Added tag v0.5.0 for changeset c82d889b3d2e
101
+ | [0338a8ab0f8b]
102
+ |
103
+ o * .hgsigs:
104
+ | Added signature for changeset c6276b15f479
105
+ | [c82d889b3d2e] [v0.5.0]
106
+ |
107
+ o * History.md, Rakefile, cztop-reactor.gemspec, lib/cztop/reactor.rb:
108
+ | Bump the minor version, cztop dep, and update History.
109
+ | [c6276b15f479]
110
+ |
111
+ o * cztop-reactor.gemspec, lib/cztop/reactor.rb,
112
+ | spec/cztop/reactor_spec.rb:
113
+ | Added methods to pause/resume all timers.
114
+ | [67cfabefffd2]
115
+ |
50
116
  2018-06-27 Michael Granger <ged@FaerieMUD.org>
51
117
 
52
- * .hgtags:
53
- Added tag v0.4.0 for changeset 36b814356934
54
- [9e371cd81152]
55
-
56
- * .hgsigs:
57
- Added signature for changeset 4fa4ea9f2a91
58
- [36b814356934] [v0.4.0]
59
-
60
- * History.md, lib/cztop/reactor.rb:
61
- Bump the minor version, update history.
62
- [4fa4ea9f2a91]
63
-
64
- * .ruby-version, lib/cztop/reactor.rb:
65
- Make the reactor threadsafe
66
- [c0beb742a2a2]
67
-
118
+ o * .hgtags:
119
+ | Added tag v0.4.0 for changeset 36b814356934
120
+ | [9e371cd81152]
121
+ |
122
+ o * .hgsigs:
123
+ | Added signature for changeset 4fa4ea9f2a91
124
+ | [36b814356934] [v0.4.0]
125
+ |
126
+ o * History.md, lib/cztop/reactor.rb:
127
+ | Bump the minor version, update history.
128
+ | [4fa4ea9f2a91]
129
+ |
130
+ o * .ruby-version, lib/cztop/reactor.rb:
131
+ | Make the reactor threadsafe
132
+ | [c0beb742a2a2]
133
+ |
68
134
  2018-06-06 Michael Granger <ged@FaerieMUD.org>
69
135
 
70
- * Merged with 33bf1ec41017
71
- [9ca502f040d3]
72
-
136
+ o * Merged with 33bf1ec41017
137
+ |\ [9ca502f040d3]
138
+ | |
139
+ | o * lib/cztop/reactor/signal_handling.rb:
140
+ | | Fix docs and logging in signal handling mixin
141
+ | | [0adc6861a172]
142
+ | |
143
+ | o * lib/cztop/reactor.rb:
144
+ | | Guard against events with no sockets
145
+ | | [749f5de1d5fe]
146
+ | |
147
+ | o * certs/ged.pem:
148
+ | | Update my gem-signing cert
149
+ | | [26089589e937]
150
+ | |
73
151
  2017-11-07 Michael Granger <ged@FaerieMUD.org>
74
152
 
75
- * .ruby-version:
76
- Update to Ruby 2.4
77
- [33bf1ec41017]
78
-
79
- 2018-06-06 Michael Granger <ged@FaerieMUD.org>
80
-
81
- * lib/cztop/reactor/signal_handling.rb:
82
- Fix docs and logging in signal handling mixin
83
- [0adc6861a172]
84
-
85
- * lib/cztop/reactor.rb:
86
- Guard against events with no sockets
87
- [749f5de1d5fe]
88
-
89
- * certs/ged.pem:
90
- Update my gem-signing cert
91
- [26089589e937]
92
-
153
+ o | * .ruby-version:
154
+ |/ Update to Ruby 2.4
155
+ | [33bf1ec41017]
156
+ |
93
157
  2017-05-19 Michael Granger <ged@FaerieMUD.org>
94
158
 
95
- * Rakefile, cztop-reactor.gemspec:
96
- Fix the rules for the gemspec.
97
- [469956f9635b]
98
-
159
+ o * Rakefile, cztop-reactor.gemspec:
160
+ | Fix the rules for the gemspec.
161
+ | [469956f9635b]
162
+ |
99
163
  2017-05-16 Michael Granger <ged@FaerieMUD.org>
100
164
 
101
- * .hgtags:
102
- Added tag v0.3.0 for changeset 93726ed1d11c
103
- [4a5ff1ab5370]
104
-
105
- * .hgsigs:
106
- Added signature for changeset b27d8748d922
107
- [93726ed1d11c] [v0.3.0]
108
-
109
- * History.md, lib/cztop/reactor.rb:
110
- Bumped the minor version, updated history.
111
- [b27d8748d922]
112
-
165
+ o * .hgtags:
166
+ | Added tag v0.3.0 for changeset 93726ed1d11c
167
+ | [4a5ff1ab5370]
168
+ |
169
+ o * .hgsigs:
170
+ | Added signature for changeset b27d8748d922
171
+ | [93726ed1d11c] [v0.3.0]
172
+ |
173
+ o * History.md, lib/cztop/reactor.rb:
174
+ | Bumped the minor version, updated history.
175
+ | [b27d8748d922]
176
+ |
113
177
  2017-05-15 Michael Granger <ged@FaerieMUD.org>
114
178
 
115
- * .hgignore, Manifest.txt, lib/cztop/reactor/signal_handling.rb,
116
- spec/cztop/reactor/signal_handling_spec.rb:
117
- Add a mixin for signal handling.
118
- [970a2eb110fb]
119
-
179
+ o * .hgignore, Manifest.txt, lib/cztop/reactor/signal_handling.rb,
180
+ | spec/cztop/reactor/signal_handling_spec.rb:
181
+ | Add a mixin for signal handling.
182
+ | [970a2eb110fb]
183
+ |
120
184
  2017-04-30 Michael Granger <ged@FaerieMUD.org>
121
185
 
122
- * .hgignore:
123
- Ignore pkg directory
124
- [1c8f915143cf]
125
-
186
+ o * .hgignore:
187
+ | Ignore pkg directory
188
+ | [1c8f915143cf]
189
+ |
126
190
  2017-04-29 Michael Granger <ged@FaerieMUD.org>
127
191
 
128
- * .hgtags:
129
- Added tag v0.2.0 for changeset 05892f4b1e67
130
- [188620133448]
131
-
132
- * .hgsigs:
133
- Added signature for changeset 94faa8741253
134
- [05892f4b1e67] [v0.2.0]
135
-
136
- * History.md, lib/cztop/reactor.rb:
137
- Bump the minor version, update history.
138
- [94faa8741253]
139
-
140
- * lib/cztop/reactor.rb, spec/cztop/reactor_spec.rb:
141
- Allow timers to be resumed after they're removed.
142
- [2318715be614]
143
-
192
+ o * .hgtags:
193
+ | Added tag v0.2.0 for changeset 05892f4b1e67
194
+ | [188620133448]
195
+ |
196
+ o * .hgsigs:
197
+ | Added signature for changeset 94faa8741253
198
+ | [05892f4b1e67] [v0.2.0]
199
+ |
200
+ o * History.md, lib/cztop/reactor.rb:
201
+ | Bump the minor version, update history.
202
+ | [94faa8741253]
203
+ |
204
+ o * lib/cztop/reactor.rb, spec/cztop/reactor_spec.rb:
205
+ | Allow timers to be resumed after they're removed.
206
+ | [2318715be614]
207
+ |
144
208
  2017-04-19 Michael Granger <ged@FaerieMUD.org>
145
209
 
146
- * Rakefile, cztop-reactor.gemspec:
147
- Remove Rakefile guard against public release.
148
- [bb56a75ae424]
149
-
210
+ o * Rakefile, cztop-reactor.gemspec:
211
+ | Remove Rakefile guard against public release.
212
+ | [bb56a75ae424]
213
+ |
150
214
  2017-04-12 Michael Granger <ged@FaerieMUD.org>
151
215
 
152
- * .hgtags:
153
- Added tag v0.1.0 for changeset 436507f28e4d
154
- [293cb9597072]
155
-
156
- * .hgsigs:
157
- Added signature for changeset 5f4e1c27760a
158
- [436507f28e4d] [v0.1.0]
159
-
160
- * History.md, lib/cztop/reactor.rb:
161
- Set the minor version, update history file.
162
- [5f4e1c27760a]
163
-
216
+ o * .hgtags:
217
+ | Added tag v0.1.0 for changeset 436507f28e4d
218
+ | [293cb9597072]
219
+ |
220
+ o * .hgsigs:
221
+ | Added signature for changeset 5f4e1c27760a
222
+ | [436507f28e4d] [v0.1.0]
223
+ |
224
+ o * History.md, lib/cztop/reactor.rb:
225
+ | Set the minor version, update history file.
226
+ | [5f4e1c27760a]
227
+ |
164
228
  2017-03-27 Michael Granger <ged@FaerieMUD.org>
165
229
 
166
- * .hgsigs:
167
- Added signature for changeset 8616ee222428
168
- [10a0b983e907]
169
-
170
- * .hgtags:
171
- Added tag v0.1.0.pre20170323172345 for changeset 77db55f567df
172
- [8616ee222428]
173
-
174
- * cztop-reactor.gemspec, lib/cztop/reactor.rb,
175
- spec/cztop/reactor_spec.rb:
176
- Add options for ignoring interrupts and blocking errors
177
- [77db55f567df] [v0.1.0.pre20170323172345]
178
-
179
- * .gems:
180
- Fix fivefish gem name in gemset
181
- [27fcb613383f]
182
-
230
+ o * .hgsigs:
231
+ | Added signature for changeset 8616ee222428
232
+ | [10a0b983e907]
233
+ |
234
+ o * .hgtags:
235
+ | Added tag v0.1.0.pre20170323172345 for changeset 77db55f567df
236
+ | [8616ee222428]
237
+ |
238
+ o * cztop-reactor.gemspec, lib/cztop/reactor.rb,
239
+ | spec/cztop/reactor_spec.rb:
240
+ | Add options for ignoring interrupts and blocking errors
241
+ | [77db55f567df] [v0.1.0.pre20170323172345]
242
+ |
243
+ o * .gems:
244
+ | Fix fivefish gem name in gemset
245
+ | [27fcb613383f]
246
+ |
183
247
  2017-03-22 Michael Granger <ged@FaerieMUD.org>
184
248
 
185
- * .hoerc, cztop-reactor.gemspec, lib/cztop/reactor.rb,
186
- spec/cztop/reactor_spec.rb:
187
- Allow a handler object instead of a block.
188
- [10904c471caa]
189
-
249
+ o * .hoerc, cztop-reactor.gemspec, lib/cztop/reactor.rb,
250
+ | spec/cztop/reactor_spec.rb:
251
+ | Allow a handler object instead of a block.
252
+ | [10904c471caa]
253
+ |
190
254
  2017-03-16 Michael Granger <ged@FaerieMUD.org>
191
255
 
192
- * Rakefile, cztop-reactor.gemspec:
193
- Add missing dependency on timers.
194
- [962f88d917bf]
195
-
196
- * .hgignore:
197
- Ignore built gems
198
- [594168b03b71]
199
-
200
- * README.md:
201
- Fix link in the README
202
- [0391133d132d]
203
-
204
- * .hgignore:
205
- Ignore generated docs directory
206
- [ad4092564786]
207
-
208
- * README.md:
209
- Tabs -> spaces in the README
210
- [41ec0ff65005]
211
-
212
- * cztop-reactor.gemspec:
213
- Add generated gemspec
214
- [b3fcff597575]
215
-
216
- * .document, .editorconfig, .gems, .hgignore, .hoerc, .pryrc,
217
- .rdoc_options, .ruby-gemset, .ruby-version, .simplecov, Gemfile,
218
- History.md, LICENSE.txt, Manifest.txt, README.md, Rakefile,
219
- certs/ged.pem, lib/cztop/reactor.rb, lib/cztop/reactor/event.rb,
220
- spec/cztop/reactor/event_spec.rb, spec/cztop/reactor_spec.rb,
221
- spec/spec_helper.rb:
222
- Initial commit.
223
- [5e3f2358036b]
256
+ o * Rakefile, cztop-reactor.gemspec:
257
+ | Add missing dependency on timers.
258
+ | [962f88d917bf]
259
+ |
260
+ o * .hgignore:
261
+ | Ignore built gems
262
+ | [594168b03b71]
263
+ |
264
+ o * README.md:
265
+ | Fix link in the README
266
+ | [0391133d132d]
267
+ |
268
+ o * .hgignore:
269
+ | Ignore generated docs directory
270
+ | [ad4092564786]
271
+ |
272
+ o * README.md:
273
+ | Tabs -> spaces in the README
274
+ | [41ec0ff65005]
275
+ |
276
+ o * cztop-reactor.gemspec:
277
+ | Add generated gemspec
278
+ | [b3fcff597575]
279
+ |
280
+ o * .document, .editorconfig, .gems, .hgignore, .hoerc, .pryrc,
281
+ .rdoc_options, .ruby-gemset, .ruby-version, .simplecov, Gemfile,
282
+ History.md, LICENSE.txt, Manifest.txt, README.md, Rakefile,
283
+ certs/ged.pem, lib/cztop/reactor.rb, lib/cztop/reactor/event.rb,
284
+ spec/cztop/reactor/event_spec.rb, spec/cztop/reactor_spec.rb,
285
+ spec/spec_helper.rb:
286
+ Initial commit.
287
+ [5e3f2358036b]
data/History.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## v0.8.0 [2019-05-22] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ Bugfixes:
4
+
5
+ - Fix several issues with socket monitoring.
6
+ - Fix bug in signal-handler teardown
7
+ - Super from the socket monitoring mixin
8
+
9
+ Enhancements:
10
+
11
+ - Add a #sockets_description method to the Reactor.
12
+ - Turn on verbose on monitors if $VERBOSE is set
13
+ - Super to monitor event handler methods if possible
14
+
15
+
1
16
  ## v0.7.0 [2018-07-23] Michael Granger <ged@FaerieMUD.org>
2
17
 
3
18
  Enhancements:
data/Rakefile CHANGED
@@ -38,7 +38,7 @@ hoespec = Hoe.spec 'cztop-reactor' do |spec|
38
38
  spec.dependency 'simplecov', '~> 0.13', :developer
39
39
  spec.dependency 'rdoc-generator-fivefish', '~> 0.3', :developer
40
40
 
41
- spec.require_ruby_version( '>=2.2.4' )
41
+ spec.require_ruby_version( '>=2.4.0' )
42
42
  spec.hg_sign_tags = true if spec.respond_to?( :hg_sign_tags= )
43
43
  spec.check_history_on_release = true if spec.respond_to?( :check_history_on_release= )
44
44
 
@@ -24,7 +24,7 @@ class CZTop::Reactor
24
24
  include MonitorMixin
25
25
 
26
26
  # The version of this library
27
- VERSION = '0.7.0'
27
+ VERSION = '0.8.0'
28
28
 
29
29
  # The maximum number of seconds to wait for events when there are no timers
30
30
  # registered.
@@ -282,16 +282,18 @@ class CZTop::Reactor
282
282
  ### registered with the reactor for the `:read` event with the specified +callback+,
283
283
  ### then returned.
284
284
  def register_monitor( socket, *events, &callback )
285
- if !events.empty? && !events.last.is_a?( String )
285
+ if !events.empty? && events.last.respond_to?( :handle_monitor_event )
286
286
  handler = events.pop
287
287
  callback = handler.method( :handle_monitor_event )
288
288
  end
289
289
 
290
+ events.map!( &:to_s )
290
291
  events.push( 'ALL' ) if events.empty?
291
292
 
292
293
  monitor = CZTop::Monitor.new( socket )
293
294
  monitor.listen( *events )
294
295
  monitor.start
296
+ monitor.verbose! if $VERBOSE
295
297
 
296
298
  self.register( monitor.actor, :read, &callback )
297
299
 
@@ -327,15 +329,19 @@ class CZTop::Reactor
327
329
 
328
330
  self.log.debug "Got event %p" % [ event ]
329
331
  if event
330
- # self.log.debug "Got event: %p" % [ event ]
331
- handler = self.sockets[ event.socket ][ :handler ]
332
- handler.call( event )
332
+ if event.socket
333
+ handler = self.sockets[ event.socket ][ :handler ]
334
+ handler.call( event )
335
+ else
336
+ self.log.warn "Got an event for an unregistered socket: racing to shut down?"
337
+ end
333
338
  else
334
339
  self.log.debug "Expired: firing timers."
335
340
  self.timers.fire
336
341
  end
337
342
 
338
- self.log.debug "%d sockets after polling: %p" % [ self.sockets.length, self.sockets ]
343
+ # self.log.debug "%d sockets after polling: %s" %
344
+ # [ self.sockets.length, self.sockets_description ]
339
345
  rescue Interrupt
340
346
  raise unless ignore_interrupts
341
347
  self.log.debug "Interrupted."
@@ -362,6 +368,21 @@ class CZTop::Reactor
362
368
  end
363
369
 
364
370
 
371
+ ### Return a description of the sockets registered with the reactor.
372
+ def sockets_description
373
+ return self.sockets.map do |sock, _|
374
+ case sock
375
+ when CZTop::Socket
376
+ "%s {%s}" % [ sock.class.name.sub(/.*::/, ''), sock.last_endpoint || 'not connected' ]
377
+ when CZTop::Actor
378
+ "Actor %#x" % [ sock.object_id * 2 ]
379
+ else
380
+ "??? %p ???" % [ sock.class ]
381
+ end
382
+ end.join( ', ' )
383
+ end
384
+
385
+
365
386
  #########
366
387
  protected
367
388
  #########
@@ -64,7 +64,9 @@ module CZTop::Reactor::SignalHandling
64
64
  return yield
65
65
 
66
66
  ensure
67
+ self.log.debug "Going to reset signal traps..."
67
68
  self.reset_signal_traps( *signals )
69
+ self.log.debug "Going to clean up signal handler..."
68
70
  self.clean_up_signal_handling( reactor )
69
71
  end
70
72
 
@@ -99,12 +101,17 @@ module CZTop::Reactor::SignalHandling
99
101
 
100
102
  ### Tear down the data structures for signal handling
101
103
  def clean_up_signal_handling( reactor )
102
- reactor.unregister( @self_pipe[:reader] )
103
-
104
- @self_pipe[:writer].options.linger = 0
105
- @self_pipe[:writer].close
106
- @self_pipe[:reader].options.linger = 0
107
- @self_pipe[:reader].close
104
+ if @self_pipe
105
+ self.log.info "Cleaning up signal handler self-pipe."
106
+ reactor.unregister( @self_pipe[:reader] )
107
+
108
+ @self_pipe[:writer].options.linger = 0
109
+ @self_pipe[:writer].close
110
+ @self_pipe[:reader].options.linger = 0
111
+ @self_pipe[:reader].close
112
+ else
113
+ self.log.info "No self-pipe; skipping signal-handler cleanup."
114
+ end
108
115
 
109
116
  Thread.main[ SIGNAL_QUEUE_KEY ].clear
110
117
  end
@@ -16,6 +16,7 @@ module CZTop::Reactor::SocketMonitoring
16
16
 
17
17
  ### Set up a monitor instance variable on object creation.
18
18
  def initialize( * ) # :notnew:
19
+ super if defined?( super )
19
20
  @monitor = nil
20
21
  end
21
22
 
@@ -26,7 +27,7 @@ module CZTop::Reactor::SocketMonitoring
26
27
 
27
28
  ### Run the block with monitoring for the specified +socket+.
28
29
  def with_socket_monitor( reactor, socket, *events )
29
- mon = self.set_up_socket_monitor( reactor, socket )
30
+ mon = self.set_up_socket_monitor( reactor, socket, *events )
30
31
 
31
32
  return yield
32
33
  ensure
@@ -43,6 +44,7 @@ module CZTop::Reactor::SocketMonitoring
43
44
  ### Tear down the monitor.
44
45
  def clean_up_socket_monitor( mon )
45
46
  mon.terminate if mon
47
+ self.log.debug "Monitor is: %p" % [ mon ]
46
48
  end
47
49
 
48
50
 
@@ -67,63 +69,109 @@ module CZTop::Reactor::SocketMonitoring
67
69
  protected
68
70
  #########
69
71
 
72
+
70
73
  ### Monitor event callback for socket connection events
71
74
  def on_connected( fd, endpoint )
72
75
  self.log.debug "Client socket on FD %d connected" % [ fd ]
76
+ super if defined?( super )
73
77
  end
74
78
 
75
79
 
76
80
  ### Monitor event callback for socket connection-delayed events
77
81
  def on_connect_delayed( fd, endpoint )
78
82
  self.log.debug "Client socket on FD %d connection delayed" % [ fd ]
83
+ super if defined?( super )
79
84
  end
80
85
 
81
86
 
82
87
  ### Monitor event callback for socket retry events
83
88
  def on_connect_retried( fd, endpoint )
84
89
  self.log.debug "Retrying connection for socket on FD %d" % [ fd ]
90
+ super if defined?( super )
91
+ end
92
+
93
+
94
+ ### Monitor event callback for listening events
95
+ def on_listening( fd, endpoint )
96
+ self.log.debug "Socket on FD %d is now listening for connections" % [ fd ]
97
+ super if defined?( super )
98
+ end
99
+
100
+
101
+ ### Monitor event callback for bind failure events
102
+ def on_bind_failed( fd, endpoint )
103
+ self.log.debug "Socket on FD %d could not be bound" % [ fd ]
104
+ super if defined?( super )
85
105
  end
86
106
 
87
107
 
88
108
  ### Monitor event callback for socket accepted events
89
109
  def on_accepted( fd, endpoint )
90
110
  self.log.debug "Client socket on FD %d accepted" % [ fd ]
111
+ super if defined?( super )
91
112
  end
92
113
 
93
114
 
94
- ### Monitor event callback for successful auth events.
95
- def on_handshake_succeeded( fd, endpoint )
96
- self.log.debug "Client socket on FD %d handshake succeeded" % [ fd ]
115
+ ### Monitor event callback for socket accept failed events
116
+ def on_accept_failed( fd, endpoint )
117
+ self.log.debug "Client socket on FD %d accept failed" % [ fd ]
118
+ super if defined?( super )
97
119
  end
98
120
 
99
121
 
100
- ### Monitor event callback for failed auth events.
101
- def on_handshake_failed( fd, endpoint )
102
- self.log.debug "Client socket on FD %d handshake failed" % [ fd ]
122
+ ### Monitor event callback for socket closed events
123
+ def on_closed( fd, endpoint )
124
+ self.log.debug "Client socket on FD %d closed" % [ fd ]
125
+ super if defined?( super )
126
+ end
127
+
128
+
129
+ ### Monitor event callback for socket close failed events
130
+ def on_close_failed( fd, endpoint )
131
+ self.log.debug "Close failed for socket on FD %d" % [ fd ]
132
+ super if defined?( super )
133
+ end
134
+
135
+
136
+ ### Monitor event callback for socket disconnection events
137
+ def on_disconnected( fd, endpoint )
138
+ self.log.debug "Client socket on FD %d disconnected" % [ fd ]
139
+ super if defined?( super )
140
+ end
141
+
142
+
143
+ ### Monitor event callback for monitor stopped events.
144
+ def on_monitor_stopped( fd, endpoint )
145
+ self.log.debug "Monitor for socket on FD %d stopped." % [ fd ]
146
+ super if defined?( super )
147
+ end
148
+
149
+
150
+ ### Monitor event callback for successful auth events.
151
+ def on_handshake_succeeded( fd, endpoint )
152
+ self.log.debug "Client socket on FD %d handshake succeeded" % [ fd ]
153
+ super if defined?( super )
103
154
  end
104
155
 
105
156
 
106
157
  ### Monitor event callback for failed handshake events.
107
158
  def on_handshake_failed_no_detail( fd, endpoint )
108
159
  self.log.debug "Client socket on FD %d handshake failed; no further details are known" % [ fd ]
160
+ super if defined?( super )
109
161
  end
110
162
 
111
163
 
112
164
  ### Monitor event callback for failed handshake events.
113
165
  def on_handshake_failed_protocol( fd, endpoint )
114
166
  self.log.debug "Client socket on FD %d handshake failed: protocol error" % [ fd ]
167
+ super if defined?( super )
115
168
  end
116
169
 
117
170
 
118
- ### Monitor event callback for socket closed events
119
- def on_closed( fd, endpoint )
120
- self.log.debug "Client socket on FD %d closed" % [ fd ]
121
- end
122
-
123
-
124
- ### Monitor event callback for socket disconnection events
125
- def on_disconnected( fd, endpoint )
126
- self.log.debug "Client socket on FD %d disconnected" % [ fd ]
171
+ ### Monitor event callback for failed auth events.
172
+ def on_handshake_failed_auth( fd, endpoint )
173
+ self.log.debug "Client socket on FD %d handshake failed: authentication failure" % [ fd ]
174
+ super if defined?( super )
127
175
  end
128
176
 
129
177
  end # module CZTop::Reactor::SocketMonitoring
@@ -7,8 +7,8 @@ require 'cztop/reactor/signal_handling'
7
7
 
8
8
  describe CZTop::Reactor::SignalHandling do
9
9
 
10
- it "can add a signal handler setup to a reactor for a block" do
11
- including_class = Class.new do
10
+ let( :including_class ) do
11
+ class_instance = Class.new do
12
12
 
13
13
  def initialize
14
14
  @signals = []
@@ -21,9 +21,12 @@ describe CZTop::Reactor::SignalHandling do
21
21
  end
22
22
 
23
23
  end
24
+ class_instance.include( described_class )
25
+ return class_instance
26
+ end
24
27
 
25
- including_class.include( described_class )
26
28
 
29
+ it "can add a signal handler setup to a reactor for a block" do
27
30
  obj = including_class.new
28
31
  reactor = CZTop::Reactor.new
29
32
 
@@ -38,10 +41,10 @@ describe CZTop::Reactor::SignalHandling do
38
41
 
39
42
 
40
43
  it "raises if the including class doesn't provide a #handle_signal method" do
41
- including_class = Class.new
42
- including_class.include( described_class )
44
+ test_class = Class.new
45
+ test_class.include( described_class )
43
46
 
44
- obj = including_class.new
47
+ obj = test_class.new
45
48
  reactor = CZTop::Reactor.new
46
49
 
47
50
  expect {
@@ -53,5 +56,23 @@ describe CZTop::Reactor::SignalHandling do
53
56
  }.to raise_error( NotImplementedError, /unhandled signal USR1/i )
54
57
  end
55
58
 
59
+
60
+ it "doesn't try to tear down signal handling if it didn't get set up" do
61
+ error_class = Class.new( StandardError )
62
+ allow( CZTop::Socket::PAIR ).to receive( :new ).
63
+ and_raise( error_class.new("something bad happened") )
64
+
65
+ obj = including_class.new
66
+ reactor = CZTop::Reactor.new
67
+
68
+ begin
69
+ obj.with_signal_handler( reactor, :USR1 ) do
70
+ fail "we shouldn't get here"
71
+ end
72
+ rescue error_class => err
73
+ expect( err.message ).to eq( "something bad happened" )
74
+ end
75
+ end
76
+
56
77
  end
57
78
 
@@ -29,7 +29,7 @@ describe CZTop::Reactor::SocketMonitoring do
29
29
  listener = CZTop::Socket::SERVER.new( '@tcp://127.0.0.1:*' )
30
30
  socket = CZTop::Socket::CLIENT.new
31
31
 
32
- obj.with_socket_monitor( reactor, socket, :CONNECTED ) do
32
+ obj.with_socket_monitor( reactor, socket ) do
33
33
  socket.connect( listener.last_endpoint )
34
34
  reactor.poll_once
35
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cztop-reactor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Granger
@@ -10,32 +10,31 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIEbDCCAtSgAwIBAgIBATANBgkqhkiG9w0BAQUFADA+MQwwCgYDVQQDDANnZWQx
14
- GTAXBgoJkiaJk/IsZAEZFglGYWVyaWVNVUQxEzARBgoJkiaJk/IsZAEZFgNvcmcw
15
- HhcNMTcwOTI3MDAzMDQ0WhcNMTgwOTI3MDAzMDQ0WjA+MQwwCgYDVQQDDANnZWQx
16
- GTAXBgoJkiaJk/IsZAEZFglGYWVyaWVNVUQxEzARBgoJkiaJk/IsZAEZFgNvcmcw
17
- ggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQC/JWGRHO+USzR97vXjkFgt
18
- 83qeNf2KHkcvrRTSnR64i6um/ziin0I0oX23H7VYrDJC9A/uoUa5nGRJS5Zw/+wW
19
- ENcvWVZS4iUzi4dsYJGY6yEOsXh2CcF46+QevV8iE+UmbkU75V7Dy1JCaUOyizEt
20
- TH5UHsOtUU7k9TYARt/TgYZKuaoAMZZd5qyVqhF1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uJd5wZRBluJANu7bEtjgc3fFaGVP2XxVdCpVjNbmMDg4Qp
29
+ ovvczP53X6pQP2RSZgxF6Lblvy8y11RziUTVRG/Z2aJHsElo6gI7vQznE/OSDrhC
30
+ gEhr8uaIUt7D+HZWRbU0+MkKPpL5uMqaFuJbqXEvSwPTuUuYkDfNfsjQO7ruWBac
31
+ bxHCrvpZ6Tijc0nrlyXi6gPOCLeaqhau2xFnlvKgELwsGYSoKBJyDwqtQ5kwrOlU
32
+ tkSyLrfZ+RZcH535Hyvif7ZxB0v5OxXXoec+N2vrUsEUMRDL9dg4/WFdN8hIOixF
33
+ 3IPKpZ1ho0Ya5q7yhygtBK9/NBFHw+nbJjcltfPDBXleRe8u73gnQo8AZIhStYSP
34
+ v4qqqa27Bs468d6SoPxjSm8a2mM9HZ4OdWhq4tFsbTeXDVquCfi64OTEaTt2xQdR
35
+ JnC4lpJfCP6aCXa5h2XAQfPSH636cQap
37
36
  -----END CERTIFICATE-----
38
- date: 2018-07-24 00:00:00.000000000 Z
37
+ date: 2019-05-22 00:00:00.000000000 Z
39
38
  dependencies:
40
39
  - !ruby/object:Gem::Dependency
41
40
  name: loggability
@@ -99,14 +98,14 @@ dependencies:
99
98
  requirements:
100
99
  - - "~>"
101
100
  - !ruby/object:Gem::Version
102
- version: '0.9'
101
+ version: '0.10'
103
102
  type: :development
104
103
  prerelease: false
105
104
  version_requirements: !ruby/object:Gem::Requirement
106
105
  requirements:
107
106
  - - "~>"
108
107
  - !ruby/object:Gem::Version
109
- version: '0.9'
108
+ version: '0.10'
110
109
  - !ruby/object:Gem::Dependency
111
110
  name: hoe-highline
112
111
  requirement: !ruby/object:Gem::Requirement
@@ -153,30 +152,36 @@ dependencies:
153
152
  name: rdoc
154
153
  requirement: !ruby/object:Gem::Requirement
155
154
  requirements:
156
- - - "~>"
155
+ - - ">="
157
156
  - !ruby/object:Gem::Version
158
157
  version: '4.0'
158
+ - - "<"
159
+ - !ruby/object:Gem::Version
160
+ version: '7'
159
161
  type: :development
160
162
  prerelease: false
161
163
  version_requirements: !ruby/object:Gem::Requirement
162
164
  requirements:
163
- - - "~>"
165
+ - - ">="
164
166
  - !ruby/object:Gem::Version
165
167
  version: '4.0'
168
+ - - "<"
169
+ - !ruby/object:Gem::Version
170
+ version: '7'
166
171
  - !ruby/object:Gem::Dependency
167
172
  name: hoe
168
173
  requirement: !ruby/object:Gem::Requirement
169
174
  requirements:
170
175
  - - "~>"
171
176
  - !ruby/object:Gem::Version
172
- version: '3.16'
177
+ version: '3.17'
173
178
  type: :development
174
179
  prerelease: false
175
180
  version_requirements: !ruby/object:Gem::Requirement
176
181
  requirements:
177
182
  - - "~>"
178
183
  - !ruby/object:Gem::Version
179
- version: '3.16'
184
+ version: '3.17'
180
185
  description: |-
181
186
  This is an implementation of the Reactor pattern described in [Pattern-Oriented
182
187
  Software Architecture (Volume 2)][POSA2]. It allows an asynchronous application
@@ -238,15 +243,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
238
243
  requirements:
239
244
  - - ">="
240
245
  - !ruby/object:Gem::Version
241
- version: 2.2.4
246
+ version: 2.4.0
242
247
  required_rubygems_version: !ruby/object:Gem::Requirement
243
248
  requirements:
244
249
  - - ">="
245
250
  - !ruby/object:Gem::Version
246
251
  version: '0'
247
252
  requirements: []
248
- rubyforge_project:
249
- rubygems_version: 2.7.6
253
+ rubygems_version: 3.0.3
250
254
  signing_key:
251
255
  specification_version: 4
252
256
  summary: This is an implementation of the Reactor pattern described in [Pattern-Oriented
metadata.gz.sig CHANGED
Binary file