Skip to content

Commit

Permalink
Update version for Swoole 4.4.22 (#3777)
Browse files Browse the repository at this point in the history
* Fixed HTTP2 client over HTTP proxy is not working

* Fixed PDO context data confusion

* Fix swMutex_lockwait invalid

* Fix test

* Fixed onPacket callback or UDP Server with IPv6 return wrong port

* Fix systemd fds bugs

* Update version for Swoole 4.4.22
  • Loading branch information
Yurunsoft committed Oct 28, 2020
1 parent a10d844 commit 8868102
Show file tree
Hide file tree
Showing 19 changed files with 300 additions and 116 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
@@ -1,7 +1,7 @@
PROJECT(libswoole)

ENABLE_LANGUAGE(ASM)
SET(SWOOLE_VERSION 4.4.21)
SET(SWOOLE_VERSION 4.4.22)
SET(SWOOLE_CLFLAGS pthread rt dl ssl crypt crypto)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
Expand Down
2 changes: 2 additions & 0 deletions include/server.h
Expand Up @@ -223,6 +223,7 @@ typedef struct _swListenPort

swProtocol protocol;
void *ptr;
int listening;
int (*onRead)(swReactor *reactor, struct _swListenPort *port, swEvent *event);
} swListenPort;

Expand Down Expand Up @@ -384,6 +385,7 @@ struct _swServer

int udp_socket_ipv4;
int udp_socket_ipv6;
int dgram_socket;

uint32_t max_wait_time;

Expand Down
34 changes: 31 additions & 3 deletions include/swoole.h
Expand Up @@ -102,10 +102,10 @@ int clock_gettime(clock_id_t which_clock, struct timespec *t);

#define SWOOLE_MAJOR_VERSION 4
#define SWOOLE_MINOR_VERSION 4
#define SWOOLE_RELEASE_VERSION 21
#define SWOOLE_RELEASE_VERSION 22
#define SWOOLE_EXTRA_VERSION ""
#define SWOOLE_VERSION "4.4.21"
#define SWOOLE_VERSION_ID 40421
#define SWOOLE_VERSION "4.4.22"
#define SWOOLE_VERSION_ID 40422
#define SWOOLE_BUG_REPORT \
"A bug occurred in Swoole-v" SWOOLE_VERSION ", please report it.\n"\
"The Swoole developers probably don't know about it,\n"\
Expand Down Expand Up @@ -218,6 +218,9 @@ typedef unsigned long ulong_t;
#define MIN(A, B) SW_MIN(A, B)
#endif

#define SW_NUM_BILLION (1000 * 1000 *1000)
#define SW_NUM_MILLION (1000 * 1000)

#ifdef SW_DEBUG
#define SW_ASSERT(e) assert(e)
#define SW_ASSERT_1BYTE(v) do { \
Expand Down Expand Up @@ -2500,6 +2503,31 @@ static sw_inline int64_t swTimer_get_absolute_msec()
return msec1 + msec2;
}

#ifdef HAVE_CLOCK_GETTIME
#define swoole_clock_gettime clock_gettime
#else
int swoole_clock_gettime(clock_id_t which_clock, struct timespec *t);
#endif

static inline struct timespec swoole_time_until(int milliseconds) {
struct timespec t;
swoole_clock_gettime(CLOCK_REALTIME, &t);

int sec = milliseconds / 1000;
int msec = milliseconds - (sec * 1000);

t.tv_sec += sec;
t.tv_nsec += msec * 1000 * 1000;

if (t.tv_nsec > SW_NUM_BILLION) {
int _sec = t.tv_nsec / SW_NUM_BILLION;
t.tv_sec += _sec;
t.tv_nsec -= _sec * SW_NUM_BILLION;
}

return t;
}

SW_EXTERN_C_END

#endif /* SWOOLE_H_ */
52 changes: 10 additions & 42 deletions package.xml
Expand Up @@ -42,10 +42,10 @@
<email>shenzhe163@gmail.com</email>
<active>yes</active>
</developer>
<date>2020-09-16</date>
<time>21:00:00</time>
<date>2020-10-27</date>
<time>18:00:00</time>
<version>
<release>4.4.21</release>
<release>4.4.22</release>
<api>4.0</api>
</version>
<stability>
Expand All @@ -54,47 +54,13 @@
</stability>
<license uri="http://www.apache.org/licenses/LICENSE-2.0.html">Apache2.0</license>
<notes>
New APIs
---
* Added Swoole\Process\ProcessManager (swoole/library#88f147b) (@huanghantao)
* Added ArrayObject::append, StringObject::equals (swoole/library#f28556f) (@matyhtf)
* Added Coroutine::parallel (swoole/library#6aa89a9) (@matyhtf)
* Added Coroutine\Barrier (swoole/library#2988b2a) (@matyhtf)
* Added Swoole\Process\ProcessManager (swoole/library#88f147b) (@huanghantao)
* Added ArrayObject::append, StringObject::equals (swoole/library#f28556f) (@matyhtf)
* Added Coroutine::parallel (swoole/library#6aa89a9) (@matyhtf)
* Added Coroutine\Barrier (swoole/library#2988b2a) (@matyhtf)
* Added firstKey and lastKey (swoole/library#51) (@sy-records)

Enhancement
---
* Support CURLOPT_FAILONERROR (swoole/library#20) (@sy-records)
* Support CURLOPT_FAILONERROR (swoole/library#20) (@sy-records)
* Support CURLOPT_SSLCERTTYPE, CURLOPT_SSLCERT, CURLOPT_SSLKEYTYPE, CURLOPT_SSLKEY (swoole/library#22) (@sy-records)
* Support CURLOPT_HTTPGET (swoole/library@d730bd0) (@shiguangqi)
* Support CURLOPT_CAINFO and CURLOPT_CAPATH (swoole/library#32) (@sy-records)
* Support CURLOPT_FORBID_REUSE (swoole/library#33) (@sy-records)
* Support cURL __toString (swoole/library#38) (@twose)
* Added lowercase_header to fix cURL header name (swoole/library#e7c2a82) (@twose)
* Set wait count directly in WaitGroup constructor (swoole/library#2fb228b8) (@matyhtf)
* Added CURLOPT_REDIR_PROTOCOLS (swoole/library#46) (@sy-records)

Fixed
---
* Fixed fseek ftell file larger than 2G bug (#3619) (@Yurunsoft)
* Fixed http proxy handshake bug (#3630) (@matyhtf)
* Fixed zend_hash_clean assertion failure (#3634) (@twose)
* Fixed header parse in Co\Http\Client (#3632) (@matyhtf)
* Fixed mysqli options error (swoole/library#35) (@sy-records)
* Fixed response header parsing when there is no space after the colon in the response header (swoole/library#27) (@Yurunsoft)
* Fixed CURLOPT_POSTFIELDS (swoole/library@ed192f6) (@twose)
* Fixed the latest connection can not be released before accept new one (swoole/library@1ef7933) (@twose)
* Fixed ArrayObject and StringObject bug (swoole/library#44) (@matyhtf)
* Fixed mysqli error (swoole/library#45) (@sy-records)
* Fixed set error code and error message when curl execution fails (swoole/library#1b6c65e) (@sy-records)
* Fixed ArrayObject and StringObject bug (swoole/library#44) (@matyhtf)
* Fixed mysqli error, typo (swoole/library#45) (@sy-records)
* Fixed array_key_last (swoole/library#46) (@sy-records)
* Fixed systemd fds bugs
* Fixed onPacket callback or UDP Server with IPv6 return wrong port
* Fixed swMutex_lockwait invalid
* Fixed PDO context data confusion
* Fixed HTTP2 client over HTTP proxy is not working
</notes>
<contents>
<dir name="/">
Expand Down Expand Up @@ -1039,6 +1005,7 @@
<file role="test" name="tests/swoole_http2_client_coro/goaway.phpt" />
<file role="test" name="tests/swoole_http2_client_coro/headers.phpt" />
<file role="test" name="tests/swoole_http2_client_coro/host.phpt" />
<file role="test" name="tests/swoole_http2_client_coro/http_proxy.phpt" />
<file role="test" name="tests/swoole_http2_client_coro/huge_headers.phpt" />
<file role="test" name="tests/swoole_http2_client_coro/issues_2374.phpt" />
<file role="test" name="tests/swoole_http2_client_coro/multi.phpt" />
Expand Down Expand Up @@ -1544,6 +1511,7 @@
<file role="test" name="tests/swoole_server/stats.phpt" />
<file role="test" name="tests/swoole_server/stop.phpt" />
<file role="test" name="tests/swoole_server/stop_in_workerStart.phpt" />
<file role="test" name="tests/swoole_server/systemd_fds.phpt" />
<file role="test" name="tests/swoole_server/task/base.phpt" />
<file role="test" name="tests/swoole_server/task/bug_2585.phpt" />
<file role="test" name="tests/swoole_server/task/callback_is_null.phpt" />
Expand Down
12 changes: 6 additions & 6 deletions php_swoole_library.h
Expand Up @@ -2757,18 +2757,18 @@ static const char* swoole_library_source_core_database_pdo_statement_proxy =
" $this->__object->setFetchMode(...$this->setFetchModeContext);\n"
" }\n"
" if ($this->bindParamContext) {\n"
" foreach ($this->bindParamContext as $param => $arguments) {\n"
" $this->__object->bindParam($param, ...$arguments);\n"
" foreach ($this->bindParamContext as $param => $item) {\n"
" $this->__object->bindParam($param, ...$item);\n"
" }\n"
" }\n"
" if ($this->bindColumnContext) {\n"
" foreach ($this->bindColumnContext as $column => $arguments) {\n"
" $this->__object->bindColumn($column, ...$arguments);\n"
" foreach ($this->bindColumnContext as $column => $item) {\n"
" $this->__object->bindColumn($column, ...$item);\n"
" }\n"
" }\n"
" if ($this->bindValueContext) {\n"
" foreach ($this->bindValueContext as $value => $arguments) {\n"
" $this->__object->bindParam($value, ...$arguments);\n"
" foreach ($this->bindValueContext as $value => $item) {\n"
" $this->__object->bindParam($value, ...$item);\n"
" }\n"
" }\n"
" continue;\n"
Expand Down
3 changes: 3 additions & 0 deletions src/coroutine/socket.cc
Expand Up @@ -455,10 +455,12 @@ bool Socket::http_proxy_handshake()
}

/* use eof protocol (provisional) */
bool ori_open_length_check = open_length_check;
bool ori_open_eof_check = open_eof_check;
uint8_t ori_package_eof_len = protocol.package_eof_len;
char ori_package_eof[SW_DATA_EOF_MAXLEN];
memcpy(ori_package_eof, SW_STRS(protocol.package_eof));
open_length_check = false;
open_eof_check = true;
protocol.package_eof_len = sizeof("\r\n\r\n") - 1;
memcpy(protocol.package_eof, SW_STRS("\r\n\r\n"));
Expand Down Expand Up @@ -532,6 +534,7 @@ bool Socket::http_proxy_handshake()
}

/* revert protocol settings */
open_length_check = ori_open_length_check;
open_eof_check = ori_open_eof_check;
protocol.package_eof_len = ori_package_eof_len;
memcpy(protocol.package_eof, SW_STRS(ori_package_eof));
Expand Down
4 changes: 1 addition & 3 deletions src/lock/mutex.c
Expand Up @@ -60,9 +60,7 @@ static int swMutex_trylock(swLock *lock)
#ifdef HAVE_MUTEX_TIMEDLOCK
int swMutex_lockwait(swLock *lock, int timeout_msec)
{
struct timespec timeo;
timeo.tv_sec = timeout_msec / 1000;
timeo.tv_nsec = (timeout_msec - timeo.tv_sec * 1000) * 1000 * 1000;
struct timespec timeo = swoole_time_until(timeout_msec);
return pthread_mutex_timedlock(&lock->object.mutex._lock, &timeo);
}
#else
Expand Down
38 changes: 21 additions & 17 deletions src/server/master.cc
Expand Up @@ -309,6 +309,8 @@ void swServer_store_listen_socket(swServer *serv)
{
serv->udp_socket_ipv6 = sockfd;
serv->connection_list[sockfd].info.addr.inet_v6.sin6_port = htons(ls->port);
} else if (ls->type == SW_SOCK_UNIX_DGRAM) {
serv->dgram_socket = sockfd;
}
}
else
Expand Down Expand Up @@ -1506,7 +1508,19 @@ int swServer_add_systemd_socket(swServer *serv)
int sock_type, sock_family;
char tmp[INET6_ADDRSTRLEN];

for (sock = SW_SYSTEMD_FDS_START; sock < SW_SYSTEMD_FDS_START + n; sock++)
int start_fd;
e = getenv("LISTEN_FDS_START");
if (e) {
start_fd = atoi(e);
} else {
start_fd = SW_SYSTEMD_FDS_START;
}
if (start_fd < 0) {
swWarn("invalid LISTEN_FDS_START");
return 0;
}

for (sock = start_fd; sock < start_fd + n; sock++)
{
swListenPort *ls = (swListenPort *) SwooleG.memory_pool->alloc(SwooleG.memory_pool, sizeof(swListenPort));
if (ls == NULL)
Expand All @@ -1518,31 +1532,21 @@ int swServer_add_systemd_socket(swServer *serv)
optlen = sizeof(val);
if (getsockopt(sock, SOL_SOCKET, SO_TYPE, &val, &optlen) < 0)
{
swWarn("getsockopt(%d, SOL_SOCKET, SO_TYPE) failed", sock);
return count;
swWarn("getsockopt(%d, SOL_SOCKET, SO_TYPE) failed %s", sock, strerror(errno));
continue;
}
sock_type = val;
//get socket family
#ifndef SO_DOMAIN
swWarn("no getsockopt(SO_DOMAIN) supports");
return count;
#else
optlen = sizeof(val);
if (getsockopt(sock, SOL_SOCKET, SO_DOMAIN, &val, &optlen) < 0)
{
swWarn("getsockopt(%d, SOL_SOCKET, SO_DOMAIN) failed", sock);
return count;
}
#endif
sock_family = val;

//get address info
address.len = sizeof(address.addr);
if (getsockname(sock, (struct sockaddr*) &address.addr, &address.len) < 0)
{
swWarn("getsockname(%d) failed", sock);
return count;
continue;
}
sock_family = ((struct sockaddr*) &address.addr)->sa_family;

ls->listening = 1;
swPort_init(ls);

switch (sock_family)
Expand Down
3 changes: 2 additions & 1 deletion src/server/port.cc
Expand Up @@ -97,11 +97,12 @@ int swPort_listen(swListenPort *ls)
int option = 1;

//listen stream socket
if (listen(sock, ls->backlog) < 0)
if (0 == ls->listening && listen(sock, ls->backlog) < 0)
{
swSysWarn("listen(%s:%d, %d) failed", ls->host, ls->port, ls->backlog);
return SW_ERR;
}
ls->listening = 1;

#ifdef TCP_DEFER_ACCEPT
if (ls->tcp_defer_accept)
Expand Down
7 changes: 3 additions & 4 deletions swoole_http2_client_coro.cc
Expand Up @@ -435,6 +435,8 @@ bool http2_client::connect()
return true;
}

extern void php_swoole_client_coro_socket_free(Socket *cli);

bool http2_client::close()
{
Socket *_client = client;
Expand Down Expand Up @@ -462,10 +464,7 @@ bool http2_client::close()
}
client = nullptr;
}
if (_client->close())
{
delete _client;
}
php_swoole_client_coro_socket_free(_client);
return true;
}

Expand Down

0 comments on commit 8868102

Please sign in to comment.