fix
This commit is contained in:
parent
c4098de5b4
commit
32765f9e2d
@ -83,10 +83,14 @@ func timesync(hosts []string) []client {
|
|||||||
wg.Wait()
|
wg.Wait()
|
||||||
close(responses)
|
close(responses)
|
||||||
|
|
||||||
|
fmt.Println("joł")
|
||||||
clients := make([]client, 0, len(hosts))
|
clients := make([]client, 0, len(hosts))
|
||||||
for client := range responses {
|
for client := range responses {
|
||||||
clients = append(clients, client)
|
clients = append(clients, client)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Printf("Successfully gathered %d clients\n", len(clients))
|
||||||
|
|
||||||
return clients
|
return clients
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,8 +104,7 @@ func notifyAll(clients []client) {
|
|||||||
for _, client := range clients {
|
for _, client := range clients {
|
||||||
client := client
|
client := client
|
||||||
go func() {
|
go func() {
|
||||||
myTime := time.Now().UnixMilli()
|
startTime := maxReactionTime - (client.after - client.before) / 2
|
||||||
startTime := myTime + maxReactionTime - (client.remote - client.before) + (client.after - client.before) / 2
|
|
||||||
_, err := remotef(client.addr, fmt.Sprintf("start %d", startTime), "")
|
_, err := remotef(client.addr, fmt.Sprintf("start %d", startTime), "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("failed to notify %s: %v\n", client.addr, err)
|
log.Printf("failed to notify %s: %v\n", client.addr, err)
|
||||||
@ -131,6 +134,7 @@ func main() {
|
|||||||
var clients []client
|
var clients []client
|
||||||
for s.Scan() {
|
for s.Scan() {
|
||||||
resp := s.Text()
|
resp := s.Text()
|
||||||
|
log.Println(resp)
|
||||||
if resp == "scan" {
|
if resp == "scan" {
|
||||||
conn.Write([]byte("Scanning...\n"))
|
conn.Write([]byte("Scanning...\n"))
|
||||||
scanResult = scan()
|
scanResult = scan()
|
||||||
@ -163,12 +167,7 @@ func main() {
|
|||||||
startTimeString := strings.TrimSpace(resp[len("start"):])
|
startTimeString := strings.TrimSpace(resp[len("start"):])
|
||||||
startTime := int64(0)
|
startTime := int64(0)
|
||||||
fmt.Scanf(startTimeString, "%d", &startTime)
|
fmt.Scanf(startTimeString, "%d", &startTime)
|
||||||
currentTime := time.Now().UnixMilli()
|
time.Sleep(time.Duration(startTime) * time.Millisecond)
|
||||||
if currentTime > startTime {
|
|
||||||
log.Println("cannot start after given time")
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
time.Sleep(time.Duration(startTime - currentTime) * time.Millisecond)
|
|
||||||
log.Println("Started #start")
|
log.Println("Started #start")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user