librtree 0.8.8 → 0.8.9

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/ext/rtree/rtree.c +2 -2
  3. data/lib/rtree.rb +25 -0
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc74390aa8eb79643f88f2c48f7408ef9dd17dd12ed1049e3bfe2961b7523e4b
4
- data.tar.gz: 25488f67912344fcd69cb2c19ca6b4344cf708bfc07d9f8e1629b5893030a759
3
+ metadata.gz: d796bcdad6e023f99009363c9c11a10d8c6dfc7b9c797b487925fa319ace78b9
4
+ data.tar.gz: 83d563781db1c1e1b6bd8b8790cbb68fbbd9a7f997dd49840ff8cba7bfcac3e8
5
5
  SHA512:
6
- metadata.gz: 4bc5ae0e333e077a8331164e87f3d4c60470bfadc046c86424b8147d59ecfdb32b212d7ae7ec0d3e834d62b0c564929723a56af988a5b5a05364ba9e841407ff
7
- data.tar.gz: 2b5d8c0799fabb2085686f4c3eb23feb367201d6630d4ac7e0621cc76ba5dbc6422b0e4d5649aee33fc375cff3411308ef81d61567f1af6049f50b677aa198de
6
+ metadata.gz: e1a6c56ad9c14ae15c8ed047e980262477f36b672bb08c5cc584eff7b2fba3b20845e8671ee166f8929abbb5a7d11e596cca36da6d89a67cef167773ada20577
7
+ data.tar.gz: b699d85386e8ea991eb2d4e4816635b6a0d550e2dbeb36b670526186d0b72f72f8cf763d22ba6339fe595dc3f70c7d6f9e9bfa5714216ec125e0b1748c146d97
data/ext/rtree/rtree.c CHANGED
@@ -139,10 +139,10 @@ static VALUE rt_update(VALUE self)
139
139
 
140
140
  /*
141
141
  The librtree API expects the search callback to return zero to
142
- continue the search, non-zero to terminate. I was expecting to
142
+ continue the search, non-zero to terminate. I was expecting to
143
143
  need to wrap the 'yield' in 'rescue's and 'ensure's to handle
144
144
  exceptions and breaks, but find that doing nothing actually does
145
- the right thing (see specs). The search implemetation is just
145
+ the right thing (see specs). The search implementation is just
146
146
  a recursive search through the tree (as you would expect) so
147
147
  there is no end-of-search cleanup to do, so I think this is all
148
148
  just fine ... wild
data/lib/rtree.rb CHANGED
@@ -8,6 +8,7 @@ class RTreeStyleBase ; end
8
8
 
9
9
  require 'rtree/rtree'
10
10
  require 'json'
11
+ require 'fcntl'
11
12
 
12
13
  # @author RTree J. J. Green
13
14
  #
@@ -61,6 +62,25 @@ require 'json'
61
62
  #
62
63
  class RTree < RTreeBase
63
64
 
65
+ module IOUtil
66
+
67
+ private
68
+
69
+ # In Ruby 3, the Fibres facility exploits non-blocking IO and so pipes
70
+ # are non-blocking by default, this buggers-up the deserialise method
71
+ # since there is short delay forking here -- so we reinstate blocking
72
+ # with some fairly low-level fcntl)2) magick.
73
+
74
+ def unset_nonblock(fd)
75
+ flags0 = fd.fcntl(Fcntl::F_GETFL, 0)
76
+ flags1 = flags0 & ~Fcntl::O_NONBLOCK
77
+ fd.fcntl(Fcntl::F_SETFL, flags1)
78
+ end
79
+
80
+ end
81
+
82
+ extend IOUtil
83
+
64
84
  class << self
65
85
 
66
86
  # Create a new RTree instance from JSON stream
@@ -184,6 +204,7 @@ class RTree < RTreeBase
184
204
  def deserialise(string, encoding)
185
205
  raise TypeError unless string.is_a? String
186
206
  rd, wr = IO.pipe(encoding)
207
+ unset_nonblock(rd)
187
208
  if fork then
188
209
  wr.close
189
210
  begin
@@ -478,6 +499,8 @@ end
478
499
  #
479
500
  class RTree::Style < RTreeStyleBase
480
501
 
502
+ extend RTree::IOUtil
503
+
481
504
  class << self
482
505
 
483
506
  # Create a new Style instance from JSON stream
@@ -500,6 +523,7 @@ class RTree::Style < RTreeStyleBase
500
523
  def from_json(json)
501
524
  raise TypeError unless json.is_a? String
502
525
  rd, wr = IO.pipe(Encoding::UTF_8)
526
+ unset_nonblock(rd)
503
527
  if fork then
504
528
  wr.close
505
529
  begin
@@ -545,5 +569,6 @@ class RTree::Style < RTreeStyleBase
545
569
  end
546
570
 
547
571
  alias_method :from_array, :from_a
572
+
548
573
  end
549
574
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: librtree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.8
4
+ version: 0.8.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - J.J. Green
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-14 00:00:00.000000000 Z
11
+ date: 2021-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -127,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
127
  version: '0'
128
128
  requirements:
129
129
  - The librtree library (1.0.6 or later)
130
- rubygems_version: 3.1.2
130
+ rubygems_version: 3.2.3
131
131
  signing_key:
132
132
  specification_version: 4
133
133
  summary: R-tree spatial index