Merge branch 'phoenix' of https://github.com/InvictusInnovations/fc into phoenix
This commit is contained in:
commit
9378f6c7aa
4 changed files with 12 additions and 10 deletions
|
|
@ -7,7 +7,7 @@ namespace fc {
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
NO_RETURN void throw_datastream_range_error( const char* file, size_t len, size_t over );
|
NO_RETURN void throw_datastream_range_error( const char* file, size_t len, int64_t over );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#include <fc/io/datastream.hpp>
|
#include <fc/io/datastream.hpp>
|
||||||
#include <fc/exception/exception.hpp>
|
#include <fc/exception/exception.hpp>
|
||||||
|
|
||||||
NO_RETURN void fc::detail::throw_datastream_range_error(char const* method, size_t len, size_t over)
|
NO_RETURN void fc::detail::throw_datastream_range_error(char const* method, size_t len, int64_t over)
|
||||||
{
|
{
|
||||||
FC_THROW_EXCEPTION( out_of_range_exception, "${method} datastream of length ${len} over by ${over}", ("method",fc::string(method))("len",len)("over",over) );
|
FC_THROW_EXCEPTION( out_of_range_exception, "${method} datastream of length ${len} over by ${over}", ("method",fc::string(method))("len",len)("over",over) );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -106,23 +106,23 @@ namespace fc {
|
||||||
if (WSAIoctl(my->_sock.native(), SIO_KEEPALIVE_VALS, &keepalive_settings, sizeof(keepalive_settings),
|
if (WSAIoctl(my->_sock.native(), SIO_KEEPALIVE_VALS, &keepalive_settings, sizeof(keepalive_settings),
|
||||||
NULL, 0, &dwBytesRet, NULL, NULL) == SOCKET_ERROR)
|
NULL, 0, &dwBytesRet, NULL, NULL) == SOCKET_ERROR)
|
||||||
wlog("Error setting TCP keepalive values");
|
wlog("Error setting TCP keepalive values");
|
||||||
#else
|
#elif !defined(__clang__) || (__clang_major__ >= 6)
|
||||||
# if !defined(__clang__) || (__clang_major__ >= 6)
|
|
||||||
// This should work for modern Linuxes and for OSX >= Mountain Lion
|
// This should work for modern Linuxes and for OSX >= Mountain Lion
|
||||||
int timeout_sec = interval.count() / fc::seconds(1).count();
|
int timeout_sec = interval.count() / fc::seconds(1).count();
|
||||||
if (setsockopt(my->_sock.native(), IPPROTO_TCP,
|
if (setsockopt(my->_sock.native(), IPPROTO_TCP,
|
||||||
# if defined( __APPLE__ )
|
#if defined( __APPLE__ )
|
||||||
TCP_KEEPALIVE,
|
TCP_KEEPALIVE,
|
||||||
# else
|
#else
|
||||||
TCP_KEEPIDLE,
|
TCP_KEEPIDLE,
|
||||||
# endif
|
#endif
|
||||||
(char*)&timeout_sec, sizeof(timeout_sec)) < 0)
|
(char*)&timeout_sec, sizeof(timeout_sec)) < 0)
|
||||||
wlog("Error setting TCP keepalive idle time");
|
wlog("Error setting TCP keepalive idle time");
|
||||||
|
# if !defined(__APPLE__) || defined(TCP_KEEPINTVL) // TCP_KEEPINTVL not defined before 10.9
|
||||||
if (setsockopt(my->_sock.native(), IPPROTO_TCP, TCP_KEEPINTVL,
|
if (setsockopt(my->_sock.native(), IPPROTO_TCP, TCP_KEEPINTVL,
|
||||||
(char*)&timeout_sec, sizeof(timeout_sec)) < 0)
|
(char*)&timeout_sec, sizeof(timeout_sec)) < 0)
|
||||||
wlog("Error setting TCP keepalive interval");
|
wlog("Error setting TCP keepalive interval");
|
||||||
# endif
|
# endif // !__APPLE__ || TCP_KEEPINTVL
|
||||||
#endif
|
#endif // !WIN32
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ namespace fc { namespace rpc {
|
||||||
|
|
||||||
void send_result( variant id, variant result )
|
void send_result( variant id, variant result )
|
||||||
{
|
{
|
||||||
ilog( "send ${i} ${r}", ("i",id)("r",result) );
|
ilog( "send: {\"id\": ${i}, \"result\": ${r}}", ("i",id)("r",result) );
|
||||||
{
|
{
|
||||||
fc::scoped_lock<fc::mutex> lock(_write_mutex);
|
fc::scoped_lock<fc::mutex> lock(_write_mutex);
|
||||||
*_out << "{\"id\":";
|
*_out << "{\"id\":";
|
||||||
|
|
@ -48,6 +48,8 @@ namespace fc { namespace rpc {
|
||||||
}
|
}
|
||||||
void send_error( variant id, fc::exception& e )
|
void send_error( variant id, fc::exception& e )
|
||||||
{
|
{
|
||||||
|
ilog( "send: {\"id\": ${i}, \"error\":{\"message\": ${what},\"code\":0,\"data\":${data}}}",
|
||||||
|
("i",id)("what",e.what())("data", e) );
|
||||||
{
|
{
|
||||||
fc::scoped_lock<fc::mutex> lock(_write_mutex);
|
fc::scoped_lock<fc::mutex> lock(_write_mutex);
|
||||||
*_out << "{\"id\":";
|
*_out << "{\"id\":";
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue