diff options
| author | Dennis Brentjes <d.brentjes@gmail.com> | 2016-10-27 09:25:53 +0200 |
|---|---|---|
| committer | Dennis Brentjes <d.brentjes@gmail.com> | 2016-10-27 09:25:53 +0200 |
| commit | 25db9ff8a4cfb4b98aeeaae360e8c718b9c5e20c (patch) | |
| tree | 079ea63fcc874506072a91b13d2612b510cf158e /libcmix-network | |
| parent | 9eaf47d5dfa56ca79ae903aabfc2cf52bdfb981e (diff) | |
| download | cmix-25db9ff8a4cfb4b98aeeaae360e8c718b9c5e20c.tar.gz cmix-25db9ff8a4cfb4b98aeeaae360e8c718b9c5e20c.tar.bz2 cmix-25db9ff8a4cfb4b98aeeaae360e8c718b9c5e20c.zip | |
Adds libgcrypt implementation for elgamal in multiplicative group.
Also adapts the API to both handle sodium and gcrypt libraries.
Diffstat (limited to 'libcmix-network')
| -rw-r--r-- | libcmix-network/CMakeLists.txt | 8 | ||||
| -rw-r--r-- | libcmix-network/client.hpp | 3 | ||||
| -rw-r--r-- | libcmix-network/connect.cpp | 10 |
3 files changed, 18 insertions, 3 deletions
diff --git a/libcmix-network/CMakeLists.txt b/libcmix-network/CMakeLists.txt index 057061c..cfe02f1 100644 --- a/libcmix-network/CMakeLists.txt +++ b/libcmix-network/CMakeLists.txt @@ -29,6 +29,14 @@ target_link_libraries(cmix-network PUBLIC log ) +option(enable_asio_handler_debug "Enable Asio handler logging to stderr" off) + +if(enable_asio_handler_debug) + target_compile_definitions(cmix-network + PUBLIC BOOST_ASIO_ENABLE_HANDLER_TRACKING + ) +endif(enable_asio_handler_debug) + if(WIN32) target_include_directories(cmix-network PUBLIC ${OPENSSL_INCLUDE_DIRS} diff --git a/libcmix-network/client.hpp b/libcmix-network/client.hpp index 2501908..df8c0c4 100644 --- a/libcmix-network/client.hpp +++ b/libcmix-network/client.hpp @@ -174,6 +174,7 @@ public: * \param message_handler The function to call when a message has been received. */ void async_receive(MessageHandler message_handler) { + BOOST_LOG_TRIVIAL(trace) << socket.get(); using namespace boost::asio::placeholders; boost::asio::async_read( @@ -268,7 +269,7 @@ struct SSLClient : private BaseClient<boost::asio::ssl::stream<boost::asio::ip:: * \brief close Closes the underlying socket. */ void close() { - socket->lowest_layer().close(); + socket->lowest_layer().cancel(); } using BaseClient::on_done; diff --git a/libcmix-network/connect.cpp b/libcmix-network/connect.cpp index 9df9b56..e80a6d4 100644 --- a/libcmix-network/connect.cpp +++ b/libcmix-network/connect.cpp @@ -6,6 +6,8 @@ #include <boost/asio/ip/address.hpp> #include <boost/asio/ssl.hpp> +#include <iostream> + using namespace boost::asio::ip; using namespace boost::asio; using boost::asio::io_service; @@ -69,8 +71,10 @@ void async_connect_iteration(basic_socket<tcp, stream_socket_service<tcp>>& sock info->retry_timer.expires_from_now(boost::posix_time::seconds(seconds_to_wait)); info->retry_timer.async_wait([&socket, info, on_connect](boost::system::error_code const& ec){ - if(ec) { - BOOST_LOG_TRIVIAL(error) << "Something went wrong with the retry timer: " << ec; + if(ec == boost::system::errc::operation_canceled) { + return; + } else if(ec) { + BOOST_LOG_TRIVIAL(error) << "Something went wrong with the retry timer: " << ec.message(); } else { async_connect_iteration(socket, info, on_connect); } @@ -83,9 +87,11 @@ void async_connect_iteration(basic_socket<tcp, stream_socket_service<tcp>>& sock } } else if(ec) { BOOST_LOG_TRIVIAL(info) << ec << std::endl; + info->retry_timer.cancel(); info->it++; async_connect_iteration(socket, info, on_connect); } else { + info->retry_timer.cancel(); on_connect(); } }; |
