mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-22 19:08:58 +00:00
Revert "Proper signal handling in monitor process"
This reverts commit 33e9a88b56
.
This commit is contained in:
parent
97cb3fa5a5
commit
5b51f4d058
@ -9,11 +9,9 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"os/signal"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -35,10 +33,6 @@ func monitorMain() {
|
|||||||
args := os.Args
|
args := os.Args
|
||||||
var restarts [countRestarts]time.Time
|
var restarts [countRestarts]time.Time
|
||||||
|
|
||||||
sign := make(chan os.Signal, 1)
|
|
||||||
sigTerm := syscall.Signal(0xf)
|
|
||||||
signal.Notify(sign, os.Interrupt, sigTerm, os.Kill)
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
if t := time.Since(restarts[0]); t < loopThreshold {
|
if t := time.Since(restarts[0]); t < loopThreshold {
|
||||||
l.Warnf("%d restarts in %v; not retrying further", countRestarts, t)
|
l.Warnf("%d restarts in %v; not retrying further", countRestarts, t)
|
||||||
@ -74,24 +68,11 @@ func monitorMain() {
|
|||||||
go copyStderr(stderr)
|
go copyStderr(stderr)
|
||||||
go copyStdout(stdout)
|
go copyStdout(stdout)
|
||||||
|
|
||||||
exit := make(chan error)
|
err = cmd.Wait()
|
||||||
|
|
||||||
go func() {
|
|
||||||
exit <- cmd.Wait()
|
|
||||||
}()
|
|
||||||
|
|
||||||
select {
|
|
||||||
case s := <-sign:
|
|
||||||
l.Infof("Signal %d received; exiting", s)
|
|
||||||
cmd.Process.Kill()
|
|
||||||
<-exit
|
|
||||||
return
|
|
||||||
case <-exit:
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// Successfull exit indicates an intentional shutdown
|
// Successfull exit indicates an intentional shutdown
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
l.Infoln("Syncthing exited:", err)
|
l.Infoln("Syncthing exited:", err)
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
IFS=$'\n\t'
|
IFS=$'\n\t'
|
||||||
|
|
||||||
|
#go test -tags integration -v
|
||||||
./test-http.sh
|
./test-http.sh
|
||||||
./test-merge.sh
|
./test-merge.sh
|
||||||
./test-delupd.sh
|
./test-delupd.sh
|
||||||
go test -tags integration -v
|
|
||||||
|
@ -19,7 +19,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -55,11 +54,7 @@ func (p *syncthingProcess) start() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *syncthingProcess) stop() {
|
func (p *syncthingProcess) stop() {
|
||||||
if runtime.GOOS != "windows" {
|
|
||||||
p.cmd.Process.Signal(os.Interrupt)
|
|
||||||
} else {
|
|
||||||
p.cmd.Process.Kill()
|
p.cmd.Process.Kill()
|
||||||
}
|
|
||||||
p.cmd.Wait()
|
p.cmd.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,13 @@ var env = []string{
|
|||||||
"STTRACE=model",
|
"STTRACE=model",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestRestartBothDuringTransfer(t *testing.T) {
|
||||||
|
// Give the receiver some time to rot with needed files but
|
||||||
|
// without any peer. This triggers
|
||||||
|
// https://github.com/syncthing/syncthing/issues/463
|
||||||
|
testRestartDuringTransfer(t, true, true, 10*time.Second, 0)
|
||||||
|
}
|
||||||
|
|
||||||
func TestRestartReceiverDuringTransfer(t *testing.T) {
|
func TestRestartReceiverDuringTransfer(t *testing.T) {
|
||||||
testRestartDuringTransfer(t, false, true, 0, 0)
|
testRestartDuringTransfer(t, false, true, 0, 0)
|
||||||
}
|
}
|
||||||
@ -32,13 +39,6 @@ func TestRestartSenderDuringTransfer(t *testing.T) {
|
|||||||
testRestartDuringTransfer(t, true, false, 0, 0)
|
testRestartDuringTransfer(t, true, false, 0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRestartSenderAndReceiverDuringTransfer(t *testing.T) {
|
|
||||||
// // Give the receiver some time to rot with needed files but
|
|
||||||
// // without any peer. This triggers
|
|
||||||
// // https://github.com/syncthing/syncthing/issues/463
|
|
||||||
testRestartDuringTransfer(t, true, true, 10*time.Second, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testRestartDuringTransfer(t *testing.T, restartSender, restartReceiver bool, senderDelay, receiverDelay time.Duration) {
|
func testRestartDuringTransfer(t *testing.T, restartSender, restartReceiver bool, senderDelay, receiverDelay time.Duration) {
|
||||||
log.Println("Cleaning...")
|
log.Println("Cleaning...")
|
||||||
err := removeAll("s1", "s2", "f1/index", "f2/index")
|
err := removeAll("s1", "s2", "f1/index", "f2/index")
|
||||||
@ -134,9 +134,6 @@ func testRestartDuringTransfer(t *testing.T, restartSender, restartReceiver bool
|
|||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.stop()
|
|
||||||
receiver.stop()
|
|
||||||
|
|
||||||
log.Println("Comparing directories...")
|
log.Println("Comparing directories...")
|
||||||
err = compareDirectories("s1", "s2")
|
err = compareDirectories("s1", "s2")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user