diff --git a/libethereum/PeerNetwork.cpp b/libethereum/PeerNetwork.cpp index 828caec46..c77af38eb 100644 --- a/libethereum/PeerNetwork.cpp +++ b/libethereum/PeerNetwork.cpp @@ -483,19 +483,21 @@ bool PeerSession::checkPacket(bytesConstRef _msg) void PeerSession::sendDestroy(bytes& _msg) { clogS(NetLeft) << RLP(bytesConstRef(&_msg).cropped(8)); - std::shared_ptr buffer = std::make_shared(); - swap(*buffer, _msg); - if (!checkPacket(bytesConstRef(&*buffer))) + + if (!checkPacket(bytesConstRef(&_msg))) { cwarn << "INVALID PACKET CONSTRUCTED!"; - } - ba::async_write(m_socket, ba::buffer(*buffer), [=](boost::system::error_code ec, std::size_t length) + + auto self(shared_from_this()); + bytes* buffer = new bytes(std::move(_msg)); + ba::async_write(m_socket, ba::buffer(*buffer), [self,buffer](boost::system::error_code ec, std::size_t length) { + delete buffer; if (ec) { cwarn << "Error sending: " << ec.message(); - dropped(); + self->dropped(); } // cbug << length << " bytes written (EC: " << ec << ")"; }); @@ -504,17 +506,21 @@ void PeerSession::sendDestroy(bytes& _msg) void PeerSession::send(bytesConstRef _msg) { clogS(NetLeft) << RLP(_msg.cropped(8)); - std::shared_ptr buffer = std::make_shared(_msg.toBytes()); + if (!checkPacket(_msg)) { cwarn << "INVALID PACKET CONSTRUCTED!"; } - ba::async_write(m_socket, ba::buffer(*buffer), [=](boost::system::error_code ec, std::size_t length) + + auto self(shared_from_this()); + bytes* buffer = new bytes(_msg.toBytes()); + ba::async_write(m_socket, ba::buffer(*buffer), [self,buffer](boost::system::error_code ec, std::size_t length) { + delete buffer; if (ec) { cwarn << "Error sending: " << ec.message(); - dropped(); + self->dropped(); } // cbug << length << " bytes written (EC: " << ec << ")"; }); @@ -568,7 +574,7 @@ void PeerSession::start() void PeerSession::doRead() { auto self(shared_from_this()); - m_socket.async_read_some(boost::asio::buffer(m_data), [this, self](boost::system::error_code ec, std::size_t length) + m_socket.async_read_some(boost::asio::buffer(m_data), [this,self](boost::system::error_code ec, std::size_t length) { if (ec) { diff --git a/windows/bootstrap.sh b/windows/bootstrap.sh index 12935a91f..126889732 100644 --- a/windows/bootstrap.sh +++ b/windows/bootstrap.sh @@ -7,12 +7,25 @@ # - Visual Studio Express 2013 for Desktop # - On PATH: bash, git, git-svn, curl, sed, 7z +error_exit() { + echo $1 1>&2 + exit 1 +} + +for i in python perl curl git sed 7z; do + which $i &>/dev/null || error_exit "Could not find $i on PATH" +done + +if [ ! -d "$VS120COMNTOOLS" ]; then + error_exit "Couldn't find Visual Studio 2013" +fi + if [[ ! $@ ]] || [ $1 == "fetch" ]; then # fetch ethereum (develop branch) if [ ! -d cpp-ethereum ]; then (set -x; git clone https://github.com/ethereum/cpp-ethereum.git) cd cpp-ethereum - (set -x; git checkout origin/develop) + (set -x; git checkout -b develop origin/develop) cd .. echo fi