From 2b3728af37979d8aa7c0c5322131f7e264863a08 Mon Sep 17 00:00:00 2001 From: Eric Frias Date: Fri, 20 Jun 2014 10:38:21 -0400 Subject: [PATCH 1/2] Add -> for directory_iterator --- include/fc/filesystem.hpp | 19 +++++++++++++++++++ src/filesystem.cpp | 1 + 2 files changed, 20 insertions(+) diff --git a/include/fc/filesystem.hpp b/include/fc/filesystem.hpp index d1a9c31..d67cdd8 100644 --- a/include/fc/filesystem.hpp +++ b/include/fc/filesystem.hpp @@ -85,6 +85,24 @@ namespace fc { #endif }; + namespace detail + { + class path_wrapper + { + public: + path_wrapper(path p) : + _path(p) + { + } + const path* operator->() const + { + return &_path; + } + private: + path _path; + }; + } + class directory_iterator { public: directory_iterator( const fc::path& p ); @@ -92,6 +110,7 @@ namespace fc { ~directory_iterator(); fc::path operator*()const; + detail::path_wrapper operator->() const; directory_iterator& operator++(int); directory_iterator& operator++(); diff --git a/src/filesystem.cpp b/src/filesystem.cpp index 1c746ae..2dd961a 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -158,6 +158,7 @@ namespace fc { directory_iterator::~directory_iterator(){} fc::path directory_iterator::operator*()const { return boost::filesystem::path(*(*_p)); } + detail::path_wrapper directory_iterator::operator->() const { return detail::path_wrapper(boost::filesystem::path(*(*_p))); } directory_iterator& directory_iterator::operator++(int) { (*_p)++; return *this; } directory_iterator& directory_iterator::operator++() { (*_p)++; return *this; } From 331e6aac7d1ac7a6fd7c0b0fa092099eb25c99a1 Mon Sep 17 00:00:00 2001 From: Eric Frias Date: Fri, 20 Jun 2014 12:22:37 -0400 Subject: [PATCH 2/2] Convert networking exceptions to fc::exceptions to properly catch them in NTP code (fixes at least some of the shutdown crashes) --- src/network/ntp.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/network/ntp.cpp b/src/network/ntp.cpp index de590d4..a764448 100644 --- a/src/network/ntp.cpp +++ b/src/network/ntp.cpp @@ -74,7 +74,10 @@ namespace fc { fc::ip::endpoint from; std::array recv_buf; - _sock.receive_from( (char*)recv_buf.data(), recv_buf.size(), from ); + try + { + _sock.receive_from( (char*)recv_buf.data(), recv_buf.size(), from ); + } FC_RETHROW_EXCEPTIONS(error, "Error reading from NTP socket"); uint64_t receive_timestamp_net_order = recv_buf[4]; uint64_t receive_timestamp_host = bswap_64(receive_timestamp_net_order); @@ -120,7 +123,7 @@ namespace fc } catch ( const fc::exception& ) { - // we exepect canceled exceptions, but cannot throw + // we expect canceled exceptions, but cannot throw // from destructor } }