Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,17 @@ buildsrc: $(SRCPATH)/crypto/lib/libsodium.a node_exporter NONGO_BIN deps $(ALGOD
cd $(SRCPATH) && \
go vet $(UNIT_TEST_SOURCES) $(E2E_TEST_SOURCES)

SOURCES_RACE := github.com/algorand/go-algorand/cmd/kmd

## Build binaries with the race detector enabled in them.
## This allows us to run e2e tests with race detection.
## We overwrite bin-race/kmd with a non -race version due to
## the incredible performance impact of -race on Scrypt.
build-race: build
@mkdir -p $(GOPATH)/bin-race
cd $(SRCPATH) && \
GOBIN=$(GOPATH)/bin-race go install $(GOTAGS) -ldflags="$(GOLDFLAGS)" $(SOURCES)
GOBIN=$(GOPATH)/bin-race go install $(GOTAGS) -race -ldflags="$(GOLDFLAGS)" $(SOURCES) && \
GOBIN=$(GOPATH)/bin-race go install $(GOTAGS) -ldflags="$(GOLDFLAGS)" $(SOURCES_RACE)

NONGO_BIN_FILES=$(GOPATH)/bin/find-nodes.sh $(GOPATH)/bin/update.sh $(GOPATH)/bin/updatekey.json $(GOPATH)/bin/COPYING

Expand Down
16 changes: 7 additions & 9 deletions daemon/kmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,13 @@ func ValidateConfig(cfg WalletServerConfig) error {

// MakeWalletServer takes a WalletServerConfig, and returns a validated,
// configured WalletServer.
func MakeWalletServer(config WalletServerConfig) (WalletServer, error) {
var ws WalletServer

func MakeWalletServer(config WalletServerConfig) (*WalletServer, error) {
err := ValidateConfig(config)
if err != nil {
return ws, err
return nil, err
}

ws = WalletServer{
ws := &WalletServer{
WalletServerConfig: config,
netPath: filepath.Join(config.DataDir, NetFilename),
pidPath: filepath.Join(config.DataDir, PIDFilename),
Expand Down Expand Up @@ -144,7 +142,7 @@ func (ws *WalletServer) releaseFileLock() error {
}

// Write out a file containing the address kmd is listening on
func (ws WalletServer) writeStateFiles(netAddr string) (err error) {
func (ws *WalletServer) writeStateFiles(netAddr string) (err error) {
// netPath file contains path to sock file
err = ioutil.WriteFile(ws.netPath, []byte(netAddr), 0640)
if err != nil {
Expand All @@ -156,15 +154,15 @@ func (ws WalletServer) writeStateFiles(netAddr string) (err error) {
}

// Delete the state files generated by writeStateFiles
func (ws WalletServer) deleteStateFiles() {
func (ws *WalletServer) deleteStateFiles() {
os.Remove(ws.pidPath)
os.Remove(ws.netPath)
}

// makeWatchdogCallback generates a callback function that either 1. does
// nothing if ws.Timeout is nil, or 2. kicks a watchdog timer that will kill
// kmd when it expires.
func (ws WalletServer) makeWatchdogCallback(kill chan os.Signal) func() {
func (ws *WalletServer) makeWatchdogCallback(kill chan os.Signal) func() {
// If Timeout is nil, then we will not kill kmd after a timeout
if ws.Timeout == nil {
return func() {}
Expand Down Expand Up @@ -193,7 +191,7 @@ func (ws WalletServer) makeWatchdogCallback(kill chan os.Signal) func() {
// returns an error if it was unable to start the server. It reads from the
// `kill` channel in order to shut down the server gracefully, and returns a
// `died` channel that will be written after the server exits.
func (ws WalletServer) Start(kill chan os.Signal) (died chan error, sock string, err error) {
func (ws *WalletServer) Start(kill chan os.Signal) (died chan error, sock string, err error) {
// Ensure we're the only instance of kmd running in this data directory
err = ws.acquireFileLock()
if err != nil {
Expand Down
8 changes: 8 additions & 0 deletions test/framework/fixtures/libgoalFixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,14 @@ func (f *LibGoalFixture) ShutdownImpl(preserveData bool) {
}
}

// intercept baseFixture.failOnError so we can clean up any algods that are still alive
func (f *LibGoalFixture) failOnError(err error, message string) {
if err != nil {
f.network.Stop(f.binDir)
f.baseFixture.failOnError(err, message)
}
}

// PrimaryDataDir returns the data directory for the PrimaryNode for the network
func (f *LibGoalFixture) PrimaryDataDir() string {
return f.network.PrimaryDataDir()
Expand Down