mirror of
https://github.com/oatpp/oatpp.git
synced 2024-12-03 08:59:56 +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/async/Error.hpp"
|
||||||
#include "oatpp/core/Types.hpp"
|
#include "oatpp/core/Types.hpp"
|
||||||
|
|
||||||
|
#if !defined(WIN32) && !defined(_WIN32)
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace oatpp {
|
namespace oatpp {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,9 +43,11 @@ namespace oatpp {
|
|||||||
#else
|
#else
|
||||||
typedef unsigned long v_io_handle;
|
typedef unsigned long v_io_handle;
|
||||||
#endif
|
#endif
|
||||||
|
typedef int v_sock_size;
|
||||||
constexpr const v_io_handle INVALID_IO_HANDLE = v_io_handle (-1);
|
constexpr const v_io_handle INVALID_IO_HANDLE = v_io_handle (-1);
|
||||||
#else
|
#else
|
||||||
typedef int v_io_handle;
|
typedef int v_io_handle;
|
||||||
|
typedef socklen_t v_sock_size;
|
||||||
constexpr const v_io_handle INVALID_IO_HANDLE = (-1);
|
constexpr const v_io_handle INVALID_IO_HANDLE = (-1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ provider::ResourceHandle<data::stream::IOStream> ConnectionProvider::get() {
|
|||||||
|
|
||||||
if(clientHandle >= 0) {
|
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;
|
break;
|
||||||
} else {
|
} else {
|
||||||
err = errno;
|
err = errno;
|
||||||
@ -282,7 +282,7 @@ oatpp::async::CoroutineStarterForResult<const provider::ResourceHandle<data::str
|
|||||||
Action doConnect() {
|
Action doConnect() {
|
||||||
errno = 0;
|
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)
|
#if defined(WIN32) || defined(_WIN32)
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
|
|
||||||
// Workaround for MinGW from: https://www.mail-archive.com/users@ipv6.org/msg02107.html
|
// Workaround for MinGW from: https://www.mail-archive.com/users@ipv6.org/msg02107.html
|
||||||
#if defined(__MINGW32__) && _WIN32_WINNT < 0x0600
|
#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) {
|
if (af == AF_INET) {
|
||||||
struct sockaddr_in in;
|
struct sockaddr_in in;
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){
|
|||||||
// Update port after binding (typicaly in case of port = 0)
|
// Update port after binding (typicaly in case of port = 0)
|
||||||
struct ::sockaddr_in s_in;
|
struct ::sockaddr_in s_in;
|
||||||
::memset(&s_in, 0, sizeof(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);
|
::getsockname(serverHandle, (struct sockaddr *)&s_in, &s_in_len);
|
||||||
setProperty(PROPERTY_PORT, oatpp::utils::conversion::int32ToStr(ntohs(s_in.sin_port)));
|
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))
|
"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)
|
listen(serverHandle, 10000) == 0)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@ -309,7 +309,7 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){
|
|||||||
// Update port after binding (typicaly in case of port = 0)
|
// Update port after binding (typicaly in case of port = 0)
|
||||||
::sockaddr_in s_in;
|
::sockaddr_in s_in;
|
||||||
::memset(&s_in, 0, sizeof(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);
|
::getsockname(serverHandle, reinterpret_cast<sockaddr*>(&s_in), &s_in_len);
|
||||||
setProperty(PROPERTY_PORT, oatpp::utils::conversion::int32ToStr(ntohs(s_in.sin_port)));
|
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() {
|
provider::ResourceHandle<data::stream::IOStream> ConnectionProvider::getExtendedConnection() {
|
||||||
|
|
||||||
sockaddr_storage clientAddress;
|
sockaddr_storage clientAddress;
|
||||||
socklen_t clientAddressSize = sizeof(clientAddress);
|
v_sock_size clientAddressSize = sizeof(clientAddress);
|
||||||
|
|
||||||
data::stream::Context::Properties properties;
|
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) {
|
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];
|
auto& method = m_methods[id];
|
||||||
if(method) {
|
if(method) {
|
||||||
return (*method)(this, caret, type);
|
return (*method)(this, caret, type);
|
||||||
|
@ -259,7 +259,7 @@ void Serializer::serializeObject(Serializer* serializer,
|
|||||||
void Serializer::serialize(data::stream::ConsistentOutputStream* stream,
|
void Serializer::serialize(data::stream::ConsistentOutputStream* stream,
|
||||||
const oatpp::Void& polymorph)
|
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];
|
auto& method = m_methods[id];
|
||||||
if(method) {
|
if(method) {
|
||||||
(*method)(this, stream, polymorph);
|
(*method)(this, stream, polymorph);
|
||||||
|
Loading…
Reference in New Issue
Block a user