Therefore no object of the class has to be created to detect the type only. In addition the member variable fType can be const. Change-Id: Ib9c484964a93d4f25ca0a354d6852c03a7b33896 Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>pull/386/head
| @@ -105,9 +105,11 @@ struct JackRequest | |||||
| virtual ~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; } | virtual int Write(detail::JackChannelTransactionInterface* trans) { return -1; } | ||||
| @@ -58,9 +58,9 @@ int JackRequestDecoder::HandleRequest(detail::JackChannelTransactionInterface* s | |||||
| CheckWriteName("JackRequest::ClientCheck", socket); | CheckWriteName("JackRequest::ClientCheck", socket); | ||||
| // Atomic ClientCheck followed by ClientOpen on same socket | // Atomic ClientCheck followed by ClientOpen on same socket | ||||
| if (req.fOpen) { | 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; | break; | ||||
| } | } | ||||
| @@ -235,14 +235,14 @@ bool JackSocketServerChannel::Execute() | |||||
| } else if (fPollTable[i].revents & POLLIN) { | } else if (fPollTable[i].revents & POLLIN) { | ||||
| JackClientSocket* socket = fSocketTable[fd].second; | JackClientSocket* socket = fSocketTable[fd].second; | ||||
| // Decode header | // 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"); | jack_log("JackSocketServerChannel::Execute : cannot decode header"); | ||||
| ClientKill(fd); | ClientKill(fd); | ||||
| // Decode request | // Decode request | ||||
| } else { | } else { | ||||
| // Result is not needed here | // Result is not needed here | ||||
| fDecoder->HandleRequest(socket, header.fType); | |||||
| fDecoder->HandleRequest(socket, type); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -83,8 +83,8 @@ bool JackClientPipeThread::Execute() | |||||
| try { | try { | ||||
| jack_log("JackClientPipeThread::Execute %x", this); | 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; | bool ret = true; | ||||
| // Lock the global mutex | // Lock the global mutex | ||||
| @@ -98,7 +98,7 @@ bool JackClientPipeThread::Execute() | |||||
| ClientKill(); | ClientKill(); | ||||
| ret = false; | ret = false; | ||||
| // Decode request | // Decode request | ||||
| } else if (fDecoder->HandleRequest(fPipe, header.fType) < 0) { | |||||
| } else if (fDecoder->HandleRequest(fPipe, type) < 0) { | |||||
| ret = false; | ret = false; | ||||
| } | } | ||||