dango 0.4.6 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/dango/framework_base.rb +20 -10
- data/lib/dango/server_framework.rb +9 -5
- data/lib/dango/version.rb +1 -1
- metadata +4 -4
data/lib/dango/framework_base.rb
CHANGED
@@ -56,10 +56,12 @@ class DangoFrameworkTimeoutException < DangoFrameworkException; end
|
|
56
56
|
class DangoFrameworkConnectionException < DangoFrameworkException; end
|
57
57
|
class DangoFrameworkDisconnectException < DangoFrameworkException; end
|
58
58
|
class DangoFrameworkReadNoDataException < DangoFrameworkException; end
|
59
|
+
class DangoFrameworkReadTimeoutException < DangoFrameworkException; end
|
59
60
|
class DangoFrameworkFlashPolicyException < DangoFrameworkException; end
|
60
61
|
class DangoFrameworkMonitorSecurityException < DangoFrameworkException; end
|
61
62
|
class DangoFrameworkTransactionException < DangoFrameworkException; end
|
62
63
|
|
64
|
+
|
63
65
|
# エラー出力用モジュール
|
64
66
|
module ErrorMessage
|
65
67
|
# デバッグ出力用のメソッド
|
@@ -114,6 +116,8 @@ module DangoFrameworkModule
|
|
114
116
|
|
115
117
|
DefaultEncodeType = EncodeTypeJSON # デフォルトのエンコードのタイプ
|
116
118
|
|
119
|
+
ReadTimeoutSec = 10.0 # データ受信のタイムアウト秒数
|
120
|
+
|
117
121
|
|
118
122
|
# デバッグ出力用のメソッド
|
119
123
|
def debug_print(str)
|
@@ -161,6 +165,7 @@ module DangoFrameworkModule
|
|
161
165
|
|
162
166
|
# データ受信処理
|
163
167
|
def dango_receive_data(sock)
|
168
|
+
logger.debug "dango_receive_data:start:sock=#{sock}"
|
164
169
|
ret_data = ""
|
165
170
|
|
166
171
|
begin
|
@@ -202,17 +207,22 @@ module DangoFrameworkModule
|
|
202
207
|
|
203
208
|
ret_data_orig = ""
|
204
209
|
|
205
|
-
|
206
|
-
|
207
|
-
begin
|
208
|
-
this_ret_data_orig = sock.recv(read_len)
|
209
|
-
rescue
|
210
|
-
raise(DangoFrameworkConnectionException, "failed to read sock(data).\n#{error_message($!, 'u')}")
|
211
|
-
end
|
212
|
-
|
213
|
-
ret_data_orig += this_ret_data_orig
|
210
|
+
# 10秒でタイムアウトを起こす
|
211
|
+
timeout(ReadTimeoutSec, DangoFrameworkReadTimeoutException) do
|
214
212
|
|
215
|
-
|
213
|
+
# サイズが0になるまで受信し続ける
|
214
|
+
while size > 0
|
215
|
+
read_len = MaxLenRecv > size ? size : MaxLenRecv
|
216
|
+
begin
|
217
|
+
this_ret_data_orig = sock.recv(read_len)
|
218
|
+
rescue
|
219
|
+
raise(DangoFrameworkConnectionException, "failed to read sock(data).\n#{error_message($!, 'u')}")
|
220
|
+
end
|
221
|
+
|
222
|
+
ret_data_orig += this_ret_data_orig
|
223
|
+
|
224
|
+
size -= this_ret_data_orig.size
|
225
|
+
end
|
216
226
|
end
|
217
227
|
|
218
228
|
ret_data = dango_receive_decrypt(ret_data_orig[0..-2])
|
@@ -72,7 +72,7 @@ class DangoServerFramework
|
|
72
72
|
|
73
73
|
def exit_process() # プロセス終了処理
|
74
74
|
debug_print("shutdown")
|
75
|
-
if @
|
75
|
+
if @is_pid_file_create_time == File.mtime(@pid_file)
|
76
76
|
begin
|
77
77
|
File.delete(@pid_file)
|
78
78
|
rescue
|
@@ -89,7 +89,7 @@ class DangoServerFramework
|
|
89
89
|
@gserver = nil # Gserver用の変数
|
90
90
|
@server_reload = nil # サーバーのリロード用フラグ
|
91
91
|
|
92
|
-
@
|
92
|
+
@is_pid_file_create_time = nil # pidファイルを作ったかどうかのフラグ
|
93
93
|
|
94
94
|
# SIGINT の捕捉
|
95
95
|
Signal.trap(:INT) do
|
@@ -187,7 +187,7 @@ class DangoServerFramework
|
|
187
187
|
|
188
188
|
GC.disable
|
189
189
|
open(@pid_file, "wb"){|fh| fh.write Process.pid.to_s } # pidをファイルに保存
|
190
|
-
@
|
190
|
+
@is_pid_file_create_time = File.mtime(@pid_file) # pidファイルを作ったことを記録
|
191
191
|
|
192
192
|
# @gserver.start(@server_max_connections)
|
193
193
|
@gserver.start(@server_max_connections, 20) # backlogを20に設定
|
@@ -333,11 +333,11 @@ class DangoServerFramework
|
|
333
333
|
do_flash_policy_file(sid, sock)
|
334
334
|
|
335
335
|
# この部分はポリシーファイルを返す設定に関係なく実行する部分
|
336
|
-
sleep 0.1
|
336
|
+
# sleep 0.1
|
337
337
|
raise(DangoFrameworkFlashPolicyException, "requested policy file. disconnectiong...")
|
338
338
|
|
339
339
|
elsif ret_objs == [] # 受信データがなければ
|
340
|
-
|
340
|
+
logger.debug "ret_objs is empty. "
|
341
341
|
|
342
342
|
else # 受信データがあれば
|
343
343
|
ret_objs.each do |ret_obj| # 受信データループ
|
@@ -413,6 +413,10 @@ class DangoServerFramework
|
|
413
413
|
@recv_fail_count += 1 if @recv_fail_count # 受信失敗回数カウント
|
414
414
|
logger.debug "read no data. maybe client closed. #{sid} "
|
415
415
|
|
416
|
+
rescue DangoFrameworkReadTimeoutException
|
417
|
+
@recv_fail_count += 1 if @recv_fail_count # 受信失敗回数カウント
|
418
|
+
logger.debug "read timeout error. #{sid} \n#{error_message($!, 'u')}"
|
419
|
+
|
416
420
|
rescue DangoFrameworkConnectionException
|
417
421
|
@recv_fail_count += 1 if @recv_fail_count # 受信失敗回数カウント
|
418
422
|
logger.debug "connection error. #{sid} \n#{error_message($!, 'u')}"
|
data/lib/dango/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dango
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keisuke Minami
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-10-
|
12
|
+
date: 2008-10-07 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -28,9 +28,9 @@ dependencies:
|
|
28
28
|
version_requirement:
|
29
29
|
version_requirements: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0
|
33
|
+
version: "0"
|
34
34
|
version:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: hoe
|