Browse Source

Change JackRequestDecoder for Windows.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4694 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/1.9.9.5
sletz 13 years ago
parent
commit
045c0544f2
4 changed files with 31 additions and 23 deletions
  1. +10
    -14
      common/JackRequestDecoder.cpp
  2. +1
    -1
      common/JackRequestDecoder.h
  3. +8
    -2
      posix/JackSocketServerChannel.cpp
  4. +12
    -6
      windows/JackWinNamedPipeServerChannel.cpp

+ 10
- 14
common/JackRequestDecoder.cpp View File

@@ -37,17 +37,12 @@ JackRequestDecoder::JackRequestDecoder(JackServer* server, JackClientHandlerInte
JackRequestDecoder::~JackRequestDecoder()
{}

bool JackRequestDecoder::HandleRequest(detail::JackChannelTransactionInterface* socket)
void JackRequestDecoder::HandleRequest(detail::JackChannelTransactionInterface* socket, int type_aux)
{
// Read header
JackRequest header;
if (header.Read(socket) < 0) {
jack_log("HandleRequest: cannot read header");
return false;
}

JackRequest::RequestType type = (JackRequest::RequestType)type_aux;
// Read data
switch (header.fType) {
switch (type) {

case JackRequest::kClientCheck: {
jack_log("JackRequest::ClientCheck");
@@ -58,8 +53,11 @@ bool JackRequestDecoder::HandleRequest(detail::JackChannelTransactionInterface*
if (res.Write(socket) < 0)
jack_error("JackRequest::ClientCheck write error name = %s", req.fName);
// Atomic ClientCheck followed by ClientOpen on same socket
if (req.fOpen)
HandleRequest(socket);
if (req.fOpen) {
JackRequest header;
header.Read(socket);
HandleRequest(socket, header.fType);
}
break;
}

@@ -369,11 +367,9 @@ bool JackRequestDecoder::HandleRequest(detail::JackChannelTransactionInterface*
}

default:
jack_error("Unknown request %ld", header.fType);
jack_error("Unknown request %ld", type);
break;
}

return true;
}

} // end of namespace


+ 1
- 1
common/JackRequestDecoder.h View File

@@ -52,7 +52,7 @@ class JackRequestDecoder
JackRequestDecoder(JackServer* server, JackClientHandlerInterface* handler);
virtual ~JackRequestDecoder();

bool HandleRequest(detail::JackChannelTransactionInterface* socket);
void HandleRequest(detail::JackChannelTransactionInterface* socket, int type);
};

} // end of namespace


+ 8
- 2
posix/JackSocketServerChannel.cpp View File

@@ -236,9 +236,15 @@ bool JackSocketServerChannel::Execute()
jack_log("Poll client error err = %s", strerror(errno));
ClientKill(fd);
} else if (fPollTable[i].revents & POLLIN) {
if (!fDecoder->HandleRequest(fSocketTable[fd].second)) {
jack_log("Could not handle external client request");
// Read header
JackClientSocket* socket = fSocketTable[fd].second;
JackRequest header;
if (header.Read(socket) < 0) {
jack_log("HandleRequest: cannot read header");
ClientKill(fd);
return false;
} else {
fDecoder->HandleRequest(socket, header.fType);
}
}
}


+ 12
- 6
windows/JackWinNamedPipeServerChannel.cpp View File

@@ -88,18 +88,24 @@ bool JackClientPipeThread::Execute()
try{
jack_log("JackClientPipeThread::Execute");
JackRequest header;
if (header.Read(socket) < 0) {
jack_log("HandleRequest: cannot read header");
ClientKill(fd);
return false;
}
// Lock the global mutex
if (WaitForSingleObject(fMutex, INFINITE) == WAIT_FAILED) {
jack_error("JackClientPipeThread::HandleRequest: mutex wait error");
}

bool res = fDecoder->HandleRequest(fPipe);
if (!res) {
ClientKill();
}
fDecoder->HandleRequest(fPipe, header.fType);
// Unlock the global mutex
ReleaseMutex(fMutex);
if (!ReleaseMutex(fMutex)) {
jack_error("JackClientPipeThread::HandleRequest: mutex release error");
}
return res;
} catch (JackQuitException& e) {


Loading…
Cancel
Save