diff --git a/common/JackRequest.h b/common/JackRequest.h index 3c2c8bef..a3334b46 100644 --- a/common/JackRequest.h +++ b/common/JackRequest.h @@ -105,9 +105,11 @@ struct JackRequest virtual ~JackRequest() {} - virtual int Read(detail::JackChannelTransactionInterface* trans) + static int ReadType(detail::JackChannelTransactionInterface* trans, RequestType& type) { - return trans->Read(&fType, sizeof(RequestType)); + type = (RequestType)0; + CheckRes(trans->Read(&type, sizeof(fType))); + return 0; } virtual int Write(detail::JackChannelTransactionInterface* trans) { return -1; } diff --git a/common/JackRequestDecoder.cpp b/common/JackRequestDecoder.cpp index 46bbd1f3..3c18f964 100644 --- a/common/JackRequestDecoder.cpp +++ b/common/JackRequestDecoder.cpp @@ -58,9 +58,9 @@ int JackRequestDecoder::HandleRequest(detail::JackChannelTransactionInterface* s CheckWriteName("JackRequest::ClientCheck", socket); // Atomic ClientCheck followed by ClientOpen on same socket if (req.fOpen) { - JackRequest header; - header.Read(socket); - return HandleRequest(socket, header.fType); + JackRequest::RequestType type; + JackRequest::ReadType(socket, type); + return HandleRequest(socket, type); } break; } diff --git a/posix/JackSocketServerChannel.cpp b/posix/JackSocketServerChannel.cpp index a53e9e85..2cb35f84 100644 --- a/posix/JackSocketServerChannel.cpp +++ b/posix/JackSocketServerChannel.cpp @@ -236,14 +236,14 @@ bool JackSocketServerChannel::Execute() } else if (fPollTable[i].revents & POLLIN) { JackClientSocket* socket = fSocketTable[fd].second; // Decode header - JackRequest header; - if (header.Read(socket) < 0) { + JackRequest::RequestType type; + if (JackRequest::ReadType(socket, type) < 0) { jack_log("JackSocketServerChannel::Execute : cannot decode header"); ClientKill(fd); // Decode request } else { // Result is not needed here - fDecoder->HandleRequest(socket, header.fType); + fDecoder->HandleRequest(socket, type); } } } diff --git a/windows/JackWinNamedPipeServerChannel.cpp b/windows/JackWinNamedPipeServerChannel.cpp index 954fae2a..6b5b96c6 100644 --- a/windows/JackWinNamedPipeServerChannel.cpp +++ b/windows/JackWinNamedPipeServerChannel.cpp @@ -83,8 +83,8 @@ bool JackClientPipeThread::Execute() try { jack_log("JackClientPipeThread::Execute %x", this); - JackRequest header; - int res = header.Read(fPipe); + JackRequest::RequestType type; + int res = JackRequest::ReadType(fPipe, type); bool ret = true; // Lock the global mutex @@ -98,7 +98,7 @@ bool JackClientPipeThread::Execute() ClientKill(); ret = false; // Decode request - } else if (fDecoder->HandleRequest(fPipe, header.fType) < 0) { + } else if (fDecoder->HandleRequest(fPipe, type) < 0) { ret = false; }