cloudi 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data.tar.gz.sig +0 -0
  2. data/lib/cloudi.rb +51 -31
  3. metadata +10 -10
  4. metadata.gz.sig +0 -0
data.tar.gz.sig CHANGED
Binary file
@@ -3,13 +3,13 @@
3
3
  # ex: set ft=ruby fenc=utf-8 sts=4 ts=4 sw=4 et nomod:
4
4
  #
5
5
  # BSD LICENSE
6
- #
7
- # Copyright (c) 2011-2016, Michael Truog <mjtruog at gmail dot com>
6
+ #
7
+ # Copyright (c) 2011-2017, Michael Truog <mjtruog at gmail dot com>
8
8
  # All rights reserved.
9
- #
9
+ #
10
10
  # Redistribution and use in source and binary forms, with or without
11
11
  # modification, are permitted provided that the following conditions are met:
12
- #
12
+ #
13
13
  # * Redistributions of source code must retain the above copyright
14
14
  # notice, this list of conditions and the following disclaimer.
15
15
  # * Redistributions in binary form must reproduce the above copyright
@@ -22,7 +22,7 @@
22
22
  # * The name of the author may not be used to endorse or promote
23
23
  # products derived from this software without specific prior
24
24
  # written permission
25
- #
25
+ #
26
26
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
27
27
  # CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
28
28
  # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@@ -176,9 +176,9 @@ module CloudI
176
176
  return poll_request(nil, false)
177
177
  end
178
178
 
179
- def forward_(command, name, request_info, request,
179
+ def forward_(request_type, name, request_info, request,
180
180
  timeout, priority, trans_id, pid)
181
- case command
181
+ case request_type
182
182
  when ASYNC
183
183
  forward_async(name, request_info, request,
184
184
  timeout, priority, trans_id, pid)
@@ -222,7 +222,7 @@ module CloudI
222
222
  end
223
223
  end
224
224
  end
225
- send(Erlang.term_to_binary([:forward_sync, name,
225
+ send(Erlang.term_to_binary([:forward_sync, name,
226
226
  OtpErlangBinary.new(request_info),
227
227
  OtpErlangBinary.new(request),
228
228
  timeout, priority,
@@ -230,9 +230,9 @@ module CloudI
230
230
  raise ForwardSyncException.new()
231
231
  end
232
232
 
233
- def return_(command, name, pattern, response_info, response,
233
+ def return_(request_type, name, pattern, response_info, response,
234
234
  timeout, trans_id, pid)
235
- case command
235
+ case request_type
236
236
  when ASYNC
237
237
  return_async(name, pattern, response_info, response,
238
238
  timeout, trans_id, pid)
@@ -301,7 +301,7 @@ module CloudI
301
301
  return poll_request(nil, false)
302
302
  end
303
303
 
304
- def null_response(command, name, pattern, request_info, request,
304
+ def null_response(request_type, name, pattern, request_info, request,
305
305
  timeout, priority, trans_id, pid)
306
306
  return ''
307
307
  end
@@ -444,8 +444,17 @@ module CloudI
444
444
  raise TerminateException.new(@timeout_terminate)
445
445
  end
446
446
  when MESSAGE_REINIT
447
- i += j; j = 4
448
- @process_count = data[i, j].unpack('L')[0]
447
+ i += j; j = 4 + 4 + 4 + 1 + 1
448
+ tmp = data[i, j].unpack("LLLcC")
449
+ @process_count = tmp[0]
450
+ @timeout_async = tmp[1]
451
+ @timeout_sync = tmp[2]
452
+ @priority_default = tmp[3]
453
+ @request_timeout_adjustment = (tmp[4] != 0)
454
+ if @request_timeout_adjustment
455
+ @request_timer = Time.now
456
+ @request_timeout = 0
457
+ end
449
458
  i += j
450
459
  when MESSAGE_KEEPALIVE
451
460
  send(Erlang.term_to_binary(:keepalive))
@@ -487,7 +496,7 @@ module CloudI
487
496
  if result[2].length > 0
488
497
  return false
489
498
  end
490
-
499
+
491
500
  data = recv('')
492
501
  data_size = data.bytesize
493
502
  if data_size == 0
@@ -608,11 +617,20 @@ module CloudI
608
617
  end
609
618
  API.assert{false}
610
619
  when MESSAGE_REINIT
611
- i += j; j = 4
612
- @process_count = data[i, j].unpack('L')[0]
620
+ i += j; j = 4 + 4 + 4 + 1 + 1
621
+ tmp = data[i, j].unpack("LLLcC")
622
+ @process_count = tmp[0]
623
+ @timeout_async = tmp[1]
624
+ @timeout_sync = tmp[2]
625
+ @priority_default = tmp[3]
626
+ @request_timeout_adjustment = (tmp[4] != 0)
627
+ if @request_timeout_adjustment
628
+ @request_timer = Time.now
629
+ @request_timeout = 0
630
+ end
613
631
  i += j; j = 4
614
632
  if i == data_size
615
- #
633
+ data.clear()
616
634
  elsif i < data_size
617
635
  next
618
636
  else
@@ -622,7 +640,7 @@ module CloudI
622
640
  send(Erlang.term_to_binary(:keepalive))
623
641
  i += j; j = 4
624
642
  if i == data_size
625
- #
643
+ data.clear()
626
644
  elsif i < data_size
627
645
  next
628
646
  else
@@ -658,7 +676,7 @@ module CloudI
658
676
  if result[2].length > 0
659
677
  return false
660
678
  end
661
-
679
+
662
680
  data = recv(data)
663
681
  data_size = data.bytesize
664
682
  if data_size == 0
@@ -691,10 +709,6 @@ module CloudI
691
709
  return result
692
710
  end
693
711
 
694
- def request_http_qs_parse(request)
695
- return text_key_value_parse(request)
696
- end
697
-
698
712
  def info_key_value_parse(message_info)
699
713
  return text_key_value_parse(message_info)
700
714
  end
@@ -717,25 +731,31 @@ module CloudI
717
731
  @s.write(data)
718
732
  end
719
733
 
720
- def recv(data)
734
+ def recv(data_old)
735
+ data = ''
721
736
  if @use_header
722
- while data.length < 4
723
- fragment = @s.readpartial(@size)
737
+ i = 0
738
+ while i < 4
739
+ fragment = @s.readpartial(4 - i)
724
740
  data += fragment
741
+ i += fragment.length
725
742
  end
726
- total = data[0,4].unpack('N')[0]
727
- data.slice!(0..3)
728
- while data.length < total
729
- fragment = @s.readpartial(@size)
743
+ total = data.unpack('N')[0]
744
+ data = data_old
745
+ i = 0
746
+ while i < total
747
+ fragment = @s.readpartial([total - i, @size].min)
730
748
  data += fragment
749
+ i += fragment.length
731
750
  end
732
751
  else
752
+ data = data_old
733
753
  ready = true
734
754
  while ready == true
735
755
  fragment = @s.readpartial(@size)
736
756
  data += fragment
737
757
  ready = (fragment.bytesize == @size)
738
-
758
+
739
759
  if ready
740
760
  ready = ! IO.select([@s], nil, nil, 0).nil?
741
761
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -36,7 +36,7 @@ cert_chain:
36
36
  a0RidVd1bUN6dS9SQWdobFZDOVJGRlF0N28xU3dHUXAKTGR2WU9lSmJ2aXlp
37
37
  SDFxMXJDM05BSk5DNFA3UTQxengxT1lhOFM5TTVxbitKcEUwWnNvbW5aeUd1
38
38
  bldheWE5UQpiVEQvYXc9PQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
39
- date: 2017-01-10 00:00:00.000000000 Z
39
+ date: 2017-03-28 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: erlang_rb
@@ -45,10 +45,10 @@ dependencies:
45
45
  requirements:
46
46
  - - ~>
47
47
  - !ruby/object:Gem::Version
48
- version: '1.6'
48
+ version: '1.7'
49
49
  - - ! '>='
50
50
  - !ruby/object:Gem::Version
51
- version: 1.6.0
51
+ version: 1.7.0
52
52
  type: :runtime
53
53
  prerelease: false
54
54
  version_requirements: !ruby/object:Gem::Requirement
@@ -56,10 +56,10 @@ dependencies:
56
56
  requirements:
57
57
  - - ~>
58
58
  - !ruby/object:Gem::Version
59
- version: '1.6'
59
+ version: '1.7'
60
60
  - - ! '>='
61
61
  - !ruby/object:Gem::Version
62
- version: 1.6.0
62
+ version: 1.7.0
63
63
  - !ruby/object:Gem::Dependency
64
64
  name: erlang_rb
65
65
  requirement: !ruby/object:Gem::Requirement
@@ -67,10 +67,10 @@ dependencies:
67
67
  requirements:
68
68
  - - ~>
69
69
  - !ruby/object:Gem::Version
70
- version: '1.6'
70
+ version: '1.7'
71
71
  - - ! '>='
72
72
  - !ruby/object:Gem::Version
73
- version: 1.6.0
73
+ version: 1.7.0
74
74
  type: :development
75
75
  prerelease: false
76
76
  version_requirements: !ruby/object:Gem::Requirement
@@ -78,10 +78,10 @@ dependencies:
78
78
  requirements:
79
79
  - - ~>
80
80
  - !ruby/object:Gem::Version
81
- version: '1.6'
81
+ version: '1.7'
82
82
  - - ! '>='
83
83
  - !ruby/object:Gem::Version
84
- version: 1.6.0
84
+ version: 1.7.0
85
85
  description: Ruby CloudI API
86
86
  email: mjtruog@gmail.com
87
87
  executables: []
metadata.gz.sig CHANGED
Binary file