diff --git a/common/JackRequest.h b/common/JackRequest.h index f504d800..a7f04bd1 100644 --- a/common/JackRequest.h +++ b/common/JackRequest.h @@ -94,6 +94,7 @@ struct JackRequest }; static const int StartMarker = 'R' | ('e' << 8) | ('q' << 16) | ('S' << 24); + static const int EndMarker = 'R' | ('e' << 8) | ('q' << 16) | ('E' << 24); static int ReadType(detail::JackChannelTransactionInterface* trans, RequestType& type) { @@ -136,6 +137,8 @@ protected: public: DATA d; protected: + const int fEnd = JackRequest::EndMarker; + template JackRequestMessage(Args&... args) : fType(DATA::Type()), fSize(sizeof(JackRequestMessage) - sizeof(fStart) - sizeof(fType) - sizeof(fSize)), @@ -151,7 +154,16 @@ protected: return -1; } + /* Size also contains fEnd */ CheckRes(trans->Read(&d, fSize)); + if (fEnd != JackRequest::EndMarker) { + jack_error("Request end marker not found (exp %08x act %08x). Request of type %d will be ignored!", + JackRequest::EndMarker, fEnd, fType); + + /* no need to sync here. Will be done by JackRequest::ReadType() */ + return -1; + } + return 0; }