Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
mpcs
dfss
Commits
498ce650
Commit
498ce650
authored
Mar 14, 2016
by
Richer Maximilien
Committed by
Loïck Bonniot
Apr 15, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[c] Implement timeout error management
parent
9018943e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
23 deletions
+23
-23
dfssc/common/sequence_analysis.go
dfssc/common/sequence_analysis.go
+1
-1
dfssc/sign/protocol.go
dfssc/sign/protocol.go
+16
-19
dfssp/api/platform.proto
dfssp/api/platform.proto
+5
-2
dfssp/contract/ready.go
dfssp/contract/ready.go
+1
-1
No files found.
dfssc/common/sequence_analysis.go
View file @
498ce650
...
...
@@ -94,7 +94,7 @@ func contains(s []uint32, e uint32) bool {
// GetAllButOne creates the slice of all sequence ids, except the one specified
func
GetAllButOne
(
s
[]
uint32
,
e
uint32
)
[]
uint32
{
res
:
=
make
([]
uint32
,
0
)
var
res
=
make
([]
uint32
,
0
)
for
i
:=
0
;
i
<
len
(
s
);
i
++
{
curID
:=
s
[
i
]
...
...
dfssc/sign/protocol.go
View file @
498ce650
...
...
@@ -3,17 +3,12 @@ package sign
import
(
"errors"
"fmt"
"log"
"strconv"
"time"
"dfss"
cAPI
"dfss/dfssc/api"
"dfss/dfssc/common"
"dfss/dfss
c/security
"
dAPI
"dfss/dfss
d/api
"
pAPI
"dfss/dfssp/api"
"dfss/dfssp/contract"
"dfss/net"
"golang.org/x/net/context"
"google.golang.org/grpc"
)
...
...
@@ -27,14 +22,14 @@ func (m *SignatureManager) Sign() error {
// Promess rounds
for
nextIndex
!=
-
1
{
pendingSet
,
err
:=
common
.
GetPendingSet
(
m
.
sequence
,
myID
,
currentIndex
)
if
err
!=
nil
{
return
err
pendingSet
,
err
1
:=
common
.
GetPendingSet
(
m
.
sequence
,
myID
,
currentIndex
)
if
err
1
!=
nil
{
return
err
1
// err is renamed to avoid shadowing err on linter check
}
sendSet
,
err
:=
common
.
GetSendSet
(
m
.
sequence
,
myID
,
currentIndex
)
if
err
!=
nil
{
return
err
sendSet
,
err
1
:=
common
.
GetSendSet
(
m
.
sequence
,
myID
,
currentIndex
)
if
err
1
!=
nil
{
return
err
1
}
// Reception of the due promesses
...
...
@@ -64,9 +59,9 @@ func (m *SignatureManager) Sign() error {
}
currentIndex
=
nextIndex
nextIndex
,
err
=
common
.
FindNextIndex
(
m
.
sequence
,
myID
,
currentIndex
)
if
err
!=
nil
{
return
err
nextIndex
,
err
1
=
common
.
FindNextIndex
(
m
.
sequence
,
myID
,
currentIndex
)
if
err
1
!=
nil
{
return
err
1
}
}
...
...
@@ -106,14 +101,16 @@ func (m *SignatureManager) SendPromise(promise *cAPI.Promise, to uint32) (*pAPI.
return
&
pAPI
.
ErrorCode
{},
err
}
// TODO
// Handle the timeout
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
10
*
time
.
Minute
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
time
.
Minute
)
defer
cancel
()
errCode
,
err
:=
(
*
connection
)
.
TreatPromise
(
ctx
,
promise
)
if
err
!=
nil
{
return
&
pAPI
.
ErrorCode
{},
err
if
err
==
grpc
.
ErrClientConnTimeout
{
dAPI
.
DLog
(
"Promise timeout for ["
+
fmt
.
Sprintf
(
"%d"
,
to
)
+
"]"
)
return
&
pAPI
.
ErrorCode
{
Code
:
pAPI
.
ErrorCode_TIMEOUT
,
Message
:
"promise timeout"
},
err
}
else
if
err
!=
nil
{
return
&
pAPI
.
ErrorCode
{
Code
:
pAPI
.
ErrorCode_INTERR
,
Message
:
"internal server error"
},
err
}
m
.
archives
.
sentPromises
=
append
(
m
.
archives
.
sentPromises
,
promise
)
...
...
dfssp/api/platform.proto
View file @
498ce650
...
...
@@ -19,8 +19,9 @@ message RegisterRequest {
string
request
=
2
;
}
// ErrorCode message contains an error code (see dffs/dfssp/api/errorCodes.go)
// and a message
// ErrorCode message contains an error code and a message
// Above or zero : target-side error
// Less than 0 : local error
message
ErrorCode
{
enum
Code
{
// SUCCESS is the error code for a successful request
...
...
@@ -33,6 +34,8 @@ message ErrorCode {
WARNING
=
3
;
// INTERR is the error code for an internal server error
INTERR
=
-
1
;
// TIMEOUT is the error code for a timeout or unreacheable target
TIMEOUT
=
-
2
;
}
Code
code
=
1
;
string
message
=
2
;
...
...
dfssp/contract/ready.go
View file @
498ce650
...
...
@@ -66,7 +66,7 @@ func ReadySign(db *mgdb.MongoManager, rooms *common.WaitingGroupMap, ctx *contex
return
nil
case
<-
time
.
After
(
10
*
time
.
Minute
)
:
rooms
.
Unjoin
(
roomID
,
channel
)
return
&
api
.
LaunchSignature
{
ErrorCode
:
&
api
.
ErrorCode
{
Code
:
api
.
ErrorCode_
INTERR
,
Message
:
"timeout"
}}
return
&
api
.
LaunchSignature
{
ErrorCode
:
&
api
.
ErrorCode
{
Code
:
api
.
ErrorCode_
TIMEOUT
,
Message
:
"timeout
for ready signal
"
}}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment