summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--go.mod4
-rw-r--r--go.sum10
-rwxr-xr-xinternal/protocol.go3
-rwxr-xr-xpool/static_pool_test.go17
-rw-r--r--tests/crc_error.php17
-rwxr-xr-xworker/sync_worker.go6
-rwxr-xr-xworker/sync_worker_test.go2
-rwxr-xr-xworker/worker.go2
8 files changed, 42 insertions, 19 deletions
diff --git a/go.mod b/go.mod
index 1c6db317..0a2af576 100644
--- a/go.mod
+++ b/go.mod
@@ -8,7 +8,7 @@ require (
github.com/shirou/gopsutil v3.21.10+incompatible
// spiral
github.com/spiral/errors v1.0.12
- github.com/spiral/goridge/v3 v3.2.3
+ github.com/spiral/goridge/v3 v3.2.4
github.com/spiral/tcplisten v1.0.0
// spiral
github.com/stretchr/testify v1.7.0
@@ -27,7 +27,7 @@ require (
github.com/tklauser/go-sysconf v0.3.9 // indirect
github.com/tklauser/numcpus v0.3.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
- golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1 // indirect
+ golang.org/x/sys v0.0.0-20211124211545-fe61309f8881 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
diff --git a/go.sum b/go.sum
index 0ce2a71b..ad3b8953 100644
--- a/go.sum
+++ b/go.sum
@@ -29,8 +29,8 @@ github.com/shirou/gopsutil v3.21.10+incompatible h1:AL2kpVykjkqeN+MFe1WcwSBVUjGj
github.com/shirou/gopsutil v3.21.10+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/spiral/errors v1.0.12 h1:38Waf8ZL/Xvxg4HTYGmrUbvi7TCHivmuatNQZlBhQ8s=
github.com/spiral/errors v1.0.12/go.mod h1:j5UReqxZxfkwXkI9mFY87VhEXcXmSg7kAk5Sswy1eEA=
-github.com/spiral/goridge/v3 v3.2.3 h1:iNz6aD/c00hC50wo+qT8uP5ZZ3VdCAERXUtNiyDE3Yo=
-github.com/spiral/goridge/v3 v3.2.3/go.mod h1:DA4Ekw9qVcTvVouUNJgxESXURBHZ2SfkliCEIpEl9lA=
+github.com/spiral/goridge/v3 v3.2.4 h1:Octzn0kgpQY10vQhrf0a5RlzCVW1lIEuR6/IGYp0BW4=
+github.com/spiral/goridge/v3 v3.2.4/go.mod h1:a6qAtZy+FBaPj/76GweHj6SkgIr+oRVgW5p4e5vLZF4=
github.com/spiral/tcplisten v1.0.0 h1:dII3R20Xslll6Uk60ac1JCn9zQwfwbt88CLrs3OryZg=
github.com/spiral/tcplisten v1.0.0/go.mod h1:+anIsZh2ZYw2EogG2pO1yEZKcGN7lEf41hUQilctYJo=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
@@ -42,7 +42,7 @@ github.com/tklauser/go-sysconf v0.3.9 h1:JeUVdAOWhhxVcU6Eqr/ATFHgXk/mmiItdKeJPev
github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs=
github.com/tklauser/numcpus v0.3.0 h1:ILuRUQBtssgnxw0XXIjKUC56fgnOrFoQQ/4+DeU2biQ=
github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8=
-github.com/vmihailenco/msgpack/v5 v5.3.4/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc=
+github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc=
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
@@ -53,8 +53,8 @@ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cO
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1 h1:kwrAHlwJ0DUBZwQ238v+Uod/3eZ8B2K5rYsUHBQvzmI=
-golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20211124211545-fe61309f8881 h1:TyHqChC80pFkXWraUUf6RuB5IqFdQieMLwwCJokV2pc=
+golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
diff --git a/internal/protocol.go b/internal/protocol.go
index e6e6e7ab..ba923ef5 100755
--- a/internal/protocol.go
+++ b/internal/protocol.go
@@ -89,9 +89,6 @@ func Pid(rl relay.Relay) (int64, error) {
return 0, err
}
- if !fr.VerifyCRC(fr.Header()) {
- return 0, errors.Str("CRC mismatch")
- }
if fr == nil {
return 0, errors.Str("nil frame received")
}
diff --git a/pool/static_pool_test.go b/pool/static_pool_test.go
index 717d301e..8e2667ac 100755
--- a/pool/static_pool_test.go
+++ b/pool/static_pool_test.go
@@ -23,8 +23,8 @@ import (
var cfg = &Config{
NumWorkers: uint64(runtime.NumCPU()),
- AllocateTimeout: time.Second * 5,
- DestroyTimeout: time.Second * 5,
+ AllocateTimeout: time.Second * 500,
+ DestroyTimeout: time.Second * 500,
}
func Test_NewPool(t *testing.T) {
@@ -560,6 +560,19 @@ func Test_Static_Pool_WrongCommand2(t *testing.T) {
assert.Nil(t, p)
}
+func Test_CRC_WithPayload(t *testing.T) {
+ ctx := context.Background()
+ _, err := Initialize(
+ ctx,
+ func() *exec.Cmd { return exec.Command("php", "../tests/crc_error.php") },
+ pipe.NewPipeFactory(),
+ cfg,
+ )
+ assert.Error(t, err)
+ data := err.Error()
+ assert.Contains(t, data, "warning: some weird php erro")
+}
+
/* PTR:
Benchmark_Pool_Echo-32 49076 29926 ns/op 8016 B/op 20 allocs/op
Benchmark_Pool_Echo-32 47257 30779 ns/op 8047 B/op 20 allocs/op
diff --git a/tests/crc_error.php b/tests/crc_error.php
new file mode 100644
index 00000000..a769fb1e
--- /dev/null
+++ b/tests/crc_error.php
@@ -0,0 +1,17 @@
+<?php
+
+declare(strict_types=1);
+
+use Spiral\Goridge\StreamRelay;
+use Spiral\RoadRunner\Worker as RoadRunner;
+
+require __DIR__ . "/vendor/autoload.php";
+
+fwrite(STDOUT, "warning: some weird php error");
+
+$rr = new RoadRunner(new StreamRelay(\STDIN, \STDOUT));
+
+while($rr->waitPayload()){
+ sleep(3);
+ $rr->respond(new \Spiral\RoadRunner\Payload(""));
+}
diff --git a/worker/sync_worker.go b/worker/sync_worker.go
index deea8cb1..12937eac 100755
--- a/worker/sync_worker.go
+++ b/worker/sync_worker.go
@@ -190,11 +190,7 @@ func (tw *SyncWorkerImpl) execPayload(p *payload.Payload) (*payload.Payload, err
return nil, errors.E(op, errors.Network, err)
}
if frameR == nil {
- return nil, errors.E(op, errors.Network, errors.Str("nil fr received"))
- }
-
- if !frameR.VerifyCRC(frameR.Header()) {
- return nil, errors.E(op, errors.Network, errors.Str("failed to verify CRC"))
+ return nil, errors.E(op, errors.Network, errors.Str("nil frame received"))
}
flags := frameR.ReadFlags()
diff --git a/worker/sync_worker_test.go b/worker/sync_worker_test.go
index 41c0c92b..288cbd45 100755
--- a/worker/sync_worker_test.go
+++ b/worker/sync_worker_test.go
@@ -14,7 +14,7 @@ func Test_NotStarted_String(t *testing.T) {
w, _ := InitBaseWorker(cmd)
assert.Contains(t, w.String(), "php tests/client.php echo pipes")
assert.Contains(t, w.String(), "inactive")
- assert.Contains(t, w.String(), "numExecs: 0")
+ assert.Contains(t, w.String(), "num_execs: 0")
}
func Test_NotStarted_Exec(t *testing.T) {
diff --git a/worker/worker.go b/worker/worker.go
index 05c6dd0d..e5c3a192 100755
--- a/worker/worker.go
+++ b/worker/worker.go
@@ -111,7 +111,7 @@ func (w *Process) String() string {
}
return fmt.Sprintf(
- "(`%s` [%s], numExecs: %v)",
+ "(`%s` [%s], num_execs: %v)",
strings.Join(w.cmd.Args, " "),
st,
w.state.NumExecs(),