aboutsummaryrefslogtreecommitdiffstats
path: root/test/RPCSession.cpp
diff options
context:
space:
mode:
authorDmitry K <winsvega@mail.ru>2016-08-02 16:11:09 +0800
committerDmitry K <winsvega@mail.ru>2016-08-02 16:11:09 +0800
commita10b6f92f97bf2eacc80534f6640e08f0b26e95d (patch)
treeffb7d72d52ae7a8d30194186bc15886c10118c5a /test/RPCSession.cpp
parentd1c744450965644df17fcc73006dd7495e75c477 (diff)
parent85a61fe886c2d99d397bf30cc01d971558130287 (diff)
downloaddexon-solidity-a10b6f92f97bf2eacc80534f6640e08f0b26e95d.tar.gz
dexon-solidity-a10b6f92f97bf2eacc80534f6640e08f0b26e95d.tar.zst
dexon-solidity-a10b6f92f97bf2eacc80534f6640e08f0b26e95d.zip
Merge branch 'develop' of https://github.com/ethereum/solidity into develop
Diffstat (limited to 'test/RPCSession.cpp')
-rw-r--r--test/RPCSession.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/test/RPCSession.cpp b/test/RPCSession.cpp
index 68369567..124ee789 100644
--- a/test/RPCSession.cpp
+++ b/test/RPCSession.cpp
@@ -38,15 +38,25 @@ IPCSocket::IPCSocket(string const& _path): m_path(_path)
BOOST_FAIL("Error opening IPC: socket path is too long!");
struct sockaddr_un saun;
+ memset(&saun, 0, sizeof(sockaddr_un));
saun.sun_family = AF_UNIX;
strcpy(saun.sun_path, _path.c_str());
+// http://idletechnology.blogspot.ca/2011/12/unix-domain-sockets-on-osx.html
+//
+// SUN_LEN() might be optimal, but it seemingly affects the portability,
+// with at least Android missing this macro. Just using the sizeof() for
+// structure seemingly works, and would only have the side-effect of
+// sending larger-than-required packets over the socket. Given that this
+// code is only used for unit-tests, that approach seems simpler.
+#if defined(__APPLE__)
+ saun.sun_len = sizeof(struct sockaddr_un);
+#endif // defined(__APPLE__)
+
if ((m_socket = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
BOOST_FAIL("Error creating IPC socket object");
- int len = sizeof(saun.sun_family) + strlen(saun.sun_path);
-
- if (connect(m_socket, reinterpret_cast<struct sockaddr const*>(&saun), len) < 0)
+ if (connect(m_socket, reinterpret_cast<struct sockaddr const*>(&saun), sizeof(struct sockaddr_un)) < 0)
BOOST_FAIL("Error connecting to IPC socket: " << _path);
m_fp = fdopen(m_socket, "r");