tanker-core 4.2.1.alpha.8 → 4.2.1.alpha.10

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: 0bca4633e82001cf61c6e6fc7a1195e8d004ca0870c915e44e652fd5454b9e86
4
- data.tar.gz: 49a1673c1ce7868e0b2e4a2b450e12adbb53175cf80a69aade9ea356138f9008
3
+ metadata.gz: 4468a16f8acee2c9c627778aeda6c59c0bcd8173015723bfa752303dfddd310b
4
+ data.tar.gz: daacb13259fc02344ca588634d79109ce6146ab4b7a2de43f9c4d489ae897a93
5
5
  SHA512:
6
- metadata.gz: 5bed10a2c6bc5c3ee78e33741be050fe06f60701893c5f67159336d420e1fa04a17c8e44b505d6382b27775db29b9b0be5867c78d4ca4d18f038b42bf149551c
7
- data.tar.gz: d289a1dfe0203656392bf0f51ac67218b365ed38b8ea7191f9fa88860ea794b829130c6476886362a8bfed71ea128719075a7cc0be566b238f2048bdc8bf2d82
6
+ metadata.gz: 4cbe6918aec04bc6c490ad5c84ab81efc02e08b884f7c1fa17d31cc01d832b78e05c6c2d753102ae467184f4286826095d37c53d1762b3249b922d45af37be8e
7
+ data.tar.gz: a9b209637053e7f24e4f6b1745bb98a519bc5dc89f7e58799e64d11977fa5ac42a753ba86f07f3ed594c64ec7bce7721dae5488b421818ae4f45bd6449a2881c
@@ -1,20 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'tanker/core/http'
4
-
5
3
  module Tanker
6
- module ForkHook
7
- def _fork(*args)
8
- puts "### PID=#{Process.pid} TANKER-CORE BEFORE FORK HOOK"
9
- CTanker.tanker_before_fork
10
- Http::ThreadPool.before_fork
11
-
12
- res = super
4
+ module CTanker
5
+ module ForkHook
6
+ def _fork(*args)
7
+ CTanker.tanker_before_fork
8
+ super
9
+ ensure
10
+ CTanker.tanker_after_fork
11
+ end
13
12
 
14
- CTanker.tanker_after_fork
15
- puts "### PID=#{Process.pid} TANKER-CORE AFTER FORK HOOK"
16
- res
13
+ def self.install
14
+ Process.singleton_class.prepend(self)
15
+ end
17
16
  end
18
- prepend_features(Process.singleton_class)
19
17
  end
20
18
  end
@@ -10,6 +10,7 @@ require_relative 'c_tanker/c_future'
10
10
  require_relative 'c_tanker/c_verification'
11
11
  require_relative 'c_tanker/c_verification_method'
12
12
  require_relative 'c_tanker/c_log_record'
13
+ require_relative 'c_tanker/fork_hook'
13
14
 
14
15
  module Tanker
15
16
  module CTanker
@@ -98,6 +99,8 @@ module Tanker
98
99
 
99
100
  blocking_attach_function :tanker_before_fork, [], :void
100
101
  blocking_attach_function :tanker_after_fork, [], :void
102
+
103
+ ForkHook.install
101
104
  end
102
105
 
103
106
  private_constant :CTanker
@@ -85,7 +85,6 @@ module Tanker
85
85
  @queue = nil
86
86
 
87
87
  def self.init
88
- puts "### PID=#{Process.pid} TANKER-CORE HTTP THREADPOOL INIT"
89
88
  # Queue is a concurrent queue in Ruby
90
89
  @queue = Queue.new
91
90
  @http_thread_pool = THREAD_POOL_SIZE.times do
@@ -96,7 +95,6 @@ module Tanker
96
95
  end
97
96
 
98
97
  def self.thread_loop
99
- puts "### PID=#{Process.pid} TANKER-CORE HTTP THREADPOOL WORKER LOOP STARTED"
100
98
  loop do
101
99
  work = @queue.pop
102
100
  work.call
@@ -104,16 +102,27 @@ module Tanker
104
102
  end
105
103
 
106
104
  def self.push(proc)
107
- puts "### PID=#{Process.pid} TANKER-CORE HTTP THREADPOOL PUSH"
108
105
  init if @queue.nil?
109
106
  @queue << proc
110
107
  end
111
108
 
112
109
  def self.before_fork
113
- puts "### PID=#{Process.pid} TANKER-CORE HTTP THREADPOOL BEFORE FORK"
114
110
  @http_thread_pool = nil
115
111
  @queue = nil
116
112
  end
113
+
114
+ module ForkHook
115
+ def _fork(*args)
116
+ ThreadPool.before_fork
117
+ super
118
+ end
119
+
120
+ def self.install
121
+ Process.singleton_class.prepend(self)
122
+ end
123
+ end
124
+
125
+ ForkHook.install
117
126
  end
118
127
 
119
128
  class Client
@@ -183,7 +192,6 @@ module Tanker
183
192
  end
184
193
 
185
194
  def send_request(crequest, _cdata)
186
- puts "### PID=#{Process.pid} TANKER-CORE HTTP SEND_REQUEST CALLED"
187
195
  request = HttpRequest.new(crequest:)
188
196
  ThreadPool.push(proc do
189
197
  process_request request
@@ -6,6 +6,10 @@ module Tanker
6
6
  @log_handler_lock = Mutex.new
7
7
  @log_handler_set = 0
8
8
 
9
+ def self.before_fork
10
+ @log_handler_set = 0
11
+ end
12
+
9
13
  def self.test_and_set_log_handler
10
14
  @log_handler_lock.synchronize do
11
15
  is_set = @log_handler_set
@@ -23,8 +27,6 @@ module Tanker
23
27
  end
24
28
 
25
29
  def initialize(options)
26
- puts "### PID=#{Process.pid} TANKER-CORE initialize, about to call CTanker.tanker_init"
27
-
28
30
  # tanker_init is not called globally to avoid potential logs at global scope
29
31
  # some frameworks like to pre-execute statements at global scope and then fork, this fork can
30
32
  # interact badly with the threads used in the log handler, so never call Tanker at global scope
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Tanker
4
4
  class Core
5
- VERSION = '4.2.1.alpha.8'
5
+ VERSION = '4.2.1.alpha.10'
6
6
 
7
7
  def self.native_version
8
8
  CTanker.tanker_version_string
data/lib/tanker/core.rb CHANGED
@@ -17,4 +17,3 @@ require_relative 'core/encryption_session'
17
17
  require_relative 'core/log_record'
18
18
  require_relative 'core/attach_result'
19
19
  require_relative 'core/init'
20
- require 'tanker/c_tanker/fork_hook'
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: 4.2.1.alpha.8
4
+ version: 4.2.1.alpha.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tanker team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-16 00:00:00.000000000 Z
11
+ date: 2024-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday