fix #4058 (#4158)
fix #4058 (#4158)

* fix #4058

* optimize code

* revert, fix tests
swoole/swoole-src,swoole/swoole-src,swoole/swoole-src,swoole/swoole-src,swoole/swoole-src,swoole/swoole-src,swoole/swoole-src