@@ -97,14 +97,6 @@ type runState struct {
97
97
confCount uint32
98
98
rsCount uint32
99
99
100
- run int
101
- mtot int
102
- clients []* client
103
- excluded []* client
104
- vk []ed25519.PublicKey
105
- mcounts []int
106
- roots []* big.Int
107
-
108
100
allKEs chan struct {}
109
101
allSRs chan struct {}
110
102
allDCs chan struct {}
@@ -116,7 +108,7 @@ type runState struct {
116
108
}
117
109
118
110
type session struct {
119
- runState
111
+ runs [] runState
120
112
121
113
sid []byte
122
114
msgses * messages.Session
@@ -125,6 +117,14 @@ type session struct {
125
117
newm func () (Mixer , error )
126
118
mix Mixer
127
119
120
+ run int
121
+ mtot int
122
+ clients []* client
123
+ excluded []* client
124
+ vk []ed25519.PublicKey
125
+ mcounts []int
126
+ roots []* big.Int
127
+
128
128
pids map [string ]int
129
129
mu sync.Mutex
130
130
@@ -422,28 +422,28 @@ func (s *Server) pairSessions(ctx context.Context) error {
422
422
}
423
423
sid := s .sidPRNG .Next (32 )
424
424
ses := & session {
425
- runState : runState {
426
- allKEs : make (chan struct {}),
427
- allSRs : make (chan struct {}),
428
- allDCs : make (chan struct {}),
429
- allConfs : make (chan struct {}),
430
- allRSs : make (chan struct {}),
431
- mtot : totalMessages ,
432
- clients : clients ,
433
- vk : vk ,
434
- mcounts : mcounts ,
435
- blaming : make (chan struct {}),
436
- rerunning : make (chan struct {}),
437
- },
438
- sid : sid ,
439
- msgses : messages .NewSession (sid , 0 , vk ),
440
- br : messages .BeginRun (vk , mcounts , sid ),
441
- msize : s .msize ,
442
- newm : newm ,
443
- mix : mix ,
444
- pids : pids ,
445
- report : s .report ,
425
+ sid : sid ,
426
+ msgses : messages .NewSession (sid , 0 , vk ),
427
+ br : messages .BeginRun (vk , mcounts , sid ),
428
+ msize : s .msize ,
429
+ newm : newm ,
430
+ mix : mix ,
431
+ mtot : totalMessages ,
432
+ clients : clients ,
433
+ vk : vk ,
434
+ mcounts : mcounts ,
435
+ pids : pids ,
436
+ report : s .report ,
446
437
}
438
+ ses .runs = append (ses .runs , runState {
439
+ allKEs : make (chan struct {}),
440
+ allSRs : make (chan struct {}),
441
+ allDCs : make (chan struct {}),
442
+ allConfs : make (chan struct {}),
443
+ allRSs : make (chan struct {}),
444
+ blaming : make (chan struct {}),
445
+ rerunning : make (chan struct {}),
446
+ })
447
447
pairs = append (pairs , ses )
448
448
}
449
449
s .pairingsMu .Unlock ()
@@ -524,7 +524,7 @@ func (s *session) exclude(blamed []int) error {
524
524
defer s .mu .Unlock ()
525
525
s .mu .Lock ()
526
526
527
- close (s .rerunning )
527
+ close (s .runs [ s . run ]. rerunning )
528
528
s .run ++
529
529
530
530
log .Printf ("excluding %v" , blamed )
@@ -574,22 +574,19 @@ func (s *session) exclude(blamed []int) error {
574
574
return err
575
575
}
576
576
577
- s .keCount = 0
578
- s .srCount = 0
579
- s .dcCount = 0
580
- s .confCount = 0
581
- s .rsCount = 0
582
- s .allKEs = make (chan struct {})
583
- s .allSRs = make (chan struct {})
584
- s .allDCs = make (chan struct {})
585
- s .allConfs = make (chan struct {})
586
- s .allRSs = make (chan struct {})
577
+ s .runs = append (s .runs , runState {
578
+ allKEs : make (chan struct {}),
579
+ allSRs : make (chan struct {}),
580
+ allDCs : make (chan struct {}),
581
+ allConfs : make (chan struct {}),
582
+ allRSs : make (chan struct {}),
583
+ blaming : make (chan struct {}),
584
+ rerunning : make (chan struct {}),
585
+ })
587
586
s .roots = nil
588
587
s .msgses = messages .NewSession (s .sid , s .run , s .vk )
589
588
s .br = messages .BeginRun (s .vk , s .mcounts , s .sid )
590
589
s .mix = mix
591
- s .blaming = make (chan struct {})
592
- s .rerunning = make (chan struct {})
593
590
594
591
for _ , c := range s .clients {
595
592
select {
@@ -651,12 +648,13 @@ func (s *session) doRun(ctx context.Context) (err error) {
651
648
}()
652
649
653
650
var blamed blamePIDs
651
+ st := & s .runs [s .run ]
654
652
655
653
// Wait for all KE messages, or KE timeout.
656
654
select {
657
655
case <- ctx .Done ():
658
656
return ctx .Err ()
659
- case <- s .allKEs :
657
+ case <- st .allKEs :
660
658
log .Print ("received all KE messages" )
661
659
case <- time .After (recvTimeout ):
662
660
log .Print ("KE timeout" )
@@ -699,15 +697,15 @@ func (s *session) doRun(ctx context.Context) (err error) {
699
697
select {
700
698
case <- ctx .Done ():
701
699
return ctx .Err ()
702
- case <- s .allSRs :
700
+ case <- st .allSRs :
703
701
log .Print ("received all SR messages" )
704
702
case <- time .After (recvTimeout ):
705
703
log .Print ("SR timeout" )
706
704
}
707
705
708
706
// Solve roots.
709
707
s .mu .Lock ()
710
- blaming := s .blaming
708
+ blaming := st .blaming
711
709
vs := make ([][]* big.Int , 0 , len (s .clients ))
712
710
for i , c := range s .clients {
713
711
if c .sr == nil {
@@ -748,7 +746,7 @@ func (s *session) doRun(ctx context.Context) (err error) {
748
746
select {
749
747
case <- ctx .Done ():
750
748
return ctx .Err ()
751
- case <- s .allDCs :
749
+ case <- st .allDCs :
752
750
log .Print ("received all DC messages" )
753
751
case <- time .After (recvTimeout ):
754
752
log .Print ("DC timeout" )
@@ -805,7 +803,7 @@ func (s *session) doRun(ctx context.Context) (err error) {
805
803
select {
806
804
case <- ctx .Done ():
807
805
return ctx .Err ()
808
- case <- s .allConfs :
806
+ case <- st .allConfs :
809
807
log .Print ("received all CM messages" )
810
808
case <- time .After (recvTimeout ):
811
809
log .Print ("CM timeout" )
@@ -899,13 +897,14 @@ func (c *client) run(ctx context.Context, run int, s *session, ke *messages.KE)
899
897
log .Printf ("recv(%v) KE Run:%d Commitment:%x" , c .raddr (), ke .Run , ke .Commitment )
900
898
901
899
s .mu .Lock ()
900
+ st := & s .runs [run ]
902
901
c .ke = ke
903
- s .keCount ++
904
- if s .keCount == uint32 (len (s .clients )) {
905
- close (s .allKEs )
902
+ st .keCount ++
903
+ if st .keCount == uint32 (len (s .clients )) {
904
+ close (st .allKEs )
906
905
}
907
- blaming := s .blaming
908
- rerunning := s .rerunning
906
+ blaming := st .blaming
907
+ rerunning := st .rerunning
909
908
s .mu .Unlock ()
910
909
911
910
select {
@@ -916,7 +915,7 @@ func (c *client) run(ctx context.Context, run int, s *session, ke *messages.KE)
916
915
if err != nil {
917
916
return err
918
917
}
919
- return c .blame (ctx , s )
918
+ return c .blame (ctx , s , run )
920
919
case kes := <- c .out :
921
920
err := c .sendDeadline (kes , sendTimeout )
922
921
if err != nil {
@@ -950,12 +949,12 @@ func (c *client) run(ctx context.Context, run int, s *session, ke *messages.KE)
950
949
}
951
950
}
952
951
c .sr = sr
953
- s .srCount ++
954
- if s .srCount == uint32 (len (s .clients )) {
955
- close (s .allSRs )
952
+ st .srCount ++
953
+ if st .srCount == uint32 (len (s .clients )) {
954
+ close (st .allSRs )
956
955
}
957
- blaming = s .blaming
958
- rerunning = s .rerunning
956
+ blaming = st .blaming
957
+ rerunning = st .rerunning
959
958
s .mu .Unlock ()
960
959
961
960
select {
@@ -966,7 +965,7 @@ func (c *client) run(ctx context.Context, run int, s *session, ke *messages.KE)
966
965
if err != nil {
967
966
return err
968
967
}
969
- return c .blame (ctx , s )
968
+ return c .blame (ctx , s , run )
970
969
case mix := <- c .out :
971
970
err = c .sendDeadline (mix , sendTimeout )
972
971
if err != nil {
@@ -998,17 +997,17 @@ func (c *client) run(ctx context.Context, run int, s *session, ke *messages.KE)
998
997
999
998
s .mu .Lock ()
1000
999
c .dc = dc
1001
- s .dcCount ++
1002
- if s .dcCount == uint32 (len (s .clients )) {
1003
- close (s .allDCs )
1000
+ st .dcCount ++
1001
+ if st .dcCount == uint32 (len (s .clients )) {
1002
+ close (st .allDCs )
1004
1003
}
1005
1004
mix := c .mix
1006
- blaming = s .blaming
1007
- rerunning = s .rerunning
1005
+ blaming = st .blaming
1006
+ rerunning = st .rerunning
1008
1007
s .mu .Unlock ()
1009
1008
1010
1009
if dc .RevealSecrets {
1011
- return c .blame (ctx , s )
1010
+ return c .blame (ctx , s , run )
1012
1011
}
1013
1012
1014
1013
// Send unconfirmed mix
@@ -1020,7 +1019,7 @@ func (c *client) run(ctx context.Context, run int, s *session, ke *messages.KE)
1020
1019
if err != nil {
1021
1020
return err
1022
1021
}
1023
- return c .blame (ctx , s )
1022
+ return c .blame (ctx , s , run )
1024
1023
case mix := <- c .out :
1025
1024
err = c .sendDeadline (mix , sendTimeout )
1026
1025
if err != nil {
@@ -1044,16 +1043,16 @@ func (c *client) run(ctx context.Context, run int, s *session, ke *messages.KE)
1044
1043
s .mu .Lock ()
1045
1044
c .cm = cm
1046
1045
c .mix = mix
1047
- s .confCount ++
1048
- if s .confCount == uint32 (len (s .clients )) {
1049
- close (s .allConfs )
1046
+ st .confCount ++
1047
+ if st .confCount == uint32 (len (s .clients )) {
1048
+ close (st .allConfs )
1050
1049
}
1051
- blaming = s .blaming
1052
- rerunning = s .rerunning
1050
+ blaming = st .blaming
1051
+ rerunning = st .rerunning
1053
1052
s .mu .Unlock ()
1054
1053
1055
1054
if cm .RevealSecrets {
1056
- return c .blame (ctx , s )
1055
+ return c .blame (ctx , s , run )
1057
1056
}
1058
1057
1059
1058
// Send signed mix
@@ -1065,7 +1064,7 @@ func (c *client) run(ctx context.Context, run int, s *session, ke *messages.KE)
1065
1064
if err != nil {
1066
1065
return err
1067
1066
}
1068
- return c .blame (ctx , s )
1067
+ return c .blame (ctx , s , run )
1069
1068
case out := <- c .out :
1070
1069
err = c .sendDeadline (out , sendTimeout )
1071
1070
if err != nil {
@@ -1135,10 +1134,11 @@ func (s *session) blame(ctx context.Context, reported []int) (err error) {
1135
1134
}
1136
1135
1137
1136
// Wait for all secrets, or timeout.
1137
+ st := & s .runs [s .run ]
1138
1138
select {
1139
1139
case <- ctx .Done ():
1140
1140
return ctx .Err ()
1141
- case <- s .allRSs :
1141
+ case <- st .allRSs :
1142
1142
log .Print ("received all RS messages" )
1143
1143
case <- time .After (5000 * time .Millisecond ):
1144
1144
s .mu .Lock ()
@@ -1307,18 +1307,19 @@ DCLoop:
1307
1307
1308
1308
var errRerun = errors .New ("rerun" )
1309
1309
1310
- func (c * client ) blame (ctx context.Context , s * session ) error {
1310
+ func (c * client ) blame (ctx context.Context , s * session , run int ) error {
1311
1311
rs := new (messages.RS )
1312
1312
err := c .readDeadline (rs , recvTimeout )
1313
1313
if err != nil {
1314
1314
return err
1315
1315
}
1316
1316
1317
1317
s .mu .Lock ()
1318
+ st := & s .runs [run ]
1318
1319
c .rs = rs
1319
- s .rsCount ++
1320
- if s .rsCount == uint32 (len (s .clients )) {
1321
- close (s .allRSs )
1320
+ st .rsCount ++
1321
+ if st .rsCount == uint32 (len (s .clients )) {
1322
+ close (st .allRSs )
1322
1323
}
1323
1324
s .mu .Unlock ()
1324
1325
0 commit comments