MEChat 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Chat.rb +3 -0
- data/client.rb +1 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df9c8aad3c6f17a909439a15eb05e47ee866ba66e812ef2146ad22d2b7bf1eae
|
4
|
+
data.tar.gz: ba2fc4b2a0bc150e711ed8adc3781a89babc2a59b913a60a63f5c72990303211
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb245e1baa6c763ef1aa4f5516d1ce41addc39a4ca2edc636cef7a165b6643fa0c54d0de814d1ce61d481dda019baeecf857d1c1cc7358dfec3fdac58e41fc4c
|
7
|
+
data.tar.gz: 486bc3b6b00de1f9646cb770d162d67f6b5517b12f73d9dd8c59b3b8700c399f26345ce624c4d79607dff701a8cac70cf69f6f9ab8363dee18dbb7b23ef476b1
|
data/Chat.rb
CHANGED
@@ -36,10 +36,13 @@ class Chat < DistributedChat::ChatService::Service
|
|
36
36
|
def request_critical_section(req,_call)
|
37
37
|
request = {:ip => Addrinfo.getaddrinfo(req.username.split(":")[0..-2].join(":"),req.username.split(":")[-1].to_i)[0], :message => req}
|
38
38
|
if $crit_section === 0
|
39
|
+
@logger.info "Sent reply to #{request[:ip].ip_address}:#{request[:ip].ip_port}, because I am not in critical section"
|
39
40
|
send_reply ip: request[:ip]
|
40
41
|
elsif $crit_section < 2 && request[:message].timestamp < $alg.clock
|
42
|
+
@logger.info "Sent reply to #{request[:ip].ip_address}:#{request[:ip].ip_port}, because I am entering critical section but my request is newer"
|
41
43
|
send_reply ip: request[:ip]
|
42
44
|
else
|
45
|
+
@logger.info "Delayed reply to #{request[:ip].ip_address}:#{request[:ip].ip_port}, because I am in critical section"
|
43
46
|
$alg.requests << request
|
44
47
|
end
|
45
48
|
DistributedChat::Response.new status_code: 0
|
data/client.rb
CHANGED
@@ -70,14 +70,9 @@ class Client
|
|
70
70
|
while new_msg != "exit"
|
71
71
|
$crit_section = 1
|
72
72
|
request_critical_section
|
73
|
-
sleepdur = 0
|
74
73
|
while $alg.replies.length < $nodes.length
|
75
|
-
sleepdur += 0.1
|
76
|
-
@logger.info "#{@ip.ip_address}:#{$port.to_s} waiting for replies"
|
77
74
|
sleep 0.1
|
78
|
-
|
79
|
-
puts "Waiting for replies. #{$alg.replies.length}/#{$nodes.length} replies received"
|
80
|
-
end
|
75
|
+
@logger.info "#{@ip.ip_address}:#{$port.to_s} #{$alg.replies.length}/#{$nodes.length} waiting for replies"
|
81
76
|
end
|
82
77
|
$crit_section = 2
|
83
78
|
$nodes.each do |node|
|