From 4812477ea6354e15fbb6b38f50e7ab03e4ad7b1a Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Sat, 24 Nov 2012 13:02:23 -0500 Subject: [PATCH] numerous bug fixes --- include/fc/future.hpp | 6 ++++-- include/fc/iostream_wrapper.hpp | 8 +++++--- include/fc/json_rpc_process_client.hpp | 14 +++++++++----- src/process.cpp | 2 +- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/include/fc/future.hpp b/include/fc/future.hpp index c634b55..d3d2ee5 100644 --- a/include/fc/future.hpp +++ b/include/fc/future.hpp @@ -167,18 +167,20 @@ namespace fc { future( const shared_ptr>& p ):m_prom(p){} future( shared_ptr>&& p ):m_prom(fc::move(p)){} future(){} + + operator const T&()const { return wait(); } /// @pre valid() /// @post ready() /// @throws timeout - const T& wait( const microseconds& timeout = microseconds::max() ){ + const T& wait( const microseconds& timeout = microseconds::max() )const { return m_prom->wait(timeout); } /// @pre valid() /// @post ready() /// @throws timeout - const T& wait_until( const time_point& tp ) { + const T& wait_until( const time_point& tp )const { return m_prom->wait_until(tp); } diff --git a/include/fc/iostream_wrapper.hpp b/include/fc/iostream_wrapper.hpp index 7524f9d..3b5fcdb 100644 --- a/include/fc/iostream_wrapper.hpp +++ b/include/fc/iostream_wrapper.hpp @@ -31,6 +31,7 @@ namespace fc { } struct impl_base : public fc::retainable { + virtual ~impl_base(){} virtual void write( const char* buf, size_t len ) = 0; virtual void close() = 0; virtual void flush() = 0; @@ -85,9 +86,10 @@ namespace fc { protected: struct impl_base : public fc::retainable { - virtual void read( char* buf, size_t len ) = 0; - virtual size_t readsome( char* buf, size_t len ) = 0; - virtual bool eof()const; + virtual ~impl_base(){} + virtual void read( char* buf, size_t len )=0; + virtual size_t readsome( char* buf, size_t len )=0; + virtual bool eof()const=0; }; template diff --git a/include/fc/json_rpc_process_client.hpp b/include/fc/json_rpc_process_client.hpp index e2e29b2..88c7214 100644 --- a/include/fc/json_rpc_process_client.hpp +++ b/include/fc/json_rpc_process_client.hpp @@ -1,6 +1,8 @@ #pragma once #include +#include #include +#include namespace fc { namespace json { @@ -9,7 +11,7 @@ namespace fc { namespace json { public: fc::future exec( const fc::path& exe, int opt = fc::process::open_all ) { - return exec( exe, fc::path(), opt ); + return exec( exe, fc::path("."), opt ); } fc::future exec( const fc::path& exe, const fc::path& wd, int opt = fc::process::open_all ) { @@ -17,14 +19,16 @@ namespace fc { namespace json { } fc::future exec( const fc::path& exe, fc::vector&& args , int opt = fc::process::open_all ) { - return exec( exe, fc::move(args), fc::path(), opt ); + return exec( exe, fc::move(args), fc::path("."), opt ); } fc::future exec( const fc::path& exe, fc::vector&& args, const fc::path& wd, int opt = fc::process::open_all ) { - auto r = _proc.exec( exe, fc::move(args), wd, opt ); + slog( "cd %s; %s", wd.generic_string().c_str(), exe.generic_string().c_str() ); + auto r = _proc.exec( canonical(exe), fc::move(args), wd, opt ); _con.reset( new fc::json::rpc_stream_connection( _proc.out_stream(), _proc.in_stream() ) ); this->_vtable.reset(new fc::detail::vtable() ); - this->_vtable->template visit( fc::json::detail::vtable_visitor(_con) ); + rpc_connection::ptr p(_con); + this->_vtable->template visit_other( fc::json::detail::vtable_visitor(p) ); return r; } @@ -35,7 +39,7 @@ namespace fc { namespace json { */ fc::istream& err_stream() { return _proc.err_stream(); } - template + template void on_close( T&& f) { _con->on_close( fc::forward(f) ); } private: diff --git a/src/process.cpp b/src/process.cpp index 705d343..9773edd 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -133,7 +133,7 @@ fc::future process::exec( const fc::path& exe, fc::vector&& arg promise::ptr p(new promise("process")); my->stat.async_wait( my->child->get_id(), [=]( const boost::system::error_code& ec, int exit_code ) { - slog( "process::result %1%", exit_code ); + slog( "process::result %d", exit_code ); if( !ec ) { #ifdef BOOST_POSIX_API try {