tanker-core 2.6.2.alpha.8 → 2.6.2.beta.2

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: ae4526cac191b56e3acd2fc0eb6762ae6638f3f41e78ea4010b829036eb73c3a
4
- data.tar.gz: 43df75515f59586054e41708394a12c579dac4c3fc91cb2eaa2dac577cc94f62
3
+ metadata.gz: 69f962904a2700e1eff1d3f7d44a5a7f29be26c0048a89ffffc3ad5e5a856f82
4
+ data.tar.gz: 040e523c8912592aadec416c027cb925d0c6e2936e0d1364c6e6cd75cae9164c
5
5
  SHA512:
6
- metadata.gz: 10eb4a1603d79a8163119a9411b2f2318a8f3255bb5c6e065df33f9eb59078a7677f50dcfad1409b3a8dac830073c96f4d618ecdffc29f0ae271275dc7f76061
7
- data.tar.gz: 525ca18eb0d5bf5d3bf48154a3bbbf77311aabf7eef861a4bc28e39d1196e404630ce7bb9950ec7b4232b97a7a58fbf8d34718f467973b9136b959c36aa4e1ad
6
+ metadata.gz: e515de3523845ec392141a9ed06baf9c936a863cb0d905384398232c705cf182377c97cf12efedebf83055b09df8ea6d8d02dabe6620b251489790cc22a54520
7
+ data.tar.gz: a60601421d1c3402ebf73d4e35cdc6127c367769523697b7495635ae0a56d2d84c8acba65e5e126f4de4164f2fddb0eede58a88acc45646b7fdcaa28baeb2f10
@@ -1,10 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ffi/platform'
4
-
5
3
  module Tanker::CTanker
6
4
  def self.get_path(name)
7
- File.expand_path "../../../vendor/tanker/#{FFI::Platform::OS}-#{FFI::Platform::ARCH}/"\
8
- "#{FFI::Platform::LIBPREFIX}#{name}.#{FFI::Platform::LIBSUFFIX}", __dir__
5
+ if /darwin/ =~ RUBY_PLATFORM
6
+ ext = '.dylib'
7
+ subdir = 'mac64'
8
+ else
9
+ ext = '.so'
10
+ subdir = 'linux64'
11
+ end
12
+
13
+ File.expand_path "../../../vendor/libctanker/#{subdir}/tanker/lib/lib#{name}#{ext}", __dir__
9
14
  end
10
15
  end
@@ -3,29 +3,6 @@
3
3
  require 'English'
4
4
  require 'tanker/c_tanker'
5
5
 
6
- # Because Ruby only has synchronous streams, we can't read them on Tanker's
7
- # thread (in the read callback). To work around that, we start a new Thread for
8
- # each read operation. This is not that bad because Ruby uses a thread pool
9
- # behind the scenes and creating a Thread is usually just a work pushed on a
10
- # queue.
11
- #
12
- # Also, there doesn't seem to easily create an IO object. The simplest way is to
13
- # create a pipe. A pipe is a stream where you read everything you write into it.
14
- # Tanker streams however are pull streams, so there must be something that pulls
15
- # from the Tanker stream and pushes onto the IO stream. We start a long-running
16
- # thread for that which just loops.
17
- #
18
- # Because so much is happening in parallel, synchronization is not trivial.
19
- # There's one mutex per stream, and we lock that same mutex for every critical
20
- # section. Here are some important constraints that must be held:
21
- # - Do not copy data to the Tanker buffer if tanker_stream_close has been
22
- # called
23
- # - Do not call tanker_stream_read_operation_finish if tanker_stream_close has
24
- # been called
25
- # - On the output stream, do not call tanker_stream_read on a closed/closing
26
- # stream. Though it is ok to close the stream after the call, but before the
27
- # future is resolved.
28
-
29
6
  module Tanker
30
7
  class Core
31
8
  def encrypt_stream(stream, encryption_options = nil)
@@ -118,6 +95,21 @@ module Tanker
118
95
  end
119
96
  end
120
97
 
98
+ # IMPORTANT: about synchronization
99
+ # Because of a design flaw in the Tanker C streaming API, it is difficult to
100
+ # handle cancelation. When canceling a read (closing the stream), Tanker
101
+ # doesn't forward the cancelation request to the input stream (there's no
102
+ # callback for that), which means that the callback maybe writing to a buffer
103
+ # that's being freed. We worked around that by adding a mutex and locking it
104
+ # in both the output stream and the input stream.
105
+ # Things to be careful about:
106
+ # - Do not copy data to the Tanker buffer if tanker_stream_close has been
107
+ # called
108
+ # - Do not call tanker_stream_read_operation_finish if tanker_stream_close has
109
+ # been called
110
+ # - On the output stream, do not call tanker_stream_read on a closed/closing
111
+ # stream. Though it is ok to close the stream after the call, but before the
112
+ # future is resolved.
121
113
  class IoToTankerStreamWrapper
122
114
  attr_reader :error
123
115
  attr_reader :read_method
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Tanker
4
4
  class Core
5
- VERSION = '2.6.2.alpha.8'
5
+ VERSION = '2.6.2.beta.2'
6
6
 
7
7
  def self.native_version
8
8
  CTanker.tanker_version_string
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tanker-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.2.alpha.8
4
+ version: 2.6.2.beta.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tanker team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-01 00:00:00.000000000 Z
11
+ date: 2020-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -165,7 +165,8 @@ files:
165
165
  - lib/tanker/encryption_options.rb
166
166
  - lib/tanker/error.rb
167
167
  - lib/tanker/sharing_options.rb
168
- - vendor/tanker/linux-x86_64/libctanker.so
168
+ - vendor/libctanker/linux64/tanker/lib/libctanker.so
169
+ - vendor/libctanker/mac64/tanker/lib/libctanker.dylib
169
170
  homepage: https://tanker.io
170
171
  licenses:
171
172
  - Apache-2.0