bayserver-core 3.0.0 → 3.0.2

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: 38bca64c229f0bad4d592192eeff7d6daefdc188399675a1fc60f8ba768294ef
4
- data.tar.gz: 2020fd1e4f422ce497dd12b8c6107101a4c3e15cc22fda349edc689d8542a4d6
3
+ metadata.gz: f16ef089e90f79b3ab9ff9e3ad60146b5fc25cc1aa569981ffc2f23738e75ed4
4
+ data.tar.gz: 8de08a5578314ed72c24b5580da7f9b819d1a42b218db39785490725646f00c8
5
5
  SHA512:
6
- metadata.gz: 6b8d633c192766082c8e9d9cfa5b161aa982803b55d0f5c3e6a09c86b3aac65b549254f9dca34fd4f8cf4b1f68d4cb1c6ae2d1f9f5236ade26b753eedd62c607
7
- data.tar.gz: 58458cf12a212850c552c08827cdee15e6e7bd78fdf4bd9b87e22505fe034c843494fc008566b7b73a4c3a4b4c72e150f810e8b320caa6670f941667afbde12a
6
+ metadata.gz: 88238e6b083141720fd92f5816e7a66c49b39d93a656514ca81c2edfbfa312efb9daf6f34f0390ce2c035138d998e3eb56223170b47b180bc676337fb4236812
7
+ data.tar.gz: 137cbe39e65d8d3144e17767f49d136764a19ca9b299a8b55817daad5a1650bacc042f2561e92f21e7411706eaf0afda6e752abfb6d68223c3d2e6126c20276b
@@ -39,46 +39,6 @@ module Baykit
39
39
  @signal_map = {}
40
40
  @signal_agent = nil
41
41
 
42
- attr :port
43
- attr :server_skt
44
-
45
- def initialize(port)
46
- @port = port
47
- @server_skt = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
48
- @server_skt.setsockopt(Socket::SOL_SOCKET,Socket::SO_REUSEADDR, true)
49
- adr = Socket.sockaddr_in(@port, "127.0.0.1")
50
- @server_skt.bind(adr)
51
- @server_skt.listen(0)
52
- BayLog.info( BayMessage.get(:MSG_OPEN_CTL_PORT, @port))
53
- end
54
-
55
- def on_socket_readable()
56
-
57
- begin
58
- skt, = @server_skt.accept
59
- skt.setsockopt(Socket::SOL_SOCKET, Socket::SO_RCVTIMEO, [5, 0].pack("l_2"))
60
-
61
- line = skt.readline.strip()
62
- BayLog.info(BayMessage.get(:MSG_COMMAND_RECEIVED, line))
63
- SignalAgent.handle_command(line)
64
- skt.write("OK\n")
65
- skt.flush
66
-
67
- rescue => e
68
- BayLog.error_e(e)
69
-
70
- ensure
71
- if skt
72
- skt.close()
73
- end
74
- end
75
-
76
- end
77
-
78
- def close
79
- @server_skt.close
80
- end
81
-
82
42
 
83
43
  ######################################################
84
44
  # class methods
@@ -92,7 +52,7 @@ module Baykit
92
52
  end
93
53
 
94
54
  if bay_port > 0
95
- @signal_agent = SignalAgent.new(bay_port)
55
+ run_signal_agent(bay_port)
96
56
  end
97
57
  end
98
58
 
@@ -153,9 +113,36 @@ module Baykit
153
113
  end
154
114
  end
155
115
 
156
- def SignalAgent.term()
157
- if @signal_agent
158
- @signal_agent.close()
116
+ def self.run_signal_agent(port)
117
+ Thread.new do
118
+ server_skt = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
119
+ server_skt.setsockopt(Socket::SOL_SOCKET,Socket::SO_REUSEADDR, true)
120
+ adr = Socket.sockaddr_in(port, "127.0.0.1")
121
+ server_skt.bind(adr)
122
+ server_skt.listen(0)
123
+ BayLog.info( BayMessage.get(:MSG_OPEN_CTL_PORT, @port))
124
+
125
+ while true
126
+ begin
127
+ skt, = server_skt.accept
128
+ skt.setsockopt(Socket::SOL_SOCKET, Socket::SO_RCVTIMEO, [5, 0].pack("l_2"))
129
+
130
+ line = skt.readline.strip()
131
+ BayLog.info(BayMessage.get(:MSG_COMMAND_RECEIVED, line))
132
+ SignalAgent.handle_command(line)
133
+ skt.write("OK\n")
134
+ skt.flush
135
+
136
+ rescue => e
137
+ BayLog.error_e(e)
138
+
139
+ ensure
140
+ if skt
141
+ skt.close()
142
+ end
143
+ end
144
+
145
+ end
159
146
  end
