diff options
author | chriseth <c@ethdev.com> | 2017-02-25 07:11:26 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2017-02-25 07:11:26 +0800 |
commit | 4305ecb0e7bca7f64324e0804df9543c4775aa6f (patch) | |
tree | 3c85dd32c0505c37d8593d085bbd2d2cfb96bf07 /test/RPCSession.cpp | |
parent | d2c79bf8e9400f783bf0feed34065882eae02a68 (diff) | |
download | dexon-solidity-4305ecb0e7bca7f64324e0804df9543c4775aa6f.tar dexon-solidity-4305ecb0e7bca7f64324e0804df9543c4775aa6f.tar.gz dexon-solidity-4305ecb0e7bca7f64324e0804df9543c4775aa6f.tar.bz2 dexon-solidity-4305ecb0e7bca7f64324e0804df9543c4775aa6f.tar.lz dexon-solidity-4305ecb0e7bca7f64324e0804df9543c4775aa6f.tar.xz dexon-solidity-4305ecb0e7bca7f64324e0804df9543c4775aa6f.tar.zst dexon-solidity-4305ecb0e7bca7f64324e0804df9543c4775aa6f.zip |
Try reading multiple times from IPC.
Diffstat (limited to 'test/RPCSession.cpp')
-rw-r--r-- | test/RPCSession.cpp | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/test/RPCSession.cpp b/test/RPCSession.cpp index ff00d783..57829ff5 100644 --- a/test/RPCSession.cpp +++ b/test/RPCSession.cpp @@ -16,19 +16,20 @@ The Implementation originally from https://msdn.microsoft.com/en-us/library/windows/desktop/aa365592(v=vs.85).aspx */ -/** @file RPCSession.cpp - * @author Dimtiry Khokhlov <dimitry@ethdev.com> - * @author Alex Beregszaszi - * @date 2016 - */ +/// @file RPCSession.cpp +/// Low-level IPC communication between the test framework and the Ethereum node. + +#include "RPCSession.h" -#include <string> -#include <stdio.h> -#include <thread> #include <libdevcore/CommonData.h> + #include <json/reader.h> #include <json/writer.h> -#include "RPCSession.h" + +#include <string> +#include <stdio.h> +#include <thread> +#include <chrono> using namespace std; using namespace dev; @@ -107,13 +108,23 @@ string IPCSocket::sendRequest(string const& _req) return string(m_readBuf, m_readBuf + cbRead); #else if (send(m_socket, _req.c_str(), _req.length(), 0) != (ssize_t)_req.length()) - BOOST_FAIL("Writing on IPC failed"); - - ssize_t ret = recv(m_socket, m_readBuf, sizeof(m_readBuf), 0); + BOOST_FAIL("Writing on IPC failed."); - // Also consider closed socket an error. - if (ret <= 0) - BOOST_FAIL("Reading on IPC failed"); + auto start = chrono::steady_clock::now(); + ssize_t ret; + do + { + ret = recv(m_socket, m_readBuf, sizeof(m_readBuf), 0); + // Also consider closed socket an error. + if (ret < 0) + BOOST_FAIL("Reading on IPC failed."); + } while ( + ret == 0 && + chrono::duration_cast<chrono::milliseconds>(chrono::steady_clock::now() - start).count() < m_readTimeOutMS + ); + + if (ret == 0) + BOOST_FAIL("Timeout reading on IPC."); return string(m_readBuf, m_readBuf + ret); #endif |