Page MenuHomePhabricator

D8227.diff
No OneTemporary

D8227.diff

diff --git a/src/net.h b/src/net.h
--- a/src/net.h
+++ b/src/net.h
@@ -680,8 +680,6 @@
*/
class TransportDeserializer {
public:
- // prepare for next message
- virtual void Reset() = 0;
// returns true if the current deserialization is complete
virtual bool Complete() const = 0;
// set the serialization context version
@@ -714,15 +712,6 @@
int readHeader(const Config &config, const char *pch, uint32_t nBytes);
int readData(const char *pch, uint32_t nBytes);
-public:
- V1TransportDeserializer(
- const CMessageHeader::MessageMagic &pchMessageStartIn, int nTypeIn,
- int nVersionIn)
- : hdrbuf(nTypeIn, nVersionIn), hdr(pchMessageStartIn),
- vRecv(nTypeIn, nVersionIn) {
- Reset();
- }
-
void Reset() {
vRecv.clear();
hdrbuf.clear();
@@ -734,6 +723,15 @@
hasher.Reset();
}
+public:
+ V1TransportDeserializer(
+ const CMessageHeader::MessageMagic &pchMessageStartIn, int nTypeIn,
+ int nVersionIn)
+ : hdrbuf(nTypeIn, nVersionIn), hdr(pchMessageStartIn),
+ vRecv(nTypeIn, nVersionIn) {
+ Reset();
+ }
+
bool Complete() const {
if (!in_data) {
return false;
@@ -747,8 +745,12 @@
vRecv.SetVersion(nVersionIn);
}
int Read(const Config &config, const char *pch, uint32_t nBytes) {
- return in_data ? readData(pch, nBytes)
- : readHeader(config, pch, nBytes);
+ int ret =
+ in_data ? readData(pch, nBytes) : readHeader(config, pch, nBytes);
+ if (ret < 0) {
+ Reset();
+ }
+ return ret;
}
CNetMessage GetMessage(const Config &config, int64_t time);
diff --git a/src/net.cpp b/src/net.cpp
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -582,7 +582,6 @@
int handled = m_deserializer->Read(config, pch, nBytes);
if (handled < 0) {
- m_deserializer->Reset();
return false;
}

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 1, 11:34 (5 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5187636
Default Alt Text
D8227.diff (1 KB)

Event Timeline