Update yasio & llhttp

This commit is contained in:
halx99 2021-10-26 14:57:23 +08:00
parent d628a07919
commit ff7f56b28d
8 changed files with 51 additions and 71 deletions

View File

@ -91,7 +91,7 @@
## llhttp
- Upstream: https://github.com/nodejs/llhttp
- Version: 6.0.4
- Version: 6.0.6
- License: MIT
## lua

View File

@ -3,7 +3,7 @@
#define LLHTTP_VERSION_MAJOR 6
#define LLHTTP_VERSION_MINOR 0
#define LLHTTP_VERSION_PATCH 4
#define LLHTTP_VERSION_PATCH 6
#ifndef LLHTTP_STRICT_MODE
# define LLHTTP_STRICT_MODE 0

View File

@ -701,7 +701,7 @@ void js_register_yasio_ibstream(JSContext* ctx, JS::HandleObject global)
jsb_ibstream_prototype =
JS_InitClass(ctx, global, JS::NullPtr(), jsb_ibstream_class, nullptr, 0, properties, funcs,
NULL, // no static properties
nullptr, // no static properties
st_funcs);
// add the proto and JSClass to the type->js info hash table
@ -1198,7 +1198,7 @@ void js_register_yasio_obstream(JSContext* ctx, JS::HandleObject global)
// JS::RootedObject parentProto(ctx, jsb_cocos2d_Ref_prototype);
jsb_obstream_prototype = JS_InitClass(ctx, global, JS::NullPtr(), jsb_obstream_class,
jsb_yasio_obstream__ctor, 0, properties, funcs,
NULL, // no static properties
nullptr, // no static properties
st_funcs);
// add the proto and JSClass to the type->js info hash table
@ -1235,7 +1235,7 @@ void js_register_yasio_transport(JSContext* ctx, JS::HandleObject global)
jsb_transport_prototype =
JS_InitClass(ctx, global, JS::NullPtr(), jsb_transport_class, nullptr, 0, properties, funcs,
NULL, // no static properties
nullptr, // no static properties
st_funcs);
// add the proto and JSClass to the type->js info hash table
@ -1416,7 +1416,7 @@ void js_register_yasio_io_event(JSContext* ctx, JS::HandleObject global)
jsb_io_event_prototype =
JS_InitClass(ctx, global, JS::NullPtr(), jsb_io_event_class, nullptr, 0, properties, funcs,
NULL, // no static properties
nullptr, // no static properties
st_funcs);
// add the proto and JSClass to the type->js info hash table
@ -1877,7 +1877,7 @@ void js_register_yasio_io_service(JSContext* ctx, JS::HandleObject global)
jsb_io_service_prototype = JS_InitClass(ctx, global, JS::NullPtr(), jsb_io_service_class,
jsb_yasio_io_service__ctor, 0, properties, funcs,
NULL, // no static properties
nullptr, // no static properties
st_funcs);
// add the proto and JSClass to the type->js info hash table

View File

