dango 0.0.11 → 0.0.12
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.
- data/lib/dango/framework_base.rb +3 -5
- data/lib/dango/server_framework.rb +46 -39
- data/lib/dango/version.rb +1 -1
- metadata +1 -1
data/lib/dango/framework_base.rb
CHANGED
@@ -242,16 +242,14 @@ module DangoFrameworkModule
|
|
242
242
|
# cs_logger.debug "send_buf:#{send_buf.inspect}"
|
243
243
|
|
244
244
|
begin
|
245
|
-
|
246
|
-
|
245
|
+
sock.write send_buf
|
246
|
+
sock.flush
|
247
247
|
|
248
248
|
# sock.send(size_str + "\n", 0)
|
249
249
|
# sock.flush
|
250
|
+
|
250
251
|
# sock.send(send_data, 0)
|
251
252
|
# sock.flush
|
252
|
-
|
253
|
-
sock.send(send_buf, 0)
|
254
|
-
sock.flush
|
255
253
|
rescue
|
256
254
|
raise(DangoFrameworkConnectionError, "sock write failed.\n#{error_message($!, 'u')}")
|
257
255
|
end
|
@@ -16,7 +16,7 @@ class DangoServerFramework
|
|
16
16
|
|
17
17
|
SendReceiveSleepIntervalSec = 0.1 # データ送信後の順の際のタイムアウトチェック間隔秒
|
18
18
|
SendReceiveTimeoutDefaultSec = 0.5 # データ送受信時のデフォルトタイムアウト秒数
|
19
|
-
|
19
|
+
SendTimeoutSec = 10.0 # データ送受信時の送信のタイムアウト秒数
|
20
20
|
|
21
21
|
class DangoGServer < GServer
|
22
22
|
def initialize(parent, *args)
|
@@ -186,9 +186,10 @@ class DangoServerFramework
|
|
186
186
|
cs_connect() # 接続時メソッド呼び出し
|
187
187
|
|
188
188
|
# 接続直後のsid通知
|
189
|
-
|
190
|
-
|
191
|
-
|
189
|
+
# Thread.start do
|
190
|
+
send_obj = {"_sid"=>session_id}
|
191
|
+
cs_server_send_data(session_id, "_notice_sid", send_obj)
|
192
|
+
# end
|
192
193
|
|
193
194
|
# メインループ入り
|
194
195
|
loop do
|
@@ -566,48 +567,54 @@ class DangoServerFramework
|
|
566
567
|
# cs_send_data(sock, send_obj_dup, :type=>dtype) # データ送信
|
567
568
|
# cs_logger.debug "cs_server_send_data:finish send data notice_name=#{notice_name.inspect}\n"
|
568
569
|
# else
|
570
|
+
if notice_name.to_s == "_notice_sid"
|
571
|
+
cs_send_data(sock, send_obj_dup, :type=>dtype) # データ送信
|
572
|
+
# cs_logger.debug "cs_server_send_data:finish send data notice_name=#{notice_name.inspect}\n"
|
573
|
+
else
|
569
574
|
Thread.start do
|
570
575
|
begin
|
571
576
|
mutex_socket_list.synchronize(session_id) do
|
572
577
|
have_came_response = nil
|
573
578
|
|
574
|
-
receive_thread =
|
575
|
-
|
579
|
+
receive_thread = Thread.start do
|
580
|
+
begin
|
581
|
+
cs_send_data(sock, send_obj_dup, :type=>dtype) # データ送信
|
582
|
+
# cs_logger.debug "cs_server_send_data:send data notice_name=#{notice_name.inspect} #{send_obj_dup['_id']}"
|
583
|
+
rescue DangoFrameworkError
|
584
|
+
cs_logger.debug "cs_server_send_data:DangoFrameworkError:notice_name=#{notice_name.inspect}\n"
|
585
|
+
end
|
586
|
+
end
|
576
587
|
|
577
|
-
#
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
# cs_logger.debug "cs_server_send_data:send data notice_name=#{notice_name.inspect} #{send_obj_dup['_id']}"
|
591
|
-
rescue DangoFrameworkError
|
592
|
-
cs_logger.debug "cs_server_send_data:DangoFrameworkError:notice_name=#{notice_name.inspect}\n"
|
593
|
-
end
|
588
|
+
# データ送信スレッドの終了待ち
|
589
|
+
if !receive_thread.join(SendTimeoutSec)
|
590
|
+
# タイムアウトの場合は
|
591
|
+
cs_logger.warn "cs_server_send_data:send timeout:#{notice_name}"
|
592
|
+
else
|
593
|
+
end_reserved_time = Time.now + timeout
|
594
|
+
|
595
|
+
# タイムアウトチェック
|
596
|
+
catch(:send_timeout) do
|
597
|
+
(timeout.to_f / SendReceiveSleepIntervalSec).to_i.times do
|
598
|
+
if Time.now > end_reserved_time
|
599
|
+
cs_logger.debug "cs_server_send_data:receive timeout:#{notice_name}"
|
600
|
+
break
|
594
601
|
end
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
+
|
603
|
+
@mutex_send_response.synchronize do
|
604
|
+
if @arr_send_response.delete(send_obj_dup["_id"])
|
605
|
+
have_came_response = true
|
606
|
+
# cs_logger.debug "response check ok:#{notice_name} #{send_obj_dup['_id'].inspect}"
|
607
|
+
throw(:send_timeout)
|
608
|
+
end
|
602
609
|
end
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
end #
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
610
|
+
|
611
|
+
sleep SendReceiveSleepIntervalSec # スリープ
|
612
|
+
end # タイムアウト処理終わり
|
613
|
+
end # catch 終わり
|
614
|
+
|
615
|
+
if !have_came_response # 戻ってきたデータがあるかどうかチェック
|
616
|
+
cs_logger.warn "!!! received data is none. #{notice_name} #{send_obj_dup['_id']}"
|
617
|
+
end
|
611
618
|
end
|
612
619
|
end
|
613
620
|
rescue
|
@@ -615,7 +622,7 @@ class DangoServerFramework
|
|
615
622
|
end
|
616
623
|
end # Thread:end
|
617
624
|
|
618
|
-
|
625
|
+
end
|
619
626
|
|
620
627
|
self
|
621
628
|
end
|
data/lib/dango/version.rb
CHANGED