Skip to content

Commit 8d2de90

Browse files
Yurunsofttwosematyhtfhuanghantao
authored
Update version for Swoole 4.4.23 (#3936)
* Fix sync client error info (#3784) # Conflicts: # swoole_client.cc * Fix memory overread when parse form-data boundary (#3858) # Conflicts: # swoole_http_request.cc * Fix test * Fix the bug of the channel, the data that has enqueue cannot be popped after the close # Conflicts: # src/coroutine/channel.cc # swoole_channel_coro.cc * Add github action (#3891) * Add github action to run swoole test * Fix test * Fix test (#3864) * Update version for Swoole 4.4.23 Co-authored-by: twosee <[email protected]> Co-authored-by: matyhtf <[email protected]> Co-authored-by: codinghuang <[email protected]>
1 parent 8e21c74 commit 8d2de90

File tree

12 files changed

+150
-66
lines changed

12 files changed

+150
-66
lines changed

.github/workflows/ext.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ jobs:
99

1010
steps:
1111
- uses: actions/checkout@v1
12+
- name: install php
13+
uses: shivammathur/setup-php@v2
14+
with:
15+
php-version: '7.4'
1216
- name: configure
1317
run: phpize && ./configure --enable-sockets --enable-mysqlnd --enable-http2 --enable-debug-log
1418
- name: make

.github/workflows/lib.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ jobs:
1919
sudo make install &&
2020
cd - &&
2121
sudo rm -rf /usr/src/googletest/googletest/build
22+
- name: install php
23+
uses: shivammathur/setup-php@v2
24+
with:
25+
php-version: '7.4'
2226
- name: configure
2327
run: phpize && ./configure --enable-sockets --enable-mysqlnd --enable-http2
2428
- name: make

.github/workflows/test.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: run-swoole-test
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
run-swoole-test:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
php: [7.1, 7.2, 7.3, 7.4]
12+
steps:
13+
- uses: actions/checkout@v1
14+
- name: Setup PHP
15+
uses: shivammathur/setup-php@v2
16+
with:
17+
php-version: "${{ matrix.php }}"
18+
- name: Show machine information
19+
run: |
20+
date
21+
env
22+
uname -a
23+
ulimit -a
24+
php -v
25+
php --ini
26+
ls -al
27+
pwd
28+
echo "`git log -20 --pretty --oneline`"
29+
echo "`git log -10 --stat --pretty --oneline`"
30+
- name: Run pecl-install.sh
31+
run: |
32+
sudo ${{runner.workspace}}/swoole-src/travis/pecl-install.sh
33+
- name: Run simple-compile-on-github.sh
34+
run: |
35+
sudo ${{runner.workspace}}/swoole-src/travis/simple-compile-on-github.sh
36+
- name: Run Swoole test
37+
run: |
38+
${{runner.workspace}}/swoole-src/travis/route.sh

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PROJECT(libswoole)
22

33
ENABLE_LANGUAGE(ASM)
4-
SET(SWOOLE_VERSION 4.4.22)
4+
SET(SWOOLE_VERSION 4.4.23)
55
SET(SWOOLE_CLFLAGS pthread rt dl ssl crypt crypto)
66
set(CMAKE_CXX_STANDARD 11)
77
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")

include/swoole.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ int clock_gettime(clock_id_t which_clock, struct timespec *t);
102102

103103
#define SWOOLE_MAJOR_VERSION 4
104104
#define SWOOLE_MINOR_VERSION 4
105-
#define SWOOLE_RELEASE_VERSION 22
105+
#define SWOOLE_RELEASE_VERSION 23
106106
#define SWOOLE_EXTRA_VERSION ""
107-
#define SWOOLE_VERSION "4.4.22"
108-
#define SWOOLE_VERSION_ID 40422
107+
#define SWOOLE_VERSION "4.4.23"
108+
#define SWOOLE_VERSION_ID 40423
109109
#define SWOOLE_BUG_REPORT \
110110
"A bug occurred in Swoole-v" SWOOLE_VERSION ", please report it.\n"\
111111
"The Swoole developers probably don't know about it,\n"\

package.xml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@
4242
<email>[email protected]</email>
4343
<active>yes</active>
4444
</developer>
45-
<date>2020-10-27</date>
46-
<time>18:00:00</time>
45+
<date>2020-12-17</date>
46+
<time>16:00:00</time>
4747
<version>
48-
<release>4.4.22</release>
48+
<release>4.4.23</release>
4949
<api>4.0</api>
5050
</version>
5151
<stability>
@@ -56,11 +56,10 @@
5656
<notes>
5757
Fixed
5858
---
59-
* Fixed systemd fds bugs
60-
* Fixed onPacket callback or UDP Server with IPv6 return wrong port
61-
* Fixed swMutex_lockwait invalid
62-
* Fixed PDO context data confusion
63-
* Fixed HTTP2 client over HTTP proxy is not working
59+
* Fixed table bugs
60+
* Fixed sync client error info (#3784)
61+
* Fixed memory overread when parse form-data boundary (#3858)
62+
* Fixed the bug of the channel, the data that has enqueue cannot be popped after the close
6463
</notes>
6564
<contents>
6665
<dir name="/">
@@ -753,6 +752,7 @@
753752
<file role="test" name="tests/swoole_channel_coro/hybird_chan3.phpt" />
754753
<file role="test" name="tests/swoole_channel_coro/lock.phpt" />
755754
<file role="test" name="tests/swoole_channel_coro/pool.phpt" />
755+
<file role="test" name="tests/swoole_channel_coro/pop_after_close.phpt" />
756756
<file role="test" name="tests/swoole_channel_coro/pop_close1.phpt" />
757757
<file role="test" name="tests/swoole_channel_coro/pop_timeout1.phpt" />
758758
<file role="test" name="tests/swoole_channel_coro/pop_timeout2.phpt" />
@@ -1784,6 +1784,7 @@
17841784
<file role="src" name="travis/pecl-install.sh" />
17851785
<file role="src" name="travis/route.sh" />
17861786
<file role="src" name="travis/run-tests.sh" />
1787+
<file role="src" name="travis/simple-compile-on-github.sh" />
17871788
<file role="src" name="travis/simple-compile.sh" />
17881789
</dir>
17891790
</contents>

src/coroutine/channel.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ void Channel::yield(enum opcode type)
5757
void* Channel::pop(double timeout)
5858
{
5959
Coroutine *current_co = Coroutine::get_current_safe();
60-
if (closed)
61-
{
60+
if (closed && is_empty()) {
6261
return nullptr;
6362
}
6463
if (is_empty() || !consumer_queue.empty())
@@ -81,8 +80,7 @@ void* Channel::pop(double timeout)
8180
{
8281
swoole_timer_del(msg.timer);
8382
}
84-
if (msg.error || closed)
85-
{
83+
if (msg.error || (closed && is_empty())) {
8684
return nullptr;
8785
}
8886
}

swoole_channel_coro.cc

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,6 @@ static PHP_METHOD(swoole_channel_coro, __construct)
174174
static PHP_METHOD(swoole_channel_coro, push)
175175
{
176176
Channel *chan = php_swoole_get_channel(ZEND_THIS);
177-
if (chan->is_closed())
178-
{
179-
zend_update_property_long(swoole_channel_coro_ce, ZEND_THIS, ZEND_STRL("errCode"), SW_CHANNEL_CLOSED);
180-
RETURN_FALSE;
181-
}
182-
else
183-
{
184-
zend_update_property_long(swoole_channel_coro_ce, ZEND_THIS, ZEND_STRL("errCode"), SW_CHANNEL_OK);
185-
}
186-
187177
zval *zdata;
188178
double timeout = -1;
189179

@@ -197,6 +187,7 @@ static PHP_METHOD(swoole_channel_coro, push)
197187
zdata = sw_zval_dup(zdata);
198188
if (chan->push(zdata, timeout))
199189
{
190+
zend_update_property_long(swoole_channel_coro_ce, SW_Z8_OBJ_P(ZEND_THIS), ZEND_STRL("errCode"), SW_CHANNEL_OK);
200191
RETURN_TRUE;
201192
}
202193
else
@@ -211,16 +202,6 @@ static PHP_METHOD(swoole_channel_coro, push)
211202
static PHP_METHOD(swoole_channel_coro, pop)
212203
{
213204
Channel *chan = php_swoole_get_channel(ZEND_THIS);
214-
if (chan->is_closed())
215-
{
216-
zend_update_property_long(swoole_channel_coro_ce, ZEND_THIS, ZEND_STRL("errCode"), SW_CHANNEL_CLOSED);
217-
RETURN_FALSE;
218-
}
219-
else
220-
{
221-
zend_update_property_long(swoole_channel_coro_ce, ZEND_THIS, ZEND_STRL("errCode"), SW_CHANNEL_OK);
222-
}
223-
224205
double timeout = -1;
225206

226207
ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_THROW, 0, 1)
@@ -233,10 +214,12 @@ static PHP_METHOD(swoole_channel_coro, pop)
233214
{
234215
RETVAL_ZVAL(zdata, 0, 0);
235216
efree(zdata);
236-
}
237-
else
238-
{
239-
zend_update_property_long(swoole_channel_coro_ce, ZEND_THIS, ZEND_STRL("errCode"), chan->is_closed() ? SW_CHANNEL_CLOSED : SW_CHANNEL_TIMEOUT);
217+
zend_update_property_long(swoole_channel_coro_ce, SW_Z8_OBJ_P(ZEND_THIS), ZEND_STRL("errCode"), SW_CHANNEL_OK);
218+
} else {
219+
zend_update_property_long(swoole_channel_coro_ce,
220+
SW_Z8_OBJ_P(ZEND_THIS),
221+
ZEND_STRL("errCode"),
222+
chan->is_closed() ? SW_CHANNEL_CLOSED : SW_CHANNEL_TIMEOUT);
240223
RETURN_FALSE;
241224
}
242225
}

swoole_client.cc

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -957,24 +957,16 @@ static PHP_METHOD(swoole_client, connect)
957957
php_swoole_client_check_setting(cli, zset);
958958
}
959959

960-
961-
//nonblock async
962-
if (cli->connect(cli, host, port, timeout, sock_flag) < 0)
963-
{
964-
if (errno == 0)
965-
{
966-
if (SwooleG.error == SW_ERROR_DNSLOOKUP_RESOLVE_FAILED)
967-
{
968-
php_swoole_error(E_WARNING, "connect to server[%s:%d] failed. Error: %s[%d]", host, (int ) port,
969-
swoole_strerror(SwooleG.error), SwooleG.error);
970-
}
971-
zend_update_property_long(swoole_client_ce, ZEND_THIS, ZEND_STRL("errCode"), SwooleG.error);
972-
}
973-
else
974-
{
975-
php_swoole_sys_error(E_WARNING, "connect to server[%s:%d] failed", host, (int )port);
976-
zend_update_property_long(swoole_client_ce, ZEND_THIS, ZEND_STRL("errCode"), errno);
977-
}
960+
// nonblock async
961+
if (cli->connect(cli, host, port, timeout, sock_flag) < 0) {
962+
php_swoole_error(E_WARNING,
963+
"connect to server[%s:%d] failed. Error: %s[%d]",
964+
host,
965+
(int) port,
966+
swoole_strerror(SwooleG.error),
967+
SwooleG.error);
968+
zend_update_property_long(
969+
swoole_client_ce, SW_Z8_OBJ_P(ZEND_THIS), ZEND_STRL("errCode"), SwooleG.error);
978970
php_swoole_client_free(ZEND_THIS, cli);
979971
RETURN_FALSE;
980972
}

swoole_http_request.cc

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -485,24 +485,27 @@ static int http_request_on_header_value(swoole_http_parser *parser, const char *
485485
else if (SW_STRCASECT(at, length, "multipart/form-data"))
486486
{
487487
offset = sizeof("multipart/form-data") - 1;
488-
while (at[offset] == ' ' || at[offset] == ';')
489-
{
488+
// skip ' ' and ';'
489+
while (offset < length && (at[offset] == ' ' || at[offset] == ';')) {
490490
offset++;
491491
}
492+
// skip 'boundary='
492493
offset += sizeof("boundary=") - 1;
493-
494494
int boundary_len = length - offset;
495495
char *boundary_str = (char *) at + offset;
496-
497496
// find ';'
498-
char *tmp = (char*) memchr(boundary_str, ';', boundary_len);
499-
if (tmp)
500-
{
501-
boundary_len = tmp - boundary_str;
497+
if (boundary_len > 0) {
498+
// find ';'
499+
char *tmp = (char *) memchr(boundary_str, ';', boundary_len);
500+
if (tmp) {
501+
boundary_len = tmp - boundary_str;
502+
}
502503
}
503504
if (boundary_len <= 0)
504505
{
505506
swWarn("invalid multipart/form-data body fd:%d", ctx->fd);
507+
/* make it same with protocol error */
508+
ctx->parser.state = s_dead;
506509
return -1;
507510
}
508511
// trim '"'

0 commit comments

Comments
 (0)