@ -344,7 +344,7 @@ static void get_ifaddrs_impl(int (**getifaddrs_impl)(struct ifaddrs** ifap),
static void free_single_ifaddrs(struct ifaddrs** ifap)
{
struct ifaddrs* ifa = ifap ? *ifap : NULL;
struct ifaddrs* ifa = ifap ? *ifap : nullptr;
if (!ifa)
return;
@ -364,7 +364,7 @@ static void free_single_ifaddrs(struct ifaddrs** ifap)
free(ifa->ifa_data);
free(ifa);
*ifap = NULL;
*ifap = nullptr;
}
static int open_netlink_session(netlink_session* session)
@ -461,14 +461,14 @@ static int append_ifaddr(struct ifaddrs* addr, struct ifaddrs** ifaddrs_head,
*last_ifaddr = last;
}
addr->ifa_next = NULL;
addr->ifa_next = nullptr;
if (addr == *last_ifaddr)
return 0;
assert(addr != *last_ifaddr);
(*last_ifaddr)->ifa_next = addr;
*last_ifaddr = addr;
assert((*last_ifaddr)->ifa_next == NULL);
assert((*last_ifaddr)->ifa_next == nullptr);
return 0;
}
@ -481,7 +481,7 @@ static int parse_netlink_reply(netlink_session* session, struct ifaddrs** ifaddr
struct nlmsghdr* current_message;
struct ifaddrs* addr;
int ret = -1;
unsigned char* response = NULL;
unsigned char* response = nullptr;
assert(session);
assert(ifaddrs_head);
@ -647,7 +647,7 @@ static int fill_ll_address(struct sockaddr_ll_extended** sa, struct ifinfomsg* n
YASIO_LOG("Address is too long to place in sockaddr_ll (%d > %d)",
static_cast<int>(rta_payload_length), static_cast<int>(sizeof((*sa)->sll_addr)));
free(*sa);
*sa = NULL;
*sa = nullptr;
return -1;
}
@ -655,7 +655,7 @@ static int fill_ll_address(struct sockaddr_ll_extended** sa, struct ifinfomsg* n
{
YASIO_LOG("Payload length too big to fit in the address structure");
free(*sa);
*sa = NULL;
*sa = nullptr;
return -1;
}
@ -671,7 +671,7 @@ static struct ifaddrs* find_interface_by_index(int index, struct ifaddrs** ifadd
{
struct ifaddrs* cur;
if (!ifaddrs_head || !*ifaddrs_head)
return NULL;
return nullptr;
/* Normally expensive, but with the small amount of links in the chain we'll deal with it's not
* worth the extra houskeeping and memory overhead
@ -687,14 +687,14 @@ static struct ifaddrs* find_interface_by_index(int index, struct ifaddrs** ifadd
cur = cur->ifa_next;
}
return NULL;
return nullptr;
}
static char* get_interface_name_by_index(int index, struct ifaddrs** ifaddrs_head)
{
struct ifaddrs* iface = find_interface_by_index(index, ifaddrs_head);
if (!iface || !iface->ifa_name)
return NULL;
return nullptr;
return iface->ifa_name;
}
@ -715,7 +715,7 @@ static int calculate_address_netmask(struct ifaddrs* ifa, struct ifaddrmsg* net_
{
uint32_t prefix_length = 0;
uint32_t data_length = 0;
unsigned char* netmask_data = NULL;
unsigned char* netmask_data = nullptr;
switch (ifa->ifa_addr->sa_family)
{
@ -782,7 +782,7 @@ static struct ifaddrs* get_link_address(const struct nlmsghdr* message,
ssize_t length = 0;
struct rtattr* attribute;
struct ifaddrmsg* net_address;
struct ifaddrs* ifa = NULL;
struct ifaddrs* ifa = nullptr;
struct sockaddr** sa;
size_t payload_size;
@ -811,7 +811,7 @@ static struct ifaddrs* get_link_address(const struct nlmsghdr* message,
{
payload_size = RTA_PAYLOAD(attribute);
YASIO_LOGV(" attribute payload_size == %u", (unsigned int)payload_size);
sa = NULL;
sa = nullptr;
switch (attribute->rta_type)
{
@ -860,7 +860,7 @@ static struct ifaddrs* get_link_address(const struct nlmsghdr* message,
{
/* IFA_LOCAL happened earlier, undo its effect here */
free(ifa->ifa_dstaddr);
ifa->ifa_dstaddr = NULL;
ifa->ifa_dstaddr = nullptr;
}
sa = &ifa->ifa_broadaddr;
break;
@ -873,7 +873,7 @@ static struct ifaddrs* get_link_address(const struct nlmsghdr* message,
* here. IFA_LOCAL carries the destination address, move it there
*/
ifa->ifa_dstaddr = ifa->ifa_addr;
ifa->ifa_addr = NULL;
ifa->ifa_addr = nullptr;
}
sa = &ifa->ifa_addr;
break;
@ -916,7 +916,7 @@ static struct ifaddrs* get_link_address(const struct nlmsghdr* message,
char* name =
get_interface_name_by_index(static_cast<int>(net_address->ifa_index), ifaddrs_head);
YASIO_LOGV(" address has no name/label, getting one from interface");
ifa->ifa_name = name ? strdup(name) : NULL;
ifa->ifa_name = name ? strdup(name) : nullptr;
}
YASIO_LOGV(" address label: %s", ifa->ifa_name);
@ -936,7 +936,7 @@ error : {
int errno_save = errno;
free_single_ifaddrs(&ifa);
errno = errno_save;
return NULL;
return nullptr;
}
}
@ -945,8 +945,8 @@ static struct ifaddrs* get_link_info(const struct nlmsghdr* message)
ssize_t length;
struct rtattr* attribute;
struct ifinfomsg* net_interface;
struct ifaddrs* ifa = NULL;
struct sockaddr_ll_extended* sa = NULL;
struct ifaddrs* ifa = nullptr;
struct sockaddr_ll_extended* sa = nullptr;
assert(message);
net_interface = reinterpret_cast<ifinfomsg*>(NLMSG_DATA(message));
@ -1007,13 +1007,13 @@ error:
free(sa);
free_single_ifaddrs(&ifa);
return NULL;
return nullptr;
}
typedef int (*getifaddrs_impl_fptr)(struct ifaddrs**);
typedef void (*freeifaddrs_impl_fptr)(struct ifaddrs* ifa);
static getifaddrs_impl_fptr getifaddrs_impl = NULL;
static freeifaddrs_impl_fptr freeifaddrs_impl = NULL;
static getifaddrs_impl_fptr getifaddrs_impl = nullptr;
static freeifaddrs_impl_fptr freeifaddrs_impl = nullptr;
static void getifaddrs_init() { get_ifaddrs_impl(&getifaddrs_impl, &freeifaddrs_impl); }
} // namespace internal
@ -1066,7 +1066,7 @@ inline int getifaddrs(struct ifaddrs** ifap)
if (!ifap)
return ret;
*ifap = NULL;
*ifap = nullptr;
struct ifaddrs* ifaddrs_head = 0;
struct ifaddrs* last_ifaddr = 0;
internal::netlink_session session;

