cztop 1.2.6 → 1.2.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ca8b5fa8bb96e24ab3c500b704891677ab4431b66f027cfd68dd15d7be79a380
4
- data.tar.gz: c6360aaef9640bf4f7f75bf3f7f2229d48c93b9e5929bdb28c5012fb9a014806
3
+ metadata.gz: ee0da7ba06a375442f26d2838664bef2e2546bc5b99f7515dbfbb560e8755dd8
4
+ data.tar.gz: 804736cdfa21a4907be8b9f7dbb3109b3a80e83735502906696454b6f10b0822
5
5
  SHA512:
6
- metadata.gz: b099c61bbfde6095eaf621b09f13501e2529f87fd91850863b4bdb30d4856584908fc06712371db6f767bf2061f9752cb26991b185e9dd8ab212d686911747fd
7
- data.tar.gz: 0731e75df8e20bbfb12546ef2145811104dc117eb381b65edbe1733cf147b4785bcc96679a372f3029351da338872c915f7d801f7031f5302ad52196fec056a7
6
+ metadata.gz: 4b058fc7d52d523028246130134af420161b7a352d7b9d7597482204d2211ab3d0ef75ae47056ba75e237c3dde2150f8df42a929250b55202161a6ca638f6999
7
+ data.tar.gz: 335d9cb39d1bb7a47aa62965145aa692507c1fa42290cec830657dc333f6909c138535f22d7f4ad2d7c40b8bca7d1c334e2a9f553ee0af881f7c9f6686663312
data/CHANGES.md CHANGED
@@ -1,3 +1,8 @@
1
+ 1.2.7 (7/12/2024)
2
+ -----
3
+ * CZTop::Socket#wait_readable: honor small (< 0.5s) timeouts
4
+ * CZTop::Socket#wait_writable: honor small (< 0.5s) timeouts
5
+
1
6
  1.2.6 (7/12/2024)
2
7
  -----
3
8
  * add missing `require 'io/wait'` to get `IO#wait_readable`
@@ -48,15 +48,29 @@ module CZTop
48
48
 
49
49
 
50
50
  # Because ZMQ sockets are edge-triggered, there's a small chance that we miss an edge (race condition). To avoid
51
- # blocking forever, all waiting on the ZMQ FD is done with this timeout.
51
+ # blocking forever, all waiting on the ZMQ FD is done with this timeout or less.
52
+ #
53
+ # The race condition exists between the calls to {#readable?}/{#writable?} and waiting for the ZMQ FD. If the
54
+ # socke becomes readable/writable during that time, waiting for the FD could block forever without a timeout.
55
+ #
52
56
  FD_TIMEOUT = 0.5
53
57
 
54
58
 
55
59
  # @note Only available on Ruby >= 3.2
56
60
  #
57
- def wait_for_fd_signal
61
+ def wait_for_fd_signal(timeout = nil)
58
62
  @fd_io ||= to_io
59
- @fd_io.wait_readable FD_TIMEOUT # NOTE: always wait for readability on ZMQ FD
63
+
64
+ if timeout
65
+ if timeout > FD_TIMEOUT
66
+ timeout = FD_TIMEOUT
67
+ end
68
+ else
69
+ timeout = FD_TIMEOUT
70
+ end
71
+
72
+ # NOTE: always wait for readability on ZMQ FD
73
+ @fd_io.wait_readable timeout
60
74
  end if IO.method_defined?(:wait_readable)
61
75
 
62
76
 
@@ -80,7 +94,7 @@ module CZTop
80
94
  while true
81
95
  # p wait_readable: self, timeout: timeout
82
96
 
83
- wait_for_fd_signal
97
+ wait_for_fd_signal timeout
84
98
  break if readable? # NOTE: ZMQ FD can't be trusted
85
99
  raise ::IO::TimeoutError if timeout_at && now >= timeout_at
86
100
 
@@ -107,7 +121,7 @@ module CZTop
107
121
  while true
108
122
  # p wait_writable: self, timeout: timeout
109
123
 
110
- wait_for_fd_signal
124
+ wait_for_fd_signal timeout
111
125
  break if writable? # NOTE: ZMQ FD can't be trusted
112
126
  raise ::IO::TimeoutError if timeout_at && now >= timeout_at
113
127
 
data/lib/cztop/version.rb CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  module CZTop
4
4
 
5
- VERSION = '1.2.6'
5
+ VERSION = '1.2.7'
6
6
 
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cztop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.6
4
+ version: 1.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrik Wenger