mirror of
https://github.com/oatpp/oatpp.git
synced 2024-11-27 08:30:07 +08:00
Merge branch 'master' into clang
* master: Fix v_sock_size definition Use auto for 2 locals Convert uses of socklen_t to v_sock_size Introduce v_sock_size for socklen_t
This commit is contained in:
commit
6d9f9bb5e2
@ -28,6 +28,10 @@
|
||||
#include "oatpp/core/async/Error.hpp"
|
||||
#include "oatpp/core/Types.hpp"
|
||||
|
||||
#if !defined(WIN32) && !defined(_WIN32)
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
namespace oatpp {
|
||||
|
||||
/**
|
||||
@ -39,9 +43,11 @@ namespace oatpp {
|
||||
#else
|
||||
typedef unsigned long v_io_handle;
|
||||
#endif
|
||||
typedef int v_sock_size;
|
||||
constexpr const v_io_handle INVALID_IO_HANDLE = v_io_handle (-1);
|
||||
#else
|
||||
typedef int v_io_handle;
|
||||
typedef socklen_t v_sock_size;
|
||||
constexpr const v_io_handle INVALID_IO_HANDLE = (-1);
|
||||
#endif
|
||||
|
||||
|
@ -123,7 +123,7 @@ provider::ResourceHandle<data::stream::IOStream> ConnectionProvider::get() {
|
||||
|
||||
if(clientHandle >= 0) {
|
||||
|
||||
if(connect(clientHandle, currResult->ai_addr, static_cast<socklen_t>(currResult->ai_addrlen)) == 0) {
|
||||
if(connect(clientHandle, currResult->ai_addr, static_cast<v_sock_size>(currResult->ai_addrlen)) == 0) {
|
||||
break;
|
||||
} else {
|
||||
err = errno;
|
||||
@ -282,7 +282,7 @@ oatpp::async::CoroutineStarterForResult<const provider::ResourceHandle<data::str
|
||||
Action doConnect() {
|
||||
errno = 0;
|
||||
|
||||
auto res = connect(m_clientHandle, m_currentResult->ai_addr, static_cast<socklen_t>(m_currentResult->ai_addrlen));
|
||||
auto res = connect(m_clientHandle, m_currentResult->ai_addr, static_cast<v_sock_size>(m_currentResult->ai_addrlen));
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
|
||||
|
@ -46,7 +46,7 @@
|
||||
|
||||
// Workaround for MinGW from: https://www.mail-archive.com/users@ipv6.org/msg02107.html
|
||||
#if defined(__MINGW32__) && _WIN32_WINNT < 0x0600
|
||||
const char * inet_ntop (int af, const void *src, char *dst, socklen_t cnt) {
|
||||
const char * inet_ntop (int af, const void *src, char *dst, oatpp::v_sock_size cnt) {
|
||||
if (af == AF_INET) {
|
||||
struct sockaddr_in in;
|
||||
|
||||
@ -228,7 +228,7 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){
|
||||
// Update port after binding (typicaly in case of port = 0)
|
||||
struct ::sockaddr_in s_in;
|
||||
::memset(&s_in, 0, sizeof(s_in));
|
||||
::socklen_t s_in_len = sizeof(s_in);
|
||||
oatpp::v_sock_size s_in_len = sizeof(s_in);
|
||||
::getsockname(serverHandle, (struct sockaddr *)&s_in, &s_in_len);
|
||||
setProperty(PROPERTY_PORT, oatpp::utils::conversion::int32ToStr(ntohs(s_in.sin_port)));
|
||||
|
||||
@ -280,7 +280,7 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){
|
||||
"Warning. Failed to set %s for accepting socket: %s", "SO_REUSEADDR", strerror(errno))
|
||||
}
|
||||
|
||||
if (bind(serverHandle, currResult->ai_addr, static_cast<socklen_t>(currResult->ai_addrlen)) == 0 &&
|
||||
if (bind(serverHandle, currResult->ai_addr, static_cast<v_sock_size>(currResult->ai_addrlen)) == 0 &&
|
||||
listen(serverHandle, 10000) == 0)
|
||||
{
|
||||
break;
|
||||
@ -309,7 +309,7 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){
|
||||
// Update port after binding (typicaly in case of port = 0)
|
||||
::sockaddr_in s_in;
|
||||
::memset(&s_in, 0, sizeof(s_in));
|
||||
::socklen_t s_in_len = sizeof(s_in);
|
||||
oatpp::v_sock_size s_in_len = sizeof(s_in);//FIXME trace
|
||||
::getsockname(serverHandle, reinterpret_cast<sockaddr*>(&s_in), &s_in_len);
|
||||
setProperty(PROPERTY_PORT, oatpp::utils::conversion::int32ToStr(ntohs(s_in.sin_port)));
|
||||
|
||||
@ -351,7 +351,7 @@ provider::ResourceHandle<data::stream::IOStream> ConnectionProvider::getDefaultC
|
||||
provider::ResourceHandle<data::stream::IOStream> ConnectionProvider::getExtendedConnection() {
|
||||
|
||||
sockaddr_storage clientAddress;
|
||||
socklen_t clientAddressSize = sizeof(clientAddress);
|
||||
v_sock_size clientAddressSize = sizeof(clientAddress);
|
||||
|
||||
data::stream::Context::Properties properties;
|
||||
|
||||
|
@ -494,7 +494,7 @@ oatpp::Void Deserializer::deserializeObject(Deserializer* deserializer, parser::
|
||||
}
|
||||
|
||||
oatpp::Void Deserializer::deserialize(parser::Caret& caret, const Type* const type) {
|
||||
v_uint32 id = static_cast<v_uint32>(type->classId.id);
|
||||
auto id = static_cast<v_uint32>(type->classId.id);
|
||||
auto& method = m_methods[id];
|
||||
if(method) {
|
||||
return (*method)(this, caret, type);
|
||||
|
@ -259,7 +259,7 @@ void Serializer::serializeObject(Serializer* serializer,
|
||||
void Serializer::serialize(data::stream::ConsistentOutputStream* stream,
|
||||
const oatpp::Void& polymorph)
|
||||
{
|
||||
v_uint32 id = static_cast<v_uint32>(polymorph.getValueType()->classId.id);
|
||||
auto id = static_cast<v_uint32>(polymorph.getValueType()->classId.id);
|
||||
auto& method = m_methods[id];
|
||||
if(method) {
|
||||
(*method)(this, stream, polymorph);
|
||||
|
Loading…
Reference in New Issue
Block a user