View File

@ -71,7 +71,7 @@ static const char* inet_ntop6(const u_char* src, char* dst, socklen_t size);
* inet_ntop(af, src, dst, size)
* convert a network format address to presentation format.
* return:
* pointer to presentation format address (`dst'), or NULL (see errno).
* pointer to presentation format address (`dst'), or nullptr (see errno).
* author:
* Paul Vixie, 1996.
*/
@ -85,7 +85,7 @@ const char* inet_ntop(int af, const void* src, char* dst, socklen_t size)
return (inet_ntop6((const u_char*)src, dst, size));
default:
errno = EAFNOSUPPORT;
return (NULL);
return (nullptr);
}
/* NOTREACHED */
}
@ -109,7 +109,7 @@ static const char* inet_ntop4(const u_char* src, char* dst, socklen_t size)
if (SPRINTF((tmp, fmt, src[0], src[1], src[2], src[3])) >= static_cast<int>(size))
{
errno = (ENOSPC);
return (NULL);
return (nullptr);
}
return strcpy(dst, tmp);
}
@ -198,7 +198,7 @@ static const char* inet_ntop6(const u_char* src, char* dst, socklen_t size)
if (i == 6 && best.base == 0 && (best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
{
if (!inet_ntop4(src + 12, tp, static_cast<socklen_t>(sizeof tmp - (tp - tmp))))
return (NULL);
return (nullptr);
tp += strlen(tp);
break;
}
@ -215,7 +215,7 @@ static const char* inet_ntop6(const u_char* src, char* dst, socklen_t size)
if ((socklen_t)(tp - tmp) > size)
{
errno = (ENOSPC);
return (NULL);
return (nullptr);
}
return strcpy(dst, tmp);
}
@ -332,7 +332,7 @@ static int inet_pton6(const char* src, u_char* dst)
tp = (u_char*)memset(tmp, '\0', NS_IN6ADDRSZ);
endp = tp + NS_IN6ADDRSZ;
colonp = NULL;
colonp = nullptr;
/* Leading :: requires some special handling. */
if (*src == ':')
if (*++src != ':')
@ -345,7 +345,7 @@ static int inet_pton6(const char* src, u_char* dst)
const char* pch;
pch = strchr(xdigits, ch);
if (pch != NULL)
if (pch != nullptr)
{
val <<= 4;
val |= (pch - xdigits);
@ -391,7 +391,7 @@ static int inet_pton6(const char* src, u_char* dst)
*tp++ = (u_char)(val >> 8) & 0xff;
*tp++ = (u_char)val & 0xff;
}
if (colonp != NULL)
if (colonp != nullptr)
{
/*
* Since some memmove()'s erroneously fail to handle

View File

@ -60,7 +60,7 @@ inline ssl_st* mbedtls_ssl_new(ssl_ctx_st* ctx)
inline void mbedtls_ssl_set_fd(ssl_st* ssl, int fd)
{
ssl->bio.fd = fd;
::mbedtls_ssl_set_bio(ssl, &ssl->bio, ::mbedtls_net_send, ::mbedtls_net_recv, NULL /* rev_timeout() */);
::mbedtls_ssl_set_bio(ssl, &ssl->bio, ::mbedtls_net_send, ::mbedtls_net_recv, nullptr /* rev_timeout() */);
}
#else
# error "yasio - Unsupported ssl backend provided!"

