summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/http/rpc_test.go63
-rw-r--r--service/http/service.go8
2 files changed, 5 insertions, 66 deletions
diff --git a/service/http/rpc_test.go b/service/http/rpc_test.go
index 491e863c..00e78d39 100644
--- a/service/http/rpc_test.go
+++ b/service/http/rpc_test.go
@@ -110,68 +110,7 @@ func Test_RPC_Unix(t *testing.T) {
s2, _ := c.Get(rpc.ID)
rs := s2.(*rpc.Service)
- go func() { c.Serve() }()
- time.Sleep(time.Millisecond * 100)
- defer c.Stop()
-
- res, _, _ := get("http://localhost:6029")
- assert.Equal(t, strconv.Itoa(*ss.rr.Workers()[0].Pid), res)
-
- cl, err := rs.Client()
- assert.NoError(t, err)
-
- r := ""
- assert.NoError(t, cl.Call("http.Reset", true, &r))
- assert.Equal(t, "OK", r)
-
- res2, _, _ := get("http://localhost:6029")
- assert.Equal(t, strconv.Itoa(*ss.rr.Workers()[0].Pid), res2)
- assert.NotEqual(t, res, res2)
-}
-
-func Test_RPC_Unix_Double(t *testing.T) {
- if runtime.GOOS == "windows" {
- t.Skip("not supported on " + runtime.GOOS)
- }
-
- logger, _ := test.NewNullLogger()
- logger.SetLevel(logrus.DebugLevel)
-
- c := service.NewContainer(logger)
- c.Register(rpc.ID, &rpc.Service{})
- c.Register(ID, &Service{})
-
- sock := `unix://` + os.TempDir() + `/rpc.unix`
- j, _ := json.Marshal(sock)
-
- assert.NoError(t, c.Init(&testCfg{
- rpcCfg: `{"enable":true, "listen":` + string(j) + `}`,
- httpCfg: `{
- "enable": true,
- "address": ":6029",
- "maxRequest": 1024,
- "uploads": {
- "dir": ` + tmpDir() + `,
- "forbid": []
- },
- "workers":{
- "command": "php ../../php-src/tests/http/client.php pid pipes",
- "relay": "pipes",
- "pool": {
- "numWorkers": 1,
- "allocateTimeout": 10000000,
- "destroyTimeout": 10000000
- }
- }
- }`}))
-
- s, _ := c.Get(ID)
- ss := s.(*Service)
-
- s2, _ := c.Get(rpc.ID)
- rs := s2.(*rpc.Service)
-
- go func() { c.Serve() }()
+ go func() { assert.NoError(t, c.Serve()) }()
time.Sleep(time.Millisecond * 100)
defer c.Stop()
diff --git a/service/http/service.go b/service/http/service.go
index d98a4596..2df8656c 100644
--- a/service/http/service.go
+++ b/service/http/service.go
@@ -97,15 +97,15 @@ func (s *Service) Serve() error {
// Stop stops the svc.
func (s *Service) Stop() {
- atomic.AddInt32(&s.inStopping, 1)
- defer atomic.AddInt32(&s.inStopping, -1)
-
s.mu.Lock()
defer s.mu.Unlock()
- if s.http == nil || s.stopping() {
+ if s.http == nil {
return
}
+ atomic.AddInt32(&s.inStopping, 1)
+ defer atomic.AddInt32(&s.inStopping, -1)
+
s.http.Shutdown(context.Background())
}