Browse Source

JackRequest: Make ReadType method static

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/548/head
Timo Wischer Adam Miartus 7 years ago
parent
commit
f51071912b
4 changed files with 13 additions and 11 deletions
  1. +4
    -2
      common/JackRequest.h
  2. +3
    -3
      common/JackRequestDecoder.cpp
  3. +3
    -3
      posix/JackSocketServerChannel.cpp
  4. +3
    -3
      windows/JackWinNamedPipeServerChannel.cpp

+ 4
- 2
common/JackRequest.h View File

@@ -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; }


+ 3
- 3
common/JackRequestDecoder.cpp View File

@@ -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;
}


+ 3
- 3
posix/JackSocketServerChannel.cpp View File

@@ -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);
}
}
}


+ 3
- 3
windows/JackWinNamedPipeServerChannel.cpp View File

@@ -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;
}



Loading…
Cancel
Save