View File

@ -310,26 +310,16 @@ void xxsocket::traverse_local_address(std::function<bool(const ip::endpoint&)> h
const char* errmsg = nullptr;
if (ailist != nullptr)
{
for (auto aip = ailist; aip != NULL; aip = aip->ai_next)
for (auto aip = ailist; aip != nullptr; aip = aip->ai_next)
{
family = aip->ai_family;
if (family == AF_INET || family == AF_INET6)
if (ep.as_is(aip))
{
ep.as_is(aip);
YASIO_LOGV("xxsocket::traverse_local_address: ip=%s", ep.ip().c_str());
switch (ep.af())
if (ep.is_global())
{
case AF_INET:
if (!IN4_IS_ADDR_LOOPBACK(&ep.in4_.sin_addr) && !IN4_IS_ADDR_LINKLOCAL(&ep.in4_.sin_addr))
done = handler(ep);
break;
case AF_INET6:
if (IN6_IS_ADDR_GLOBAL(&ep.in6_.sin6_addr))
done = handler(ep);
if (handler(ep))
break;
}
if (done)
break;
}
}
freeaddrinfo(ailist);
@ -358,28 +348,18 @@ void xxsocket::traverse_local_address(std::function<bool(const ip::endpoint&)> h
endpoint ep;
/* Walk through linked list*/
for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next)
for (ifa = ifaddr; ifa != nullptr; ifa = ifa->ifa_next)
{
if (ifa->ifa_addr == NULL)
if (ifa->ifa_addr == nullptr)
continue;
family = ifa->ifa_addr->sa_family;
if (family == AF_INET || family == AF_INET6)
if (ep.as_is(ifa->ifa_addr))
{
ep.as_is(ifa->ifa_addr);
YASIO_LOGV("xxsocket::traverse_local_address: ip=%s", ep.ip().c_str());
switch (ep.af())
if (ep.is_global())
{
case AF_INET:
if (!IN4_IS_ADDR_LOOPBACK(&ep.in4_.sin_addr) && !IN4_IS_ADDR_LINKLOCAL(&ep.in4_.sin_addr))
done = handler(ep);
break;
case AF_INET6:
if (IN6_IS_ADDR_GLOBAL(&ep.in6_.sin6_addr))
done = handler(ep);
if (handler(ep))
break;
}
if (done)
break;
}
}
@ -584,7 +564,7 @@ int xxsocket::connect_n(socket_native_type s, const endpoint& ep, const std::chr
if (n == 0)
goto done; /* connect completed immediately */
if ((n = xxsocket::select(s, &rset, &wset, NULL, wtimeout)) <= 0)
if ((n = xxsocket::select(s, &rset, &wset, nullptr, wtimeout)) <= 0)
error = xxsocket::get_last_errno();
else if ((FD_ISSET(s, &rset) || FD_ISSET(s, &wset)))
{ /* Everythings are ok */
@ -938,7 +918,7 @@ const char* xxsocket::strerror(int error)
ZeroMemory(error_msg, sizeof(error_msg));
::FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK /* remove line-end charactors \r\n */, NULL,
error, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), // english language
error_msg, sizeof(error_msg), NULL);
error_msg, sizeof(error_msg), nullptr);
return error_msg;
#else

View File

@ -160,7 +160,7 @@ struct yasio__global_state {
yasio__min_wait_duration = std::thread::hardware_concurrency() > 1 ? 0LL : YASIO_MIN_WAIT_DURATION;
#if defined(YASIO_SSL_BACKEND) && YASIO_SSL_BACKEND == 1
# if OPENSSL_VERSION_NUMBER >= 0x10100000 && !defined(LIBRESSL_VERSION_NUMBER)
if (OPENSSL_init_ssl(0, NULL) == 1)
if (OPENSSL_init_ssl(0, nullptr) == 1)
yasio__setbits(this->init_flags_, INITF_SSL);
# endif
#endif