160
147
  end
161
148
  end
@@ -275,32 +275,6 @@ module Baykit
275
275
 
276
276
  return
277
277
 
278
- while not GrandAgentMonitor.monitors.empty?
279
- sel = Selector.new()
280
- pip_to_mon_map = {}
281
- GrandAgentMonitor.monitors.values.each do |mon|
282
- BayLog.debug("Monitoring pipe of %s", mon)
283
- sel.register(mon.communication_channel, Selector::OP_READ)
284
- pip_to_mon_map[mon.communication_channel] = mon
285
- end
286
- server_skt = nil
287
- if SignalAgent.signal_agent
288
- server_skt = SignalAgent.signal_agent.server_skt
289
- sel.register(server_skt, Selector::OP_READ)
290
- end
291
-
292
- selected_map = sel.select(nil)
293
- selected_map.keys().each do |ch|
294
- if ch == server_skt
295
- SignalAgent.signal_agent.on_socket_readable()
296
- else
297
- mon = pip_to_mon_map[ch]
298
- mon.on_readable()
299
- end
300
- end
301
- end
302
-
303
- SignalAgent.term()
304
278
 
305
279
  rescue => err
306
280
  BayLog.fatal_e(err, "%s", err.message)
@@ -32,7 +32,7 @@ module Baykit
32
32
  attr :headers
33
33
  attr_accessor :charset
34
34
  attr :available
35
- attr :consume_listener
35
+ attr :res_consume_listener
36
36
 
37
37
  attr_accessor :header_sent
38
38
  attr :yacht
@@ -74,7 +74,7 @@ module Baykit
74
74
  end
75
75
 
76
76
  @available = false
77
- @consume_listener = nil
77
+ @res_consume_listener = nil
78
78
 
79
79
  @can_compress = false
80
80
  @compressor = nil
@@ -156,12 +156,16 @@ module Baykit
156
156
  end
157
157
 
158
158
  def set_consume_listener(&listener)
159
- @consume_listener = listener
159
+ @res_consume_listener = listener
160
160
  @bytes_consumed = 0
161
161
  @bytes_posted = 0
162
162
  @available = true
163
163
  end
164
164
 
165
+ def detach_consume_listener
166
+ @res_consume_listener = nil
167
+ end
168
+
165
169
  def send_res_content(chk_tour_id, buf, ofs, len)
166
170
  @tour.check_tour_id(chk_tour_id)
167
171
  BayLog.debug("%s sendContent len=%d", @tour, len)
@@ -182,7 +186,7 @@ module Baykit
182
186
  end
183
187
 
184
188
 
185
- if @consume_listener == nil
189
+ if @res_consume_listener == nil
186
190
  raise Sink.new("Response consume listener is null")
187
191
  end
188
192
 
@@ -277,9 +281,6 @@ module Baykit
277
281
 
278
282
  def consumed(check_id, length)
279
283
  @tour.check_tour_id(check_id)
280
- if @consume_listener == nil
281
- raise Sink.new("Response consume listener is null")
282
- end
283
284
 
284
285
  @bytes_consumed += length
285
286
 
@@ -297,7 +298,11 @@ module Baykit
297
298
  end
298
299
 
299
300
  if !@tour.zombie?
300
- @consume_listener.call(length, resume)
301
+ if @res_consume_listener == nil
302
+ BayLog.debug("%s Consume listener is null, so can not invoke callback", self)
303
+ else
304
+ @res_consume_listener.call(length, resume)
305
+ end
301
306
  end
302
307
  end
303
308
 
@@ -1,7 +1,7 @@
1
1
  module Baykit
2
2
  module BayServer
3
3
  class Version
4
- VERSION='3.0.0'
4
+ VERSION='3.0.2'
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bayserver-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michisuke-P
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-15 00:00:00.000000000 Z
11
+ date: 2024-11-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: BayServer is one of the high-speed web servers. It operates as a single-threaded,
14
14
  asynchronous server, which makes it exceptionally fast. It also supports multi-core