Skip to content

Commit 7dd728e

Browse files
author
Kazuhiko Yamashita
authored
Merge pull request #14 from STNS/fix-memory-leak
fix memory leak for copy byte array
2 parents 8bae6ff + 692ef71 commit 7dd728e

File tree

4 files changed

+94
-101
lines changed

4 files changed

+94
-101
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ UNAME_S := $(shell uname -s)
2121
.PHONY: build
2222
## build: build the nke
2323
build:
24-
$(GO) build -o $(BUILD)/cache-stnsd -ldflags "-X github.com/STNS/cache-stnsd/cmd.version=$(VERSION)"
24+
$(GO) build -o $(BUILD)/cache-stnsd -ldflags "-X github.com/STNS/cache-stnsd/cmd.version=$(VERSION) -s -w"
2525

2626
.PHONY: install
2727
install: build ## Install
@@ -59,9 +59,9 @@ test:
5959
$(GO) test -race $(TEST)
6060

6161
.PHONY: run
62-
run:
62+
run: build
6363
@echo "$(INFO_COLOR)==> $(RESET)$(BOLD)Runing$(RESET)"
64-
$(GO) run main.go -c $(TESTCONFIG) -p /tmp/cache-stnsd.pid -l /tmp/cache-stnsd.log server -s /tmp/cache-stnsd.sock
64+
tmp/bin/cache-stnsd -c $(TESTCONFIG) -p /tmp/cache-stnsd.pid -l /tmp/cache-stnsd.log server -s /tmp/cache-stnsd.sock --log-level debug
6565

6666
.PHONY: integration
6767
integration: ## Run integration test after Server wakeup

cache_stnsd/http.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ func (h *Http) prefetchUserOrGroup(resource string, ug interface{}) error {
136136
return err
137137
}
138138

139-
j = []byte("[" + string(j) + "]")
139+
j = append([]byte(`[`), j...)
140+
j = append(j, []byte(`]`)...)
140141

141142
cacheKey, err := h.cacheKey(resource, fmt.Sprintf("name=%s", val.GetName()))
142143
if err != nil {

go.mod

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,16 @@ require (
77
github.com/ReneKroon/ttlcache/v2 v2.1.0
88
github.com/STNS/STNS/v2 v2.2.8
99
github.com/STNS/libstns-go v0.2.0
10-
github.com/Songmu/retry v0.1.0
11-
github.com/facebookgo/atomicfile v0.0.0-20151019160806-2de1f203e7d5 // indirect
1210
github.com/facebookgo/pidfile v0.0.0-20150612191647-f242e2999868
13-
github.com/flosch/pongo2 v0.0.0-20200529170236-5abacdfa4915 // indirect
14-
github.com/hashicorp/go-retryablehttp v0.6.7
15-
github.com/juju/go4 v0.0.0-20160222163258-40d72ab9641a // indirect
16-
github.com/juju/persistent-cookiejar v0.0.0-20171026135701-d5e5a8405ef9 // indirect
1711
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirect
1812
github.com/k0kubun/pp v3.0.1+incompatible
13+
github.com/kr/pretty v0.2.0 // indirect
14+
github.com/kr/text v0.2.0 // indirect
1915
github.com/lib/pq v1.8.0
20-
github.com/lxc/lxd v0.0.0-20200711014005-e4f84baabff7
21-
github.com/mitchellh/go-homedir v1.1.0
22-
github.com/pyama86/go-cache v0.0.0-20160619073142-5c290c8c42f4
16+
github.com/onsi/gomega v1.12.0 // indirect
17+
github.com/pkg/profile v1.6.0
2318
github.com/sirupsen/logrus v1.7.0
2419
github.com/spf13/cobra v1.0.0
2520
github.com/spf13/viper v1.7.0
26-
github.com/thoas/go-funk v0.7.0
27-
gopkg.in/macaroon-bakery.v2 v2.2.0 // indirect
28-
gopkg.in/retry.v1 v1.0.3 // indirect
29-
gopkg.in/robfig/cron.v2 v2.0.0-20150107220207-be2e0b0deed5 // indirect
21+
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
3022
)

0 commit comments

Comments
